API reference (v1)

This page describes every /api/v1 endpoint, plus authentication, errors, rate limits and versioning. For a walkthrough, start with Getting started. The machine-readable version is openapi.json; a running server also serves it at GET /api/v1/openapi.json.

Conventions

  • Base URL: your ThreadPool deployment, for example https://threadpool.example.com. Locally it is http://localhost:3000.
  • Format: request and response bodies are JSON. Send Content-Type: application/json with every body.
  • No budgets or prices. Tasks, agents and approvals carry no price, budget or amount. What bounds an agent is its scope: which capability, which step, which operations, for how long.
  • Time: every timestamp is ISO 8601 in UTC, for example 2026-10-21T09:14:07.512Z.
  • Ids: opaque strings. Don't parse them.
  • Unknown fields: request bodies reject unknown fields (400 VALIDATION_ERROR), so typos fail loudly. Responses may gain new fields at any time; ignore the ones you don't recognise.
  • Request ids: every response has an X-Request-Id header. Error bodies repeat it as requestId. Quote it when you report a problem.
  • Caching: responses are Cache-Control: no-store.

Authentication

Every endpoint except GET /api/v1/openapi.json needs an organization API key in the Authorization header:

http
Authorization: Bearer tpk_k3v9q2m8x1z4_Jx3mQ9vT2rB7nL0pW5sY8cF1hK4dG6aE2iU9oZ3tR7w

Keys have the form tpk_<12 characters>_<43 characters>. The first part (tpk_k3v9q2m8x1z4) is the key's public prefix; the dashboard shows it so you can tell keys apart. The rest is a 256-bit secret.

How a key is authorized

A key belongs to one organization and acts as the member who created it. Each request is allowed only if all of these hold:

  1. The key exists, isn't revoked and hasn't expired.
  2. Its creator is still an active member of the organization.
  3. The key has the endpoint's scope.
  4. The creator's current role still allows that scope. Demoting the creator narrows their keys at once; removing or suspending them disables the keys.
ScopeAllowsRoles that can hold it
tasks:createPOST /api/v1/tasksOWNER, ADMIN, MANAGER, MEMBER
tasks:estimatePOST /api/v1/tasks/estimateOWNER, ADMIN, MANAGER, MEMBER
tasks:viewGET /api/v1/tasks/{id}, GET /api/v1/tasks/{id}/eventsevery role
approvals:decidePOST /api/v1/approvals/{id}OWNER, ADMIN, FINANCE
gateway:runEvery /api/v1/gateway endpoint (see Governance gateway)OWNER, ADMIN, MANAGER, MEMBER

Separation of duties. A key holding both tasks:create and approvals:decide can approve its own tasks' hires. If your approval policy is meant to put a second person in the loop, give approvals:decide to a separate key held by whoever approves.

Create, rotate and revoke keys

Only OWNER and ADMIN members can manage keys. You do this in the dashboard, not with an API key.

  1. Open Connect → API keys and choose New key.
  2. Enter a name, tick the scopes, and choose when it expires: in 30 days, 90 days, 1 year, or never.
  3. Copy the key from the dialog. It is shown once. ThreadPool stores only a SHA-256 hash, so a lost key cannot be recovered; create a new one.

An organization can have up to 10 active keys. Nobody can grant a scope beyond their own role.

Rotation. There is no rotate endpoint, because two keys can be live at once:

  1. Create the new key.
  2. Deploy it to your integration.
  3. Revoke the old key once its "last used" time stops moving.

Revocation takes effect on the next request; the key then gets 401 INVALID_API_KEY. Creating and revoking keys are recorded in the organization's event log (API_KEY_CREATED, API_KEY_REVOKED).

Storage. Treat keys like passwords: keep them in a secret manager or environment variable, never in source control, and never in browser or mobile code. The API is meant for server-to-server calls and doesn't send CORS headers.

Errors

Every error has the same shape:

json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "The request body is invalid.",
    "details": {
      "fieldErrors": { "qualityThreshold": ["Too big: expected number to be <=100"] },
      "formErrors": []
    }
  },
  "requestId": "req_3f9a1c0d2b7e4a5f6c8d9e0a"
}

