{"openapi":"3.1.0","info":{"title":"AgentLock API","version":"1.0.0","description":"AgentLock sits between an AI agent and the systems it acts on. Agents submit actions to the gateway; AgentLock evaluates the workspace policy, asks a person to approve the action when the policy requires it, runs it with credentials from the encrypted vault and returns the redacted result. Agents never receive the secrets.\n\nThis specification covers the endpoints that agents, the SDKs, the hook adapters and MCP clients call. Agents authenticate with Ed25519 request signing or with an agent token. The signed outcome notifications are described under `webhooks`. The full reference is at https://app.agentlock.net/docs/api.","license":{"name":"MIT","identifier":"MIT"}},"servers":[{"url":"https://app.agentlock.net"}],"tags":[{"name":"Gateway","description":"Submit actions and read their results."},{"name":"Credentials","description":"Vault credentials available to the agent."},{"name":"Messages","description":"Threaded messages between the agent and the workspace members."},{"name":"SSH sessions","description":"Persistent SSH sessions of the agent."},{"name":"Permission routing","description":"Tool permission decisions for coding agents."},{"name":"MCP","description":"MCP server over Streamable HTTP."}],"paths":{"/api/gateway/request":{"post":{"tags":["Gateway"],"operationId":"submitAction","summary":"Submit an action","description":"Evaluates the action against the policy. `ALLOW` starts execution, `REQUIRE_APPROVAL` waits for a person (HTTP 202) and `BLOCK` refuses it. Poll `GET /api/gateway/result/{requestId}` for the outcome. A browser action with a `session_id` runs immediately and returns its result in `result`.\n\nSigned body: the request body. The payload is redacted before it is stored; reference vault credentials by name or ID instead of sending secrets. For `http`, `credential_id` takes precedence over `credential_name`; when both are sent they must refer to the same credential.","security":[{"agentId":[],"agentTimestamp":[],"agentNonce":[],"agentSignature":[],"agentSignatureVersion":[]},{"agentToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActionRequest"},"example":{"action_type":"write","tool":"http","payload":{"method":"POST","url":"https://api.example.com/orders","body":{"item":"widget","quantity":10},"credential_name":"example-api"},"idempotency_key":"order-2026-12-02-001"}}}},"responses":{"200":{"description":"Allowed, blocked, an idempotent repeat or the result of an in-session browser action. The `request_id` of a blocked request or of an in-session browser action cannot be polled.","headers":{"x-request-id":{"$ref":"#/components/headers/XRequestId"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GatewayResponse"},"examples":{"allowed":{"summary":"Allowed","value":{"request_id":"7d9f3c2e-1a4b-4c8d-9e6f-0a1b2c3d4e5f","decision":"ALLOW","status":"ALLOWED"}},"blocked":{"summary":"Blocked","value":{"request_id":"0b6e4f1d-2c3a-4e5f-8a9b-1c2d3e4f5a6b","decision":"BLOCK","status":"BLOCKED","message":"Admin actions are not permitted by policy"}},"idempotent":{"summary":"Idempotent repeat","value":{"request_id":"7d9f3c2e-1a4b-4c8d-9e6f-0a1b2c3d4e5f","decision":"REQUIRE_APPROVAL","status":"PENDING","idempotent":true,"expires_at":"2026-12-02T10:05:00.000Z"}},"browserAction":{"summary":"In-session browser action","value":{"request_id":"0b6e4f1d-2c3a-4e5f-8a9b-1c2d3e4f5a6b","decision":"ALLOW","status":"ALLOWED","result":{"session_id":"bs_5e1c2d3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f","snapshot":"- heading \"Orders\" [level=1]\n- button \"New order\"","page_url":"https://shop.example.com/orders","page_title":"Orders","action_performed":"Clicked \"text=New order\""}}}}}}},"202":{"description":"Waiting for approval until `expires_at`.","headers":{"x-request-id":{"$ref":"#/components/headers/XRequestId"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GatewayResponse"},"example":{"request_id":"7d9f3c2e-1a4b-4c8d-9e6f-0a1b2c3d4e5f","decision":"REQUIRE_APPROVAL","status":"PENDING","expires_at":"2026-12-02T10:05:00.000Z"}}}},"400":{"description":"The body is not JSON (`Invalid JSON body`) or does not match the schema; an invalid payload, `webhook_url`, `credential_id` or agent ID; or an SSH credential stored without host and user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid request body"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Agent inactive, tool not on the agent allowlist, credential assigned to other agents, feature not on the plan, session owned by another agent, an in-session browser action the policy does not allow, or any in-session browser action while Safe Mode is on. The reason is in `error`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"request_id":"0b6e4f1d-2c3a-4e5f-8a9b-1c2d3e4f5a6b","error":"Tool 'ssh.run' not permitted for this agent","decision":"BLOCK","status":"BLOCKED"}}}},"404":{"description":"Credential (by name or ID), SSH credential or session not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Browser session not found"}}}},"409":{"$ref":"#/components/responses/Replay"},"410":{"description":"The browser or SSH session is closed or expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Browser session has expired"}}}},"423":{"description":"The workspace kill switch is engaged.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"request_id":"0b6e4f1d-2c3a-4e5f-8a9b-1c2d3e4f5a6b","decision":"BLOCK","status":"BLOCKED","error":"Workspace kill-switch is engaged. Contact a workspace admin to release it."}}}},"429":{"description":"Rate limit, hourly action limit, monthly action quota or concurrent session limit reached.","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Hourly action limit exceeded","limit":100,"retry_after":3600}}}},"500":{"description":"Unexpected error, or an in-session browser action failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Browser action failed"}}}},"503":{"$ref":"#/components/responses/Unavailable"}}}},"/api/gateway/result/{requestId}":{"get":{"tags":["Gateway"],"operationId":"getResult","summary":"Get the status and result of a request","description":"Returns the current status of a request of the calling agent and, once it has run, the redacted result. Poll until the status is final: `SUCCEEDED`, `FAILED`, `DENIED`, `EXPIRED` or `UNDONE`.\n\nSigned body: `{\"requestId\":\"<requestId>\"}`.","security":[{"agentId":[],"agentTimestamp":[],"agentNonce":[],"agentSignature":[],"agentSignatureVersion":[]},{"agentToken":[]}],"parameters":[{"name":"requestId","in":"path","required":true,"description":"The `request_id` returned by `POST /api/gateway/request`.","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Current status.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResultResponse"},"example":{"status":"SUCCEEDED","result":{"status":201,"ok":true,"headers":{"content-type":"application/json"},"body":{"id":"ord_123","created":true}},"error":null}}}},"400":{"description":"The request ID or agent ID is not a UUID.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid request ID"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"No such request for this agent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Request not found"}}}},"409":{"$ref":"#/components/responses/Replay"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/Unavailable"}}}},"/api/gateway/credentials":{"get":{"tags":["Credentials"],"operationId":"listCredentials","summary":"List usable credentials","description":"Lists the names and types of the vault credentials assigned to this agent or to no agent. Secret values are never returned.\n\nSigned body: `{}`.","security":[{"agentId":[],"agentTimestamp":[],"agentNonce":[],"agentSignature":[],"agentSignatureVersion":[]},{"agentToken":[]}],"responses":{"200":{"description":"Credentials the agent may use.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialList"},"example":{"credentials":[{"name":"example-api","type":"api_key"},{"name":"shop-login","type":"login"}]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"The agent is inactive.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Agent not found or inactive"}}}},"409":{"$ref":"#/components/responses/Replay"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/gateway/messages":{"get":{"tags":["Messages"],"operationId":"getMessages","summary":"Get messages for the agent","description":"By default returns unread messages from workspace members, oldest first, and marks them as read. Expired messages are not returned.\n\nMessages are marked as read while the response is sent. If the response is lost, for example to a 502 or 504, call again with `include_read=true` and `since` set to the time of the last received response, and keep the messages with `sender_type` `user` that were not handled yet.\n\nSigned body: `{\"_poll\":\"messages\"}`. Query parameters are not signed.","security":[{"agentId":[],"agentTimestamp":[],"agentNonce":[],"agentSignature":[],"agentSignatureVersion":[]},{"agentToken":[]}],"parameters":[{"name":"since","in":"query","description":"Only messages created after this time. An unparsable value is ignored.","schema":{"type":"string","format":"date-time"}},{"name":"limit","in":"query","description":"Maximum number of messages.","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"include_read","in":"query","description":"`true` also returns read messages and the agent's own messages. Combine it with `since` to fetch messages again after a lost response.","schema":{"type":"boolean","default":false}},{"name":"thread_id","in":"query","description":"Only messages of this thread. A value that is not a UUID returns HTTP 400.","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Messages.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageList"},"example":{"messages":[{"id":"3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e6f","thread_id":"9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d","sender_type":"user","sender_id":"5f6e7d8c-9b0a-4b1c-8d2e-3f4a5b6c7d8e","content":"Approved. Use the staging endpoint next time.","metadata":{},"expires_at":"2027-01-01T10:00:00.000Z","read_at":null,"created_at":"2026-12-02T10:00:00.000Z"}]}}}},"400":{"description":"The agent ID or `thread_id` is not a UUID.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"thread_id must be a UUID"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/AgentInactive"},"409":{"$ref":"#/components/responses/Replay"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/ServerError"}}},"post":{"tags":["Messages"],"operationId":"sendMessage","summary":"Send a message or start a thread","description":"Replies in an existing thread (`thread_id`) or starts a new thread (`create_thread: true`).\n\nSigned body: the request body.","security":[{"agentId":[],"agentTimestamp":[],"agentNonce":[],"agentSignature":[],"agentSignatureVersion":[]},{"agentToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/SendMessageRequest"},{"$ref":"#/components/schemas/CreateThreadRequest"}]},"examples":{"reply":{"summary":"Reply","value":{"thread_id":"9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d","content":"Done. The report is ready."}},"newThread":{"summary":"New thread","value":{"create_thread":true,"subject":"Deploy finished","content":"Version 2.1 is live on staging."}}}}}},"responses":{"201":{"description":"Message created. A new thread also returns `thread`.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/SendMessageResponse"},{"$ref":"#/components/schemas/CreateThreadResponse"}]},"example":{"message":{"id":"4d5e6f7a-8b9c-4d0e-9f1a-2b3c4d5e6f7a","thread_id":"9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d","sender_type":"agent","sender_id":"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d","content":"Done. The report is ready.","metadata":{},"expires_at":null,"created_at":"2026-12-02T10:01:00.000Z"}}}}},"400":{"description":"The body is not JSON (`Invalid JSON body`), does not match either schema, or the agent ID is not a UUID.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid request body","details":{"content":["String must contain at least 1 character(s)"]}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Agent inactive, or the monthly message or thread quota is reached.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Monthly message limit reached (100). Upgrade to send more."}}}},"404":{"description":"The thread does not exist or belongs to another agent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Conversation not found."}}}},"409":{"$ref":"#/components/responses/Replay"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/Unavailable"}}}},"/api/gateway/ssh-sessions":{"get":{"tags":["SSH sessions"],"operationId":"listSshSessions","summary":"List open SSH sessions","description":"Lists the agent's active, unexpired SSH sessions, most recently used first.\n\nSigned body: `{}`.","security":[{"agentId":[],"agentTimestamp":[],"agentNonce":[],"agentSignature":[],"agentSignatureVersion":[]},{"agentToken":[]}],"responses":{"200":{"description":"Open sessions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SshSessionList"},"example":{"sessions":[{"session_id":"ss_2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e","host":"build-01.example.com","port":22,"user":"deploy","via_vpn":false,"expires_at":"2026-12-02T10:20:00.000Z","last_activity_at":"2026-12-02T10:04:12.000Z","action_count":3}]}}}},"400":{"description":"The agent ID is not a UUID.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid agent ID format"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"409":{"$ref":"#/components/responses/Replay"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/gateway/permission-routing":{"post":{"tags":["Permission routing"],"operationId":"routePermission","summary":"Decide a coding agent tool call","description":"Called by the hook adapters before a coding agent runs a tool. Returns `allow`, `deny`, `ask_local` or `forward`. For `forward`, submit `action` unchanged to `POST /api/gateway/request` with the same token and poll the result; allow the call only on `SUCCEEDED`.","security":[{"agentToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HookInput"},"example":{"hook_event_name":"PreToolUse","session_id":"a1b2c3","cwd":"/home/dev/project","permission_mode":"default","tool_name":"Bash","tool_input":{"command":"git push origin main"}}}}},"responses":{"200":{"description":"The decision.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoutingDecision"},"example":{"decision":"forward","mode":"gateway","reason":"Shell command may mutate local or external state — no matching claudeBash rule, gateway default is approval","action":{"action_type":"write","tool":"permission.claude_code","payload":{"source":"claude_code","hook_event_name":"PreToolUse","session_id":"a1b2c3","cwd":"/home/dev/project","permission_mode":"default","tool_name":"Bash","action_type_hint":"write","classification_reason":"Shell command may mutate local or external state","tool_input":{"command":"git push origin main"},"input_sha256":"<hex SHA-256 of the canonical JSON of tool_input>","command":"git push origin main"}}}}}},"400":{"description":"The body is not valid JSON or does not match the schema.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid hook input"}}}},"401":{"description":"Missing, unknown, expired or revoked token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Authorization: Bearer <agent token> is required"}}}},"403":{"description":"The agent is inactive.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Agent inactive or not found"}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/mcp":{"post":{"tags":["MCP"],"operationId":"mcpJsonRpc","summary":"MCP JSON-RPC endpoint","description":"MCP over Streamable HTTP, protocol version `2025-03-26`, one JSON response per request. `initialize`, `ping` and notifications need no token; `tools/list` and `tools/call` need an agent token. Tools: `request_action` (`action_type`, `tool`, `payload`, optional `idempotency_key`) and `get_result` (`request_id`, optional `timeout_ms` from 1000 to 30000, default 30000). `request_action` answers at once with `ALLOWED`, `PENDING` or `BLOCKED`. `get_result` stops at a final status (`SUCCEEDED`, `FAILED`, `DENIED`, `EXPIRED`, `UNDONE`) or when the request is not found. Only `SUCCEEDED` counts as success: every other final status, and every HTTP error of the gateway, sets `isError` on the tool result.","security":[{},{"agentToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcRequest"},"example":{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"request_action","arguments":{"action_type":"read","tool":"http","payload":{"method":"GET","url":"https://api.example.com/items"}}}}}}},"responses":{"200":{"description":"JSON-RPC result, or a JSON-RPC error with code -32602 for an unknown tool.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcResponse"},"example":{"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","text":"{\"request_id\":\"7d9f3c2e-1a4b-4c8d-9e6f-0a1b2c3d4e5f\",\"decision\":\"ALLOW\",\"status\":\"ALLOWED\"}"}]}}}}},"202":{"description":"Notification accepted. Empty body."},"400":{"description":"Parse error (-32700) or invalid request (-32600).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcResponse"}}}},"401":{"description":"Missing or invalid token (-32001).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcResponse"}}}},"403":{"description":"The agent is not active (-32001).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcResponse"}}}},"404":{"description":"Unknown method (-32601).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcResponse"}}}},"429":{"description":"More than 60 calls per minute for this agent (-32000).","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcResponse"}}}}}}}},"webhooks":{"actionOutcome":{"post":{"operationId":"actionOutcome","summary":"Outcome of a request with `webhook_url`","description":"Sent to the `webhook_url` of a request when it succeeds, fails, is denied by an approver or expires without a decision. Blocked requests send none. Expired approvals are marked every 5 minutes, so an `EXPIRED` delivery can arrive up to 5 minutes after `expires_at`. Delivery is attempted once with a 5-second timeout.\n\nVerify every delivery: compute HMAC-SHA256 over `X-AgentLock-Timestamp`, a period and the raw body, with the workspace's webhook signing secret (`whsec_...`, under Settings > Webhook Signing Secret for owners and admins) as the key, and compare `sha256=<hex digest>` with `X-AgentLock-Signature` in constant time. Reject timestamps older than 5 minutes.","parameters":[{"name":"X-AgentLock-Timestamp","in":"header","required":true,"description":"Time of signing, ISO 8601.","schema":{"type":"string","format":"date-time"}}],"security":[{"webhookSignature":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookPayload"},"example":{"request_id":"7d9f3c2e-1a4b-4c8d-9e6f-0a1b2c3d4e5f","status":"SUCCEEDED","result":{"status":201,"ok":true,"body":{"id":"ord_123","created":true}},"timestamp":"2026-12-02T10:00:03.000Z"}}}},"responses":{"2XX":{"description":"Received. AgentLock does not retry a delivery, whatever the answer."}}}}},"components":{"securitySchemes":{"agentId":{"type":"apiKey","in":"header","name":"x-agent-id","description":"Request signing: the agent UUID. Sent together with `x-timestamp`, `x-nonce`, `x-signature-version` and `x-signature`."},"agentTimestamp":{"type":"apiKey","in":"header","name":"x-timestamp","description":"Request signing: current Unix time in milliseconds. Must be within 5 minutes of the server time."},"agentNonce":{"type":"apiKey","in":"header","name":"x-nonce","description":"Request signing: base64 of 16 random bytes, new for every request. A repeated nonce returns HTTP 409."},"agentSignatureVersion":{"type":"apiKey","in":"header","name":"x-signature-version","description":"Request signing: `2`."},"agentSignature":{"type":"apiKey","in":"header","name":"x-signature","description":"Request signing: base64 Ed25519 detached signature over the UTF-8 pre-image `2\\n<METHOD>\\n<path>\\n<x-timestamp>\\n<x-nonce>\\n<canonical JSON of the signed body>`. The signed body of each operation is named in its description."},"agentToken":{"type":"http","scheme":"bearer","description":"Agent token (`alt_...`) created in the dashboard. Takes precedence over the signing headers."},"webhookSignature":{"type":"apiKey","in":"header","name":"X-AgentLock-Signature","description":"Sent by AgentLock on webhook deliveries: `sha256=` followed by the hex HMAC-SHA256 of `<X-AgentLock-Timestamp>.<raw body>`, keyed with the workspace's webhook signing secret."}},"headers":{"XRequestId":{"description":"Identifier of the HTTP request.","schema":{"type":"string","format":"uuid"}},"RetryAfter":{"description":"Seconds to wait before retrying.","schema":{"type":"integer"}}},"responses":{"Unauthorized":{"description":"Missing or invalid authentication: unknown or inactive agent, missing nonce, invalid signature, timestamp outside the window, or an unknown, expired or revoked token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Unauthorized"}}}},"AgentInactive":{"description":"The agent is suspended or revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Agent inactive"}}}},"Replay":{"description":"The nonce was used before. Sign again with a new nonce.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Replay detected"}}}},"RateLimited":{"description":"Rate limit exceeded.","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Rate limit exceeded","retry_after":60}}}},"ServerError":{"description":"Unexpected error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Internal server error"}}}},"Unavailable":{"description":"Temporary failure. Retry with new signing headers.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Unable to schedule action. Please retry."}}}}},"schemas":{"ActionType":{"type":"string","enum":["read","write","financial","admin"],"description":"Declared risk class. The server raises it when the tool or payload warrants a higher class and never lowers it."},"ActionRequest":{"type":"object","required":["action_type","tool","payload"],"properties":{"action_type":{"$ref":"#/components/schemas/ActionType"},"tool":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[a-zA-Z0-9._\\-:]+$","description":"Tool to run, for example `http`, `browser.open`, `ssh.run`, `mcp.call_tool`."},"payload":{"type":"object","additionalProperties":true,"description":"Tool parameters, at most 64 KB as JSON."},"idempotency_key":{"type":"string","maxLength":128,"description":"A repeated request from the same agent with the same key returns the first request."},"cost_estimate":{"type":"number","minimum":0,"description":"Compared with the policy limit `maxCostPerAction`."},"webhook_url":{"type":"string","format":"uri","maxLength":2048,"description":"HTTPS URL that receives the outcome, signed with the workspace's webhook signing secret (see `webhooks`). Private and internal hosts are rejected."}}},"PermissionAction":{"type":"object","required":["action_type","tool","payload"],"description":"Action to submit unchanged to `POST /api/gateway/request`.","properties":{"action_type":{"$ref":"#/components/schemas/ActionType"},"tool":{"type":"string","const":"permission.claude_code"},"payload":{"type":"object","additionalProperties":true}}},"GatewayResponse":{"type":"object","required":["request_id","decision","status"],"properties":{"request_id":{"type":"string","format":"uuid"},"decision":{"type":"string","enum":["ALLOW","REQUIRE_APPROVAL","BLOCK"]},"status":{"type":"string","enum":["ALLOWED","PENDING","NEEDS_SECOND_APPROVAL","BLOCKED","DENIED","EXPIRED"],"description":"New requests are `ALLOWED`, `PENDING` or `BLOCKED`. An idempotent repeat reports the first request's current approval status."},"message":{"type":"string","description":"Reason for a block."},"expires_at":{"type":"string","format":"date-time","description":"End of the approval window."},"idempotent":{"type":"boolean","description":"`true` for an idempotent repeat."},"result":{"$ref":"#/components/schemas/BrowserResult"}}},"BrowserResult":{"type":"object","required":["session_id","snapshot","page_url","page_title","action_performed"],"properties":{"session_id":{"type":"string","description":"Browser session ID, `bs_` followed by a UUID."},"snapshot":{"type":"string","description":"Accessibility tree in Playwright ARIA snapshot format."},"page_url":{"type":"string"},"page_title":{"type":"string"},"action_performed":{"type":"string"},"screenshot":{"type":"string","description":"Base64 PNG, for `browser.screenshot`."}}},"ResultResponse":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["PENDING","NEEDS_SECOND_APPROVAL","QUEUED","RUNNING","SUCCEEDED","FAILED","DENIED","EXPIRED","UNDOING","UNDONE"]},"result":{"description":"Redacted tool output once the action has run. The shape depends on the tool."},"error":{"type":["string","null"],"description":"Cause of a `FAILED` action, at most 500 characters, with secrets, stack traces and internal paths removed."}}},"WebhookPayload":{"type":"object","required":["request_id","status","timestamp"],"properties":{"request_id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["SUCCEEDED","FAILED","DENIED","EXPIRED"]},"result":{"description":"Redacted tool output, for `SUCCEEDED`."},"error":{"type":"string","description":"Cause of the failure, for `FAILED`, with paths, URLs and secrets removed."},"timestamp":{"type":"string","format":"date-time"}}},"Credential":{"type":"object","required":["name","type"],"properties":{"name":{"type":"string"},"type":{"type":"string","description":"Credential type, for example `api_key`, `login`, `mcp`, `ssh` or `wireguard`."}}},"CredentialList":{"type":"object","required":["credentials"],"properties":{"credentials":{"type":"array","items":{"$ref":"#/components/schemas/Credential"}}}},"Message":{"type":"object","required":["id","thread_id","sender_type","sender_id","content","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"thread_id":{"type":"string","format":"uuid"},"sender_type":{"type":"string","enum":["user","agent"]},"sender_id":{"type":"string","format":"uuid"},"content":{"type":"string"},"metadata":{"type":["object","null"],"additionalProperties":true},"expires_at":{"type":["string","null"],"format":"date-time"},"read_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}},"MessageList":{"type":"object","required":["messages"],"properties":{"messages":{"type":"array","items":{"$ref":"#/components/schemas/Message"}}}},"SendMessageRequest":{"type":"object","required":["thread_id","content"],"properties":{"thread_id":{"type":"string","format":"uuid"},"content":{"type":"string","minLength":1,"maxLength":4096},"metadata":{"type":"object","additionalProperties":true,"description":"At most 8 KB as JSON."}}},"CreateThreadRequest":{"type":"object","required":["create_thread","content"],"properties":{"create_thread":{"type":"boolean","const":true},"content":{"type":"string","minLength":1,"maxLength":4096},"subject":{"type":"string","maxLength":200},"metadata":{"type":"object","additionalProperties":true,"description":"At most 8 KB as JSON."}}},"SendMessageResponse":{"type":"object","required":["message"],"properties":{"message":{"$ref":"#/components/schemas/Message"}}},"CreateThreadResponse":{"type":"object","required":["thread","message"],"properties":{"thread":{"type":"object","required":["id","subject"],"properties":{"id":{"type":"string","format":"uuid"},"subject":{"type":["string","null"]}}},"message":{"$ref":"#/components/schemas/Message"}}},"SshSession":{"type":"object","required":["session_id","host","port","user","via_vpn","expires_at"],"properties":{"session_id":{"type":"string","description":"SSH session ID, `ss_` followed by a UUID."},"host":{"type":"string"},"port":{"type":"integer"},"user":{"type":"string"},"via_vpn":{"type":"boolean"},"expires_at":{"type":"string","format":"date-time"},"last_activity_at":{"type":["string","null"],"format":"date-time"},"action_count":{"type":"integer"}}},"SshSessionList":{"type":"object","required":["sessions"],"properties":{"sessions":{"type":"array","items":{"$ref":"#/components/schemas/SshSession"}}}},"HookInput":{"type":"object","required":["tool_name"],"properties":{"tool_name":{"type":"string","minLength":1,"maxLength":100},"tool_input":{"type":"object","additionalProperties":true,"default":{}},"hook_event_name":{"type":"string","maxLength":100},"session_id":{"type":"string","maxLength":200},"transcript_path":{"type":"string","maxLength":1000},"cwd":{"type":"string","maxLength":1000},"permission_mode":{"type":"string","maxLength":100},"permission_suggestions":{"type":"array","items":{}}}},"RoutingDecision":{"type":"object","required":["decision","mode","reason"],"properties":{"decision":{"type":"string","enum":["allow","deny","ask_local","forward"]},"mode":{"type":"string","enum":["bypass","gateway","terminal"]},"reason":{"type":"string"},"matched_pattern":{"type":"string","description":"The `claudeBash` pattern behind an `allow` or `deny`."},"action":{"$ref":"#/components/schemas/PermissionAction"}}},"JsonRpcRequest":{"type":"object","required":["jsonrpc","method"],"properties":{"jsonrpc":{"type":"string","const":"2.0"},"id":{"type":["string","number","null"]},"method":{"type":"string","minLength":1},"params":{"type":"object","additionalProperties":true}}},"JsonRpcResponse":{"type":"object","required":["jsonrpc","id"],"properties":{"jsonrpc":{"type":"string","const":"2.0"},"id":{"type":["string","number","null"]},"result":{"description":"Method result."},"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}}}}},"Error":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"description":"Failing fields, on `POST /api/gateway/messages`."},"retry_after":{"type":"integer","description":"Seconds to wait, on HTTP 429."},"limit":{"type":"integer","description":"The hourly action limit, on HTTP 429."},"request_id":{"type":"string","format":"uuid"},"decision":{"type":"string"},"status":{"type":"string"}}}}}}