Standard docs

Gate Agent API Reference

Your runtime owns reasoning and execution. Gate exposes six authenticated endpoints that wrap governed tool execution with contracts, policy, review, decisions, signed approval validation, and audit evidence.

Authentication

Use your own Gate installation as STACKSONA_GATE_URL and the agent's sg_ key as a Bearer token. JSON requests use Content-Type: application/json.

Runtime model

Gate wraps execution, it does not run the tools

Keep provider keys, service credentials, executable functions, retries, and business logic in your runtime. Resolve contracts earlier if useful, but evaluate the exact final tool arguments immediately before execution.

Resolve contractsRuntime selects toolGate evaluates callExecute, wait, revise, or replan

Endpoint overview

MethodPathPurpose
POST/api/agent/tools/resolveResolve governed tool contracts for the runtime.
POST/api/agent/tasks/{taskID}/eventsAppend runtime evidence or a guarded revision event.
POST/api/agent/tasks/{taskID}/requestsEvaluate the exact proposed tool call.
GET/api/agent/decisionsRead one current review decision by thread or task.
GET/api/agent/decisions/listDiscover pending or completed review references.
POST/api/agent/approvals/validateValidate and consume a one-time signed approval token.

Runtime quick start

bash
# 1. Resolve governed contracts
curl -sS -X POST "$STACKSONA_GATE_URL/api/agent/tools/resolve" \
  -H "Authorization: Bearer $STACKSONA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"tools":["issue_refund","send_email"]}'

# 2. Gate the exact proposed tool call
curl -sS -X POST "$STACKSONA_GATE_URL/api/agent/tasks/order-1042/requests" \
  -H "Authorization: Bearer $STACKSONA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"tool_name":"issue_refund","payload":{"amount":389.99,"currency":"usd"}}'

# 3. If pending_review, poll the exact returned thread
curl -sS "$STACKSONA_GATE_URL/api/agent/decisions?thread_id=THR-A1B2C3D4" \
  -H "Authorization: Bearer $STACKSONA_API_KEY"

1. Resolve tool contracts

Resolve registered tool contracts so the runtime can reason over the same names, descriptions, and input schemas configured in Gate.

FieldRequiredBehavior
toolsYesArray of 1 to 100 non-empty tool names. Exact duplicates are collapsed. Whitespace-only names are rejected.
json
{
  "tools": ["issue_refund", "send_email"]
}
json
{
  "tools": [
    {
      "name": "issue_refund",
      "description": "Issue a customer refund",
      "input_schema": {
        "type": "object",
        "required": ["amount"],
        "properties": {"amount": {"type": "number"}}
      }
    }
  ],
  "unregistered": ["send_email"]
}
Runtime responsibility

Validate model-generated arguments against input_schema in your runtime. Gate returns the schema but does not perform arbitrary JSON Schema validation on /requests.

The request body is limited to 16 KiB, unknown top-level fields are rejected, and the body must contain exactly one JSON object. A body over the current 16 KiB cap surfaces as HTTP 400.

2. Log an event

Append evidence to a runtime task. Ordinary event names are open-ended. The revision. prefix is the one namespace that changes request handling.

FieldRequiredDescription
event_typeYesAny non-empty event name. Use an application-owned namespace for custom evidence.
event_summaryYesHuman-readable evidence summary.
payloadNoStructured event evidence object.
imagesNoBase64 evidence images when attachments are enabled.
json
{
  "event_type": "tool.execution.completed",
  "event_summary": "Refund executed",
  "payload": {"provider_id": "rf_123"}
}

Success is 201 Created with no JSON body.

Event contract

Processed lifecycle names

EventMeaning
task.started / execution.startedStart timestamp markers used by runtime projection logic.
task.completed / execution.completedTerminal completed marker.
task.failed / execution.failedTerminal failure marker.
task.cancelled / execution.cancelledTerminal cancellation marker.
task.terminated / execution.terminatedTerminal forced-termination marker.