Branch on error.code. message is for humans and may change wording. details appears only for some codes.

HTTPcodeMeaningWhat to do
400INVALID_JSONThe body is missing or isn't valid JSONSend a JSON object
400VALIDATION_ERRORA field is missing, out of range or unknown; or a bad or (on gateway writes) missing Idempotency-Key, limit or afterFix the request. details.fieldErrors names the fields
400AGENT_NOT_AVAILABLEAn id in approvedAgentIds isn't visible to your organizationRemove it
409AGENT_NOT_AVAILABLEA hosted agent you asked to run is suspended, paused, or was taken offline by the Circuit Breaker (message says which)Reactivate it in the dashboard, or run another agent
400TASK_NOT_ACTIONABLEThe prompt isn't a clear, actionable request (e.g. "hello")Rephrase the prompt
400CONTENT_POLICY_VIOLATIONThe task asks for content that facilitates illegal or harmful activity (phishing, fraud, malware, harassment, ...)Change the task; the attempt is logged as a security event
401UNAUTHENTICATEDNo Authorization: Bearer headerSend the key
401INVALID_API_KEYUnknown, revoked or expired key, or its creator has left or been suspendedUse a valid key. All of these look the same on purpose
403INSUFFICIENT_SCOPEThe key lacks the scope; details.requiredScope names itCreate a key with that scope
403FORBIDDENThe creator's current role no longer allows the action; or a gateway report was refused (details.reason)Ask an owner to restore the role, or use another key. For a refused report see Report a result
404NOT_FOUNDNo such task, approval, run or step in this key's organizationCheck the id. Other organizations' resources always look missing
409CONFLICTThe approval was already decided or expired; or the gateway run, step or authorization is not in a state for this call; or a request with the same Idempotency-Key is still runningRe-read the task or run. For an in-flight key, retry shortly with the same key
409IDEMPOTENCY_KEY_REUSEDThis Idempotency-Key was used before with a different body (or, on the gateway, a different operation or target)Use a new key for a new request
413PAYLOAD_TOO_LARGEA gateway request body is larger than 256 KBSend less; see the gateway limits
429RATE_LIMITEDA per-key rate limit was hitWait Retry-After seconds
502 / 504AGENT_RUN_FAILEDA hosted agent's model provider did not give an answer. details.reason is invalid_key, model_not_found, rate_limited, quota_exceeded, timeout, bad_request, empty_output, provider_error or not_configured; details.retryable says whether trying again can help. 504 is a timeoutFix the key or model in the dashboard, or retry when retryable is true. This is never ThreadPool's own rate limit (that is 429 RATE_LIMITED)
500INTERNAL_ERRORUnexpected server errorRetry reads; retry creates with the same Idempotency-Key
502ESTIMATE_UNAVAILABLEThe estimate couldn't be produced right nowRetry later, or create the task anyway

A 401 also carries WWW-Authenticate: Bearer realm="threadpool-api".

Rate limits

Limits are counted per API key over sliding windows. A request must pass every limit that applies to it.

Applies toLimit per key
Every /api/v1 request120 per minute and 3,000 per hour
POST /api/v1/tasks (also)3 per minute and 15 per hour
POST /api/v1/tasks/estimate (also)20 per minute
POST /api/v1/approvals/{id} (also)30 per minute
Every POST /api/v1/gateway/... (also)60 per minute and 1,500 per hour
POST /api/v1/gateway/runs/{id}/steps/{stepId}/verify (also)20 per minute and 400 per hour

A request counts against the limit even if it then fails validation. Separately, the server sheds floods from any single IP address across all of /api: 240 reads (GET) and 90 writes per minute.

Authenticated responses carry headers for the tightest per-key window of the "every request" limit:

HeaderMeaning
X-RateLimit-LimitRequests allowed in the window
X-RateLimit-RemainingRequests left in it
X-RateLimit-ResetUnix time (seconds) when the window resets

When a limit is hit you get 429 and a Retry-After header in seconds. For a per-key limit the body is the standard error, and the X-RateLimit-* headers describe the limit you hit:

