Agent API reference
The HTTP API the SDK, the MCP proxy and the hook use. Use it directly only if you are writing an integration in another language: you then have to verify decisions exactly as described in Verifying a decision, or you lose the guarantees.
Base URL: https://api.aithorized.dev/v1
Authentication
| Header | |
|---|---|
Authorization | Bearer ak_live_…, the agent's API key. |
Idempotency-Key | Required on POST /requests: a UUID. The same key with the same body returns the original response for 24 hours; with a different body, 409 IDEMPOTENCY_CONFLICT. |
X-Aithorized-SDK | Your client and version, e.g. py/0.1.0. |
X-Aithorized-Policy-Version | The version of the signed policy bundle you evaluated. |
traceparent | Optional W3C trace context. |
GET /policies/bundle
The workspace's signed policy: { version, defaults, rules, autoRules, keyId, signature }. The signature is Ed25519 over the canonical JSON (RFC 8785) of the bundle without signature. Verify it with the key you pinned from the dashboard; refuse anything else. Poll about every minute.
POST /requests
Ask for approval. Body:
{
"agentId": "agt_…",
"sessionId": "ses_7f3c2a",
"action": "stripe.refund",
"payload": { "charge": "ch_1", "amount": 45000 },
"payloadHash": "sha256:…",
"payloadPreview": { "redactedPaths": [], "fields": [{ "path": "/amount", "label": "Amount", "value": "450.00 EUR" }] },
"dryRunPreview": { "source": "my-adapter", "kind": "api", "summary": "Refund 450.00 EUR", "impact": { "reversible": false } },
"diffPreview": null,
"editableFields": [{ "path": "/amount", "type": "integer", "min": 1, "max": 45000 }],
"reason": "Customer reported a duplicate charge.",
"riskLevel": "HIGH",
"approversRequired": 1,
"ttlSeconds": 300,
"policy": { "ruleId": "big-refunds", "version": 14 },
"context": { "environment": "prod" }
}payloadHash is sha256: + base64url of SHA-256 over the RFC 8785 canonical JSON of payload. The server recomputes it (422 PAYLOAD_HASH_MISMATCH), re-evaluates the policy (it may raise riskLevel or approversRequired, never lower them) and clamps ttlSeconds to 30–3600.
201:
{
"id": "req_…",
"status": "PENDING",
"riskLevel": "HIGH",
"approversRequired": 1,
"payloadHash": "sha256:…",
"createdAt": "2026-11-27T10:15:00.120Z",
"expiresAt": "2026-11-27T10:20:00.120Z",
"streamUrl": "/v1/requests/req_…/events"
}A matching temporary auto-approval rule answers 201 with status: "APPROVED" at once (never for CRITICAL).
GET /requests/{id}/events
Server-sent events until the request ends. Send Last-Event-ID to resume after a disconnect; a : ping comment arrives every 15 seconds.
id: 1
event: pending
data: {"id":"req_…","status":"PENDING","expiresAt":"…"}
id: 2
event: resolved
data: {"id":"req_…","status":"APPROVED","resolution":"HUMAN","decisionBundleUrl":"/v1/requests/req_…/decision-bundle"}resolved (any final status) and killed (kill switch) end the stream. Fallback: GET /requests/{id}?wait=25 answers when the status changes or after 25 seconds.
Keep your own deadline: if no final event arrives by expiresAt, treat the request as expired and do not run the action.
GET /requests/{id}/decision-bundle
The signed decision: the status, the original payloadHash, the finalPayload and its hash, the reviewer's feedback on a rejection, and every approver's signatures with their decisionObjects, plus the signed device-key directory.
Verifying a decision
All mandatory; any failure means do not run:
statusisAPPROVEDorMODIFIED_APPROVED.- The device-key directory is signed by a key you pinned.
- For each signature: its key is in the directory and not revoked, its class is enough for the risk (
STRONGforHIGHandCRITICAL), thedecisionObjectnames this request, this workspace and thispayloadHash, and the ECDSA P-256 signature is valid. - The number of distinct users with valid approvals is at least
approversRequired. - SHA-256 of the canonical
finalPayloadequalsfinalPayloadHash, and every signature commits to that same hash. finalPayloaddiffers from your payload only ateditableFieldspaths, within their limits.
@aithorized/core implements all of this (verifyDecisionBundle); its test vectors are the reference for other languages.
POST /requests/{id}/execution
After running (or failing to run) an approved action: { "executed": true, "finalPayloadHash": "sha256:…", "outcome": "SUCCESS", "durationMs": 412 }. 204. Audit only; it never changes the decision.
POST /observations
Shadow Mode, never blocking: { "agentId": "agt_…", "observations": [{ "ts": "…", "tool": "sql.execute", "argsShape": { "query": "string" }, "environment": "prod", "outcome": "SUCCESS" }] }. 202. At most 500 observations or 1 MiB per batch; drop the batch on failure.
Errors
Errors are JSON, { "error": { "code": "…", "message": "…" } }. Any non-2xx answer means the action must not run.
| Status | Codes |
|---|---|
| 400 | VALIDATION_ERROR |
| 401 | INVALID_API_KEY, API_KEY_REVOKED |
| 402 | QUOTA_EXCEEDED (Hobby's hard cap) |
| 403 | TENANT_SUSPENDED |
| 404 | REQUEST_NOT_FOUND |
| 409 | IDEMPOTENCY_CONFLICT |
| 422 | PAYLOAD_HASH_MISMATCH |
| 423 | KILL_SWITCH_ACTIVE, CIRCUIT_BROKEN |
| 429 | RATE_LIMITED (honour Retry-After) |
| 5xx | INTERNAL, UNAVAILABLE: retry the create with the same Idempotency-Key, within your deadline |