Auth internal API
Agent run tokens
2 endpoints.
/api/v1/internal/agent-run-tokensIssue 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| Field | Type | Description |
|---|---|---|
agent_typerequired | string | min length 1 · max length 40 · pattern ^[a-z][a-z0-9_]*$ |
business_idrequired | string (uuid) | |
run_idrequired | string | min length 1 · max length 200 · pattern ^[^\x00-\x1f\x7f]+$ |
thread_id | string | null | |
conversation_id | string (uuid) | null | |
call_id | string | null | |
actor_typerequired | string | pattern ^(BUSINESS_USER|KEYSTONE_ADMIN|SYSTEM|CONTACT)$ |
started_by | string | null | |
toolsrequired | string[] | min items 1 · max items 400string[] fields |
agent_kind | enum | null | |
routine_id | string | null | |
asking_message_id | string | null | |
subject_token | string | null | |
role_ceiling | integer | null |
Responses
201Successful Responseapplication/jsonInternalAgentRunTokenResponse| Field | Type | Description |
|---|---|---|
tokenrequired | string | |
expires_inrequired | integer |
4XXRefused: `code` says why5XXFailed: `code` says why
Error bodies: ErrorBody. See Errors.
/api/v1/internal/agent-run-tokens/renewRenew 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| Field | Type | Description |
|---|---|---|
run_tokenrequired | string | min length 1 · max length 16384 |
tools | string[] | null | string[] | null fields |
role_ceiling | integer | null | |
asking_message_id | string | null |
Responses
201Successful Responseapplication/jsonInternalAgentRunTokenResponseInternalAgentRunTokenResponse, expanded above.
4XXRefused: `code` says why5XXFailed: `code` says why
Error bodies: ErrorBody. See Errors.