Recommended runtime conventions

task.request.loaded, task.input.loaded, task.sop.loaded, task.tools.available, tool.execution.completed, and tool.execution.failed.

Gate-generated names

approval.requested, decision.allow, decision.reject, decision.approved, decision.rejected, task.summary, token_issued, token_consumed, and token_rejected.

Custom by default

Ordinary custom event names are not checked against a fixed enum or reserved-name rejection list. Use your own namespace to avoid confusing application evidence with Gate lifecycle records.

3. Request a decision

Evaluate the exact tool call the runtime is about to execute. tool_name is the only required field.

FieldRequiredDefault / behavior
tool_nameYesExact tool selected by the runtime.
payloadNoExact tool arguments. Defaults to {}.
workflow_nameNoDefaults to agent workflow name, then agent name.
task_labelNoDefaults to the path taskID.
subjectNoDefaults to Review {tool_name}.
previewNoShort reviewer context.
risk_levelNolow, medium, high, or critical. Empty or unrecognized values currently normalize to medium.
summaryNoReview summary items. Defaults to an empty array.
imagesNoBase64 evidence images when attachments are enabled.
json
{
  "tool_name": "issue_refund",
  "payload": {
    "amount": 389.99,
    "currency": "usd"
  }
}

An unregistered tool request is still gateable. Gate routes it to human review with an unregistered-tool reason.

Responses

StatusMeaning
allowAutomatic policy allow. Execute the proposed call.
rejectAutomatic policy reject. Do not execute.
pending_reviewA human-review thread was created. Persist the returned thread_id.
json
{
  "status": "pending_review",
  "thread_id": "THR-A1B2C3D4",
  "task_id": "order-1042",
  "message": "Rule matched: amount upper_limit",
  "recommended_poll_after_seconds": 15
}

4. Get one decision

QueryUse
thread_idPreferred. Identifies the exact review request returned by /requests.
task_idReusable grouping ID. Resolves to the newest review thread for the authenticated agent and task.

Statuses to handle

pending_review, changes_requested, approved, and rejected.

json
{
  "status": "changes_requested",
  "thread_id": "THR-A1B2C3D4",
  "task_id": "order-1042",
  "message": "Reduce the amount and resubmit",
  "modification": {
    "requested_changes": "Reduce the amount and resubmit",
    "requested_at": "2026-08-09T17:00:00Z"
  },
  "recommended_poll_after_seconds": 3
}
Signed approvals

When enabled, the first successful read of an approved decision may additionally include approval_token and token_expires_at. The raw token is delivered once. If signed proof is required by your runtime, a missing token must block execution.

5. List decisions

ParameterDefaultBehavior
statuscompletedcompleted returns approved/rejected. pending returns needs-review/escalated threads as pending_review.
limit25Maximum 100. Results are scoped to the authenticated agent and ordered newest first.
json
{
  "decisions": [
    {
      "thread_id": "THR-A1B2C3D4",
      "task_id": "order-1042",
      "status": "approved",
      "updated_at": "2026-08-09T17:00:00Z"
    }
  ]
}

This endpoint is token-safe discovery. Listing a completed decision does not reveal or consume the one-time signed approval token. Fetch the exact decision by thread_id when the runtime is ready to continue.

6. Validate a signed approval

FieldRequiredDescription
task_idYesTask ID associated with the approval.
signatureYesRaw one-time approval token returned by an approved decision.
json
{ "valid": true }
json
{
  "valid": false,
  "reason": "invalid"
}

Failure reasons include invalid, expired, and used. Tokens are single-use, expiry-bound, agent/context-bound, and invalidated by agent API-key rotation.

Important HTTP behavior

Token validation failures, including invalid, expired, used, malformed, or missing inputs, are currently represented in the JSON body and can return HTTP 200. Always inspect valid.

Requested changes and revisions