json
{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded for this API key. Retry after the number of seconds in Retry-After.",
    "details": { "retryAfterSeconds": 42, "limit": 3 }
  },
  "requestId": "req_9d2e0b7a4c1f6e8d3a5b0c2f"
}

The per-IP limit replies before your key is checked, with a simpler body: {"error": "Too many requests. Please slow down and try again shortly.", "code": "RATE_LIMITED", "retryAfterSeconds": 12}. To handle both, branch on the 429 status and Retry-After, not on the body.

Operators: limits are shared across server instances only when Upstash Redis is configured (UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN). Without it, each instance counts on its own.

Task lifecycle

text
CREATED ─▶ PLANNING ─▶ IN_PROGRESS ─┬─▶ COMPLETED
                │           ▲  │     ├─▶ PARTIAL
                ▼           │  ▼     └─▶ FAILED
         AWAITING_APPROVAL ─┘  AWAITING_QA
                │
                └─▶ CANCELLED   (plan rejected or expired)
StatusMeaning
CREATEDAccepted; execution is starting
PLANNINGThe Manager is turning the prompt into a plan of steps
IN_PROGRESSAgents are being assigned, run and reviewed
AWAITING_APPROVALPaused on a human decision (see Decide an approval). Nobody is hired and no credential is issued while it waits
AWAITING_QAOutputs are being reviewed
COMPLETEDFinished; every step passed QA. result.content holds the report
PARTIALA report was produced but some steps couldn't be completed. result.incompleteSteps says which
FAILEDThe task could not produce a report. Every open assignment was ended. result.failureReason says why
CANCELLING / CANCELLEDCancelled from the dashboard, or a plan approval was rejected or expired

COMPLETED, PARTIAL, FAILED and CANCELLED are final.

Following a task. Use one of these:

  • Webhooks (recommended). Subscribe to TASK_COMPLETED, TASK_PARTIAL, TASK_FAILED and APPROVAL_REQUESTED, then read the task when one arrives. See Webhooks.
  • Polling. GET /api/v1/tasks/{id} every 5–10 seconds until the status is final. Polling also wakes a task whose background run was interrupted.
  • The event log. Poll GET /api/v1/tasks/{id}/events?after=<nextCursor> to receive each step as it happens.

A typical task takes a few minutes. It can take longer with many steps, slow agents, or a wait for approval.


Create a task

POST /api/v1/tasks · scope tasks:create

Creates a task and starts it in the background. It goes through the same checks as a task created in the dashboard: validation, agent visibility, approval gates, scoped credentials, the Circuit Breaker and QA. The response returns straight away with status: "CREATED".

Headers

HeaderRequiredDescription
AuthorizationyesBearer <key>
Content-Typeyesapplication/json
Idempotency-Keyno8–128 characters from A-Z a-z 0-9 _ - . :. See Idempotent retries

Body (TaskInput)

FieldTypeRequiredRules
promptstringyes3–6000 characters; a clear, actionable request
qualityThresholdintegerno0–100, default 70. The minimum QA score a step needs to be accepted
deadlinestringnoISO 8601 date-time, used in planning
dataSensitivitystringnoPUBLIC (default), INTERNAL or SENSITIVE. Limits which agents may see the task's data; SENSITIVE may require plan approval
approvedAgentIdsstring[]noUp to 50 agent ids explicitly allowed to receive the data. Each must be visible to your organization
workflowMemorystringnoAUTO (default) reuses similar past workflows; OFF plans from scratch
bash
curl -sS -X POST "$THREADPOOL_URL/api/v1/tasks" \
  -H "Authorization: Bearer $THREADPOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: report-2026-10-21-escooters" \
  -d '{
    "prompt": "Compare the top 5 European e-scooter operators on pricing, fleet size and funding.",
    "qualityThreshold": 75
  }'

201 Created. The Location header holds the task's path.

json
{
  "task": {
    "id": "cmh1x0q7z0003l80g5d2k9w1e",
    "status": "CREATED",
    "prompt": "Compare the top 5 European e-scooter operators on pricing, fleet size and funding.",
    "qualityThreshold": 75,
    "dataSensitivity": "PUBLIC",
    "workflowMemory": "AUTO",
    "deadline": null,
    "parentTaskId": null,
    "createdAt": "2026-10-21T09:10:02.118Z",
    "updatedAt": "2026-10-21T09:10:02.118Z",
    "steps": [],
    "approvals": [],
    "result": null
  }
}

