Keystone Developers
Open Keystone
API reference

Auth internal API

Agent run tokens

2 endpoints.

POST/api/v1/internal/agent-run-tokens

Issue Agent Run Token

A run token for one workflow-engine agent run (see ``app/core/mcp_tokens.py``).

A person's run (BUSINESS_USER, KEYSTONE_ADMIN) is minted for the person whose own token, bound to workflow-engine, it presents (``subject_token``): it acts for that person, with the role they hold now, and a business user must be a member of the business (sor says). A body naming anyone else as ``started_by`` is refused. With ``RUN_TOKEN_REQUIRE_SUBJECT`` off, a person's run without one is minted for the ``started_by`` workflow-engine names, as before (an agent type in ``AGENT_RUN_PERSON_AGENT_TYPES`` then carries that person's role). A SYSTEM run (a routine, or SOR's own task) and a CONTACT run (someone the account talks with, bound to the one conversation or call it serves) act for no person and carry no role.

Authentication

X-Agent-Run-Issuer-Key header.

Request bodyrequired

application/jsonInternalAgentRunTokenRequest
FieldTypeDescription
agent_typerequiredstringmin length 1 · max length 40 · pattern ^[a-z][a-z0-9_]*$
business_idrequiredstring (uuid)
run_idrequiredstringmin length 1 · max length 200 · pattern ^[^\x00-\x1f\x7f]+$
thread_idstring | null
conversation_idstring (uuid) | null
call_idstring | null
actor_typerequiredstringpattern ^(BUSINESS_USER|KEYSTONE_ADMIN|SYSTEM|CONTACT)$
started_bystring | null
toolsrequiredstring[]min items 1 · max items 400
string[] fields
agent_kindenum | null
routine_idstring | null
asking_message_idstring | null
subject_tokenstring | null
role_ceilinginteger | null

Responses

201Successful Response
application/jsonInternalAgentRunTokenResponse
FieldTypeDescription
tokenrequiredstring
expires_inrequiredinteger
  • 4XXRefused: `code` says why
  • 5XXFailed: `code` says why

Error bodies: ErrorBody. See Errors.

POST/api/v1/internal/agent-run-tokens/renew

Renew Agent Run Token

The next token of a person's run, for its previous token (live, or expired at most ``RUN_TOKEN_RENEW_GRACE_SECONDS`` ago) that their own token proved (``minted_from: subject_token``): the same person, business, run, thread and agent, with tools, role ceiling and asking message no wider than the previous token's. The person must still be an active user with the same kind of role, and a business user still a member. No renewal takes the run past ``RUN_TOKEN_MAX_RUN_HOURS`` since their own token last proved them (``proven_at``); after that, or once a previous token lapsed, only their own token mints the run again.

Authentication

X-Agent-Run-Issuer-Key header.

Request bodyrequired

application/jsonInternalAgentRunTokenRenewRequest
FieldTypeDescription
run_tokenrequiredstringmin length 1 · max length 16384
toolsstring[] | null
string[] | null fields
role_ceilinginteger | null
asking_message_idstring | null

Responses

201Successful Response
application/jsonInternalAgentRunTokenResponse

InternalAgentRunTokenResponse, expanded above.

  • 4XXRefused: `code` says why
  • 5XXFailed: `code` says why

Error bodies: ErrorBody. See Errors.