When a reviewer requests changes, polling returns changes_requested. Keep the same review thread and POST a guarded revision event.

json
{
  "event_type": "revision.order-1042.THR-A1B2C3D4",
  "event_summary": "Revised after reviewer feedback",
  "payload": {
    "revision": {
      "revision_id": "rev-002",
      "tool_name": "issue_refund",
      "subject": "Review issue_refund",
      "request_payload": {"amount": 250}
    }
  }
}
Revision fieldRequiredBehavior
revision_idYesMust be unique within the thread.
tool_nameYesUpdated proposed tool.
subjectYesUpdated reviewer-facing proposal subject.
request_payloadYesRevised tool arguments reevaluated by rules.
workflow_name, task_label, preview, risk_level, summaryNoMay update review context. Existing values are retained when omitted.

A revision is accepted only for the same agent, task, and thread while the thread is pending, and only after reviewer change-request feedback newer than the latest proposal. Duplicate, stale, or no-longer-pending revisions return 409. A revision that passes policy remains pending for reviewer confirmation; a revision that evaluates to reject may terminate as rejected.

Decision webhooks

When webhook delivery is configured, Gate POSTs completed human decisions to the configured HTTPS endpoint.

json
{
  "thread_id": "THR-A1B2C3D4",
  "task_id": "order-1042",
  "decision": "approved",
  "message": "Approved",
  "tenant_id": "tenant-uuid",
  "workflow_name": "Customer Support",
  "task_label": "Refund review"
}

Verify the signature

text
X-Guard-Signature: sha256=<hex-hmac>

HMAC-SHA256(webhook_secret, exact_raw_request_body)

Gate attempts delivery immediately, then retries after 1 second and 3 seconds. Any HTTP status below 300 is treated as success. Webhook destinations must use HTTPS; localhost, loopback, common private ranges, link-local destinations, and unsafe redirect targets are rejected.

Identifiers

IdentifierOwnerUse
taskID / task_idYour runtimeGroups events and one or more decision requests. Reuse is supported. Use a stable URL-safe path-segment value.
thread_idGateIdentifies one exact human-review request. Prefer for polling, revisions, and correlation.
revision_idYour runtimeUnique identifier for one submitted revision inside a thread.

There is no live 36-character task-ID contract on this API surface. Avoid path-breaking characters such as /, ?, and #.

Operational limits

AreaCurrent behavior
Agent rate limitEnforced per agent from tenant API settings. Exceeded requests return 429.
Tool resolve body16 KiB maximum. Overflow currently returns 400.
Tool resolve count1 to 100 tool names.
Stored tool input schemaTool ingestion caps configured input schemas at 64 KiB.
Decision listingDefault 25 rows, maximum 100.
ImagesLimited by installation/tenant attachment configuration and available storage quota.
Rule checks / decision threadsPlan entitlements may impose hard caps. Exceeded hard caps can return 402.

HTTP errors

StatusMeaning
400Malformed JSON, missing required input, invalid query values, rule-evaluation input errors, malformed revisions, or oversized /tools/resolve body.
401Missing or invalid Bearer agent API key.
402Applicable hard usage or entitlement cap reached.
403Agent API or polling disabled, subscription guard, or unavailable feature.
404Decision or revision target not found for the requested context.
409Revision no longer pending, reviewer feedback stale/missing, or revision ID duplicated.
413Evidence image or attachment/storage limits exceeded. /tools/resolve overflow is the exception and currently reports 400.
429Per-agent API rate limit exceeded.
500 / 503Unexpected server failure or attachment storage unavailable.

Most Agent API errors are plain HTTP error text rather than a universal JSON envelope. Preserve the response body for diagnostics. The signed approval validation endpoint is the important exception: inspect its JSON valid field even when HTTP is 200.

Safe runtime rule

Fail closed for an unknown decision status. If signed approval proof is required, also fail closed when approved arrives without approval_token. Never execute a governed action merely because an HTTP request succeeded.