Errors: 400 (INVALID_JSON, VALIDATION_ERROR, AGENT_NOT_AVAILABLE, TASK_NOT_ACTIONABLE, CONTENT_POLICY_VIOLATION), 401, 403 (INSUFFICIENT_SCOPE, FORBIDDEN), 409 IDEMPOTENCY_KEY_REUSED, 429, 500.

A request that still sends the removed budget field is refused by name, and nothing is created:

json
{
  "error": { "code": "VALIDATION_ERROR", "message": "The 'budget' field was removed: tasks no longer have a token budget. Remove it from the request body." },
  "requestId": "req_5c1d8e2f0a9b7c3d4e6f1a2b"
}

Idempotent retries

A timeout doesn't tell you whether the task was created, so send an Idempotency-Key with every create:

  • Same key, same body. Returns the task created the first time, with status 200 and Idempotent-Replayed: true. No second task is created.
  • Same key, different body. Returns 409 IDEMPOTENCY_KEY_REUSED.
  • Scope and lifetime. Keys are scoped to your organization and never expire. Use one per logical request, for example your own job or order id.

Estimate a task

POST /api/v1/tasks/estimate · scope tasks:estimate

Plans the task exactly as a real run would and predicts how it would be staffed and how well it would do, from agents' measured stats. It creates no task and hires nobody. The body is the same TaskInput as for creating a task.

bash
curl -sS -X POST "$THREADPOOL_URL/api/v1/tasks/estimate" \
  -H "Authorization: Bearer $THREADPOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Compare the top 5 European e-scooter operators on pricing, fleet size and funding.", "qualityThreshold": 75}'

200 OK (shortened)

json
{
  "estimate": {
    "basis": "Prediction from measured agent stats (unrated agents use the pool prior). Not a guarantee.",
    "planSource": "sarvam",
    "planReused": false,
    "steps": [
      { "sequence": 1, "type": "market_research", "capability": "web_research", "label": "Web research", "dependsOn": [], "eligibleAgents": 3, "agent": { "name": "Scout", "quality": 84, "rated": true } },
      { "sequence": 2, "type": "competitor_matrix", "capability": "competitive_analysis", "label": "Competitive analysis", "dependsOn": [1], "eligibleAgents": 2, "agent": { "name": "Rival", "quality": 86, "rated": true } }
    ],
    "dropped": [],
    "outlook": { "bestQuality": 90, "thresholdReachable": true },
    "prediction": { "strategy": "Balanced", "expectedQuality": 85, "weakestStepQuality": 82, "meetThresholdProbability": 0.87, "criticalPathLatencyMs": 94000, "unratedSteps": 0, "allUnrated": false },
    "recommendations": [
      { "code": "ok", "message": "Threshold 75 looks achievable with current agents." }
    ],
    "inputs": null
  }
}

planSource is "local_fallback" when the Manager LLM is unavailable and the deterministic planner was used instead. The estimate is labelled as such and not presented as the LLM's plan. steps[].eligibleAgents is how many agents could be hired for that step right now. dropped lists steps the plan was trimmed of (nobody can be hired for them, or your organization limits plan size), each with a reason. The numbers above are an example; real ones come from your deployment's measured agent stats.

Errors: 400, 401, 403, 429, 500, and 502 ESTIMATE_UNAVAILABLE.

Get a task

GET /api/v1/tasks/{id} · scope tasks:view

Path parameterDescription
idTask id
bash
curl -sS "$THREADPOOL_URL/api/v1/tasks/cmh1x0q7z0003l80g5d2k9w1e" \
  -H "Authorization: Bearer $THREADPOOL_API_KEY"

200 OK for a finished task (shortened)

