POST /api/v1/agents/:key/credentials
Auth: Guardian JWT (Authorization: Bearer) from login or register. Machine credentials (trm_…) are not JWTs and never reach this surface — agents and credentials are managed by their human owner only.
POST
/api/v1/agents/:key/credentialsstableMint a credential
| Name | In | Type | Required | Default | Allowed | Description |
|---|---|---|---|---|---|---|
key | query | string | required | — | — | The agent's agent_key (path segment). |
kind | body | string | required | — | api_key, mcp_token | api_key mints a trm_api_… secret for the REST surface; mcp_token mints a trm_mk_… token for MCP clients. |
label | body | string | optional | — | — | Free-text label for the credential list. |
writes_enabled | body | boolean | optional | false | — | Whether the credential may write memories. Recall-only by default. |
Mints a machine credential bound to the agent. The plaintext secret rides exactly this one response and is never retrievable again.
Response
| Field | Type | Allowed | Description |
|---|---|---|---|
credential | — | — | The credential metadata (no secret material). |
credential.id | string | — | Credential UUID. |
credential.agent_id | string | — | UUID of the bound agent. |
credential.kind | string | api_key, mcp_token | api_key mints a trm_api_… secret; mcp_token mints a trm_mk_… token. |
credential.label | string | — | Free-text label, or null. |
credential.key_prefix | string | — | Leading characters of the minted secret, for recognition. Metadata only — the token hash is never echoed. |
credential.writes_enabled | boolean | — | Whether the credential may write memories (default false). |
credential.last_used_at | string | — | Last successful use, or null. |
credential.revoked_at | string | — | Revocation timestamp, or null while live. |
credential.inserted_at | string | — | Mint timestamp (ISO-8601). |
credential.updated_at | string | — | Last-update timestamp (ISO-8601). |
secret | string | — | The plaintext secret (trm_api_… or trm_mk_…). Shown exactly once — store it now. |
Example
curl -X POST https://therobot.is/api/v1/agents/project-aria/credentials \
-H "Authorization: Bearer EXAMPLE_JWT" \
-H "Content-Type: application/json" \
-d '{"kind": "api_key", "label": "CI writer", "writes_enabled": true}'Errors
401{ "error": "Authentication required" }A well-formed but unknown or revoked trm_ bearer. The response does not say which.
404{ "error": "not found" }Unknown or foreign agent key — at the agent level the two are deliberately the same answer, so no existence leaks.
422{ "errors": { "field": ["message", …] } }Validation failure, as a per-field message map.