json
{
  "task": {
    "id": "cmh1x0q7z0003l80g5d2k9w1e",
    "status": "COMPLETED",
    "prompt": "Compare the top 5 European e-scooter operators on pricing, fleet size and funding.",
    "qualityThreshold": 75,
    "dataSensitivity": "PUBLIC",
    "workflowMemory": "AUTO",
    "deadline": null,
    "parentTaskId": null,
    "createdAt": "2026-10-21T09:10:02.118Z",
    "updatedAt": "2026-10-21T09:14:07.498Z",
    "steps": [
      {
        "id": "cmh1x3p1c0004l80gq8t6v1n2",
        "sequence": 1,
        "capability": "web_research",
        "type": "market_research",
        "description": "Collect pricing, fleet size and funding for the top European operators.",
        "status": "DONE",
        "attempts": 1,
        "qaScore": 86,
        "agent": { "id": "agent-research-standard", "name": "Scout" },
        "inherited": false,
        "skipReason": null,
        "outcome": "accepted",
        "assignments": 1
      }
    ],
    "approvals": [],
    "result": {
      "content": "# European e-scooter operators\n\n...",
      "failureReason": null,
      "averageQuality": 85,
      "confidence": { "label": "high", "score": 81, "reason": "All steps passed QA with cited sources." },
      "review": { "approved": true, "score": 84, "reworkRounds": 0, "unresolvedIssues": [] },
      "sources": [{ "id": "S1", "title": "Operator funding round", "url": "https://example.com/article", "kind": "page", "cited": true }],
      "incompleteSteps": []
    }
  }
}

result is null until the task reaches a final status. result.content is the report as Markdown. Each step's outcome says how its agent's responsibility ended, and assignments how many agents held it.

Errors: 401, 403, 404 NOT_FOUND (including tasks of other organizations), 429, 500.

List task events

GET /api/v1/tasks/{id}/events · scope tasks:view

Returns the task's persisted event log, oldest first.

Query parameterDefaultDescription
after—Return only events after this event id. Pass the previous page's nextCursor
limit100Page size, 1–500
bash
curl -sS "$THREADPOOL_URL/api/v1/tasks/cmh1x0q7z0003l80g5d2k9w1e/events?limit=2" \
  -H "Authorization: Bearer $THREADPOOL_API_KEY"

200 OK

json
{
  "events": [
    { "id": "cmh1x0q8a0004l80gd1f7k2s9", "type": "TASK_CREATED", "actor": "system", "createdAt": "2026-10-21T09:10:02.131Z", "data": { "prompt": "Compare the top 5 European e-scooter operators on pricing, fleet size and funding.", "attachments": 0, "via": "api", "apiKeyId": "cmh0z9y2k0001l80g3b7n5m8c" } },
    { "id": "cmh1x0r1b0006l80gk4h2p7d3", "type": "MANAGER_PLANNING", "actor": "manager", "createdAt": "2026-10-21T09:10:02.904Z", "data": {} }
  ],
  "hasMore": true,
  "nextCursor": "cmh1x0r1b0006l80gk4h2p7d3"
}
  • Next page. Request again with after=<nextCursor>.
  • Polling for new events. Keep passing the last nextCursor. When nothing is new you get "events": [] and the same cursor back.
  • Cursor errors. An after that isn't an event of this task returns 400 VALIDATION_ERROR.

Common event types include TASK_CREATED, MANAGER_PLANNING, SUBTASK_CREATED, AGENTS_DISCOVERED, AGENTS_FILTERED, AGENTS_RANKED, AGENT_SELECTED, STEP_ASSIGNED, WORK_STARTED, WORK_COMPLETED, QA_PASSED, QA_FAILED, STEP_ACCEPTED, STEP_REJECTED, ACTION_BLOCKED, APPROVAL_REQUESTED, APPROVAL_GRANTED, APPROVAL_REJECTED, APPROVAL_EXPIRED, TASK_COMPLETED, TASK_PARTIAL and TASK_FAILED. New types may be added; ignore ones you don't use. data differs by type. AGENTS_RANKED is emitted only when two or more agents were eligible for a step; AGENT_SELECTED always is, and its data.selection is sole_eligible (nothing was scored, so no scoreBreakdown) or ranked. Older tasks may lack selection.

Errors: 400, 401, 403, 404, 429, 500.

Decide an approval

POST /api/v1/approvals/{id} · scope approvals:decide

An organization can require a human decision before work is committed. Owners and admins set this under Organization → Approvals. There are two kinds of approval:

  • PLAN comes after planning and before any hire. Approving starts the work. Rejecting it, or letting it expire, cancels the task. Nobody was hired.
  • HIRE comes before a particular agent is hired, when the organization's policy asks for it: every hire, hires of outside providers' agents, or hires for listed capabilities. Approving hires that agent for that step. Rejecting moves on to the next-ranked agent, which may need approval too.

While a request is open, the task is AWAITING_APPROVAL: nobody is hired and no credential is issued for it. A request that expires is treated as rejected.

Finding the approval id. It appears in each of these:

  • task.approvals[] where status is "PENDING"
  • the APPROVAL_REQUESTED event in the task's event log
  • the APPROVAL_REQUESTED webhook

The key's creator must be an OWNER, ADMIN or FINANCE member, and the approval must belong to a task in the key's organization.

Path parameterDescription
idApproval request id
Body fieldTypeRequiredDescription
decisionstringyes"approve" or "reject"
reasonstringnoUp to 500 characters, kept on the record
bash
curl -sS -X POST "$THREADPOOL_URL/api/v1/approvals/cmh1x5k8e0007l80gw2q4z8n1" \
  -H "Authorization: Bearer $THREADPOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"decision": "approve", "reason": "Scope looks right for this request."}'

200 OK

json
{
  "approval": {
    "id": "cmh1x5k8e0007l80gw2q4z8n1",
    "kind": "PLAN",
    "status": "APPROVED",
    "subtaskId": null,
    "agentId": null,
    "reasons": ["plan_policy"],
    "expiresAt": "2026-10-21T10:11:30.000Z",
    "decidedAt": "2026-10-21T09:12:41.207Z",
    "decisionReason": "Scope looks right for this request.",
    "createdAt": "2026-10-21T09:11:30.000Z"
  },
  "taskResumed": true,
  "taskCancelled": false
}

taskResumed means the task continues on its own. taskCancelled is true after rejecting a PLAN. A request can be decided only once:

json
{
  "error": { "code": "CONFLICT", "message": "This request was already approved." },
  "requestId": "req_0a7c3e9b1d5f2a8c6e4b0d1f"
}

reasons lists why approval was needed: plan_policy, sensitive_data or hire_policy. Decisions made with a key are recorded with that key's id (APPROVAL_GRANTED / APPROVAL_REJECTED events carry "via": "api").

Errors: 400, 401, 403 (INSUFFICIENT_SCOPE, FORBIDDEN), 404, 409 CONFLICT (already decided or expired), 429, 500.

Hosted agents

Agents that ThreadPool runs for you, on your own model provider key (OpenAI, Anthropic, Google Gemini or Sarvam AI) with your own system prompt. You create them in the dashboard under Organization → Agents → Host an agent, where the key is checked with a real call, encrypted at rest and never shown again. A hosted agent can be hired by the Manager once it passes calibration, and, whether calibrated or not, you can run it directly with these two endpoints. Each run is one call to your provider, so it spends your provider quota, and ThreadPool keeps a record of who ran it and how it ended (lengths and hashes, never the text).

EndpointDescription
GET /api/v1/agents · scope agents:runThe organization's hosted agents: { agents: [{ id, name, description, capabilities, model: { provider, name }, available }] }. available is false while the agent is paused, suspended or offline. Never includes system prompts, settings or key hints
POST /api/v1/agents/{id}/run · scope agents:runRun the agent on one input: { input } (1 to 32,000 characters). 200 with { run: { id, agentId, status, output, model, usage: { inputTokens, outputTokens }, latencyMs, createdAt } }
bash
curl -X POST "$THREADPOOL_URL/api/v1/agents/$AGENT_ID/run" \
  -H "Authorization: Bearer $THREADPOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "input": "Summarise the termination clause in two sentences." }'

An agent of another organization is a 404 NOT_FOUND, exactly like a missing one. The agent answers with its saved system prompt; you cannot override it per request. A run is not a QA-verified task step: it does not change the agent's measured quality, reputation or routing. If the provider refuses (a revoked key, no quota, an unknown model) you get 502 AGENT_RUN_FAILED with a details.reason, and nothing is retried for you.

Errors: 400 (INVALID_JSON, VALIDATION_ERROR), 401, 403 (INSUFFICIENT_SCOPE, FORBIDDEN), 404, 409 AGENT_NOT_AVAILABLE, 413, 429, 500, 502 / 504 (AGENT_RUN_FAILED).

Governance gateway

For agents you run yourself: ThreadPool authorizes each step, verifies what your agent reports and records the outcome, without executing anything. The model, every decision and reason code, and the MCP server and SDK are described in Governance gateway. Every gateway POST requires an Idempotency-Key (see Idempotency).

EndpointDescription
POST /api/v1/gateway/runs · scope gateway:runOpen a governed run: { title, qualityThreshold?, dataSensitivity?, enforcement? }. 201 with { run, controls }; controls states what governs the run and what it is not protected by
GET /api/v1/gateway/capabilities · scope gateway:runThe values a step's capability accepts, each with a label and what it is for, plus stepKinds and enforcement. Read it instead of guessing: any other capability is a 400
GET /api/v1/gateway/credentials/{credentialId} · scope gateway:runRead-only: is this credential still a live authorization? 200 with { valid, reason?, credential }. Call it from your own tool layer before a side effect
GET /api/v1/gateway/runs/{id} · scope gateway:runRead the run, its steps, verdicts and approval requests
POST /api/v1/gateway/runs/{id}/steps · scope gateway:runDeclare a step and your agent: { capability, skill?, kind?, description?, allowedTools?, agent: { id, name } }. 201 with { step }. A new agent id that looks like a revoked or inactive one, or more than 50 new agents in 24 hours, is refused (403)
POST /api/v1/gateway/runs/{id}/steps/{stepId}/authorize · scope gateway:runAsk for authority. 200 with decision: allow (with a scoped credential), deny or pending_approval
POST /api/v1/gateway/runs/{id}/steps/{stepId}/report · scope gateway:runReport the result: { credentialId, output, artifacts?, latencyMs?, toolCalls? }. An out-of-scope credential is refused and revokes the agent
POST /api/v1/gateway/runs/{id}/steps/{stepId}/abandon · scope gateway:runGive an unused authorization back when your agent could not finish: { reason? }. The step can be authorized again at once; the attempt still counts. 200 with { step, abandoned, attemptsUsed, attemptsRemaining }
POST /api/v1/gateway/runs/{id}/steps/{stepId}/verify · scope gateway:runRun ThreadPool QA on the report; the step is accepted or rejected. verdict.verifiedBy says whether a QA model or only deterministic checks decided it
POST /api/v1/gateway/runs/{id}/close · scope gateway:runClose the run: { run, summary, accountability, receipt: { hash, body } }

A governed run is a task, so GET /api/v1/tasks/{id} and its events also work for it. ThreadPool never plans, staffs or resumes a governed run.


Schemas

The full definitions are in openapi.json. Summary:

TaskInput

See the body table under Create a task. Unknown fields are rejected.

Task

FieldTypeDescription
idstringTask id
statusstringSee Task lifecycle
promptstringAs submitted
qualityThresholdinteger0–100
dataSensitivitystringPUBLIC, INTERNAL or SENSITIVE
workflowMemorystringAUTO or OFF
deadlinestring | nullISO 8601
parentTaskIdstring | nullSet on follow-up tasks created in the dashboard
createdAt, updatedAtstringISO 8601
stepsStep[]The plan, in order
approvalsApproval[]Every approval request of the task
resultTaskResult | nullSet when the task is final

Step

FieldTypeDescription
idstringStep id (also called subtask id)
sequenceintegerOrder in the plan
capabilitystringA capability id, e.g. web_research, competitive_analysis, financial_analysis, data_analysis, report_generation
typestringThe planner's short name for the step
descriptionstring | nullWhat the step must do
statusstringPENDING, SELECTING, ASSIGNED, EXECUTING, AWAITING_QA, DONE, FAILED (BIDDING also appears on tasks created before assignments replaced bidding)
attemptsintegerAttempts made
qaScorenumber | nullScore from independent QA
agentobject | null{ id, name } of the hired agent
inheritedbooleanCopied from a parent task by a follow-up
skipReasonstring | nullWhy the step was skipped, if it was
outcomestring | nullHow the step's responsibility ended: accepted, rejected, reassigned, cancelled or in_progress. null when no agent held the step
assignmentsintegerHow many agents held the step; more than one means it was reassigned

Approval

FieldTypeDescription
idstringApproval request id
kindstringPLAN or HIRE
statusstringPENDING, APPROVED, REJECTED, EXPIRED
subtaskId, agentIdstring | nullHIRE: the step and agent
reasonsstring[]plan_policy, sensitive_data, hire_policy
expiresAtstringAfter this time the request counts as rejected
decidedAt, decisionReasonstring | nullSet once decided
createdAtstringISO 8601

TaskResult

FieldTypeDescription
contentstring | nullThe report (Markdown)
failureReasonstring | nullSet when the task FAILED
averageQualitynumber | nullMean QA score of the steps
confidenceobject | null{ label, score, reason }, computed from QA and checks
reviewobject | nullFinal review: { approved, score, reworkRounds, unresolvedIssues }
sourcesobject[]Sources the report draws on: { id, title, url, kind, cited }
incompleteStepsobject[]Steps that could not be completed (on PARTIAL)

Event

FieldTypeDescription
idstringEvent id (use it as a cursor)
typestringEvent type
actorstringsystem, manager, circuit_breaker, an agent id, or a user id
createdAtstringISO 8601
dataobjectType-specific payload

Versioning and compatibility

  • Versioning. The version is in the path: /api/v1. Webhook payloads carry "apiVersion": "v1".
  • Changes that can happen within v1. New endpoints, new optional request fields, new response fields, new event types in the event log, and new error.code values on error statuses. Write clients that ignore unknown fields and treat an unknown error.code by its HTTP status.
  • Changes that need a new version. Removing or renaming a field, changing a field's type or meaning, making an optional request field required, and changing authentication or the error envelope. These would ship under a new path (/api/v2), with v1 kept running alongside it while integrations migrate.
  • Webhook event types. TASK_COMPLETED, TASK_PARTIAL, TASK_FAILED, CIRCUIT_BREAKER_TRIGGERED, APPROVAL_REQUESTED, POLICY_VIOLATION, APPROVAL_GRANTED, APPROVAL_REJECTED, APPROVAL_EXPIRED, GATEWAY_RUN_OPENED, GATEWAY_STEP_REPORTED, GATEWAY_RUN_CLOSED. New types can be added within v1; an endpoint only ever receives the types it subscribed to, and an existing type's payload only changes in the backwards-compatible ways listed above.

Breaking changes

The token budget was removed from the API. This is a breaking change made inside v1, because ThreadPool had no external integrations yet; it is listed here so nothing changes silently.

WhereBeforeNow
POST /api/v1/tasks, POST /api/v1/tasks/estimatebudget was requiredbudget is rejected with 400 VALIDATION_ERROR naming the field. Remove it
Taskbudget, spent, remainingBudget, escrowRemoved. Steps gain outcome and assignments
Estimatecost, prediction.expectedCost, steps[].agent.price, recommendations[].setBudgetRemoved. outlook and steps[].eligibleAgents are new
ApprovalamountRemoved. reasons value hire_above_threshold is now hire_policy
Errors403 SPEND_CAP_EXCEEDEDRemoved (there is no spend cap)
Webhookstask.budget, task.spent, task.remainingBudget; requestedAmount on CIRCUIT_BREAKER_TRIGGERED; amount on approvals and policy violationsRemoved
EventsESCROW_LOCKED, ESCROW_REFUNDED, TRANSACTION_BLOCKED, ...New tasks emit STEP_ASSIGNED, STEP_ACCEPTED, STEP_REJECTED, ACTION_BLOCKED. Tasks created earlier keep their original events

Tasks created before this change stay readable. Their own event log and report keep what was recorded at the time.