Skip to content

Agent API

These routes are served on Sefra’s agent listener and behave exactly like the MCP tools. For a walkthrough, see Connect over REST.

Download the OpenAPI specification to generate a client or import it into your API tools.

Send an OAuth access token issued for the agent listener’s audience as Authorization: Bearer <token>.

Submit a single intent or a plan

A body with intent is a single intent, the MCP tool input of that intent with the intent type named beside it. A body with steps is a plan, the input of sefra-submit_plan. Only this route takes a rate-limit token.

Parameters

Name In Type Required Description
Idempotency-Key header string No The client’s key, 16 to 128 characters of [A-Za-z0-9_-], required when any step changes state. Sent as a structured-field string ("…") or bare. May be sent in the body as idempotency_key instead, or in both if equal. A read intent takes no key.

Request body

Content type application/json, schema SingleIntentSubmission or PlanSubmission.

Responses

Status Description Body
200 Replay. The key is bound to an execution with the same payload; its current envelope, replayed true. Envelope
201 Accepted, and the execution reached a final status within the synchronous wait. Envelope
202 Accepted, and the execution is not final yet (executing, compensating, pending_approval, needs_intervention). Poll its Location after poll_after_s. Envelope
400 IDEMPOTENCY_KEY_MISSING, or a malformed request without a code: not a JSON object, both or neither of intent and steps, intent not a string, the key header twice, or header and body keys that differ. Problem (application/problem+json)
401 No bearer token, or one that is not valid. No code. Problem (application/problem+json)
403 POLICY_DENIED, POLICY_ERROR or PRINCIPAL_SUSPENDED. Problem (application/problem+json)
413 The body is larger than 2 MiB. No code, no execution. Problem (application/problem+json)
422 SCHEMA_VIOLATION, PLAN_INVALID, UNKNOWN_INTENT or IDEMPOTENCY_KEY_REUSED. Problem (application/problem+json)
429 RATE_LIMITED. Retry after Retry-After seconds, equal to envelope.error.retry_after_s; the key is still free. Problem (application/problem+json)
500 Sefra could not process the request; nothing was accepted. No code. Problem (application/problem+json)
503 PAUSED, INTENT_DISABLED, FACT_UNAVAILABLE or LICENSE_EXPIRED, retryable later; or, without a code, no active bundle or the identity provider unavailable (then with Retry-After). Problem (application/problem+json)

Read one of your executions

Parameters

Name In Type Required Description
id path string Yes

Responses

Status Description Body
200 The current envelope, whatever the status. Envelope
401 No bearer token, or one that is not valid. No code. Problem (application/problem+json)
404 UNKNOWN_EXECUTION: no such execution, or another principal’s. The envelope is the reduced one. Problem (application/problem+json)
500 Sefra could not process the request; nothing was accepted. No code. Problem (application/problem+json)
503 The identity provider is unavailable. No code; Retry-After set. Problem (application/problem+json)

Cancel one of your executions while it is pending approval

Parameters

Name In Type Required Description
id path string Yes

Responses

Status Description Body
200 Cancelled. The envelope, rejected with CANCELLED. Envelope
401 No bearer token, or one that is not valid. No code. Problem (application/problem+json)
404 UNKNOWN_EXECUTION: no such execution, or another principal’s. The envelope is the reduced one. Problem (application/problem+json)
409 NOT_CANCELLABLE: the execution is not pending_approval. Problem (application/problem+json)
500 Sefra could not process the request; nothing was accepted. No code. Problem (application/problem+json)
503 The identity provider is unavailable. No code; Retry-After set. Problem (application/problem+json)
Field Type Required Description
approval object No
error object No
execution_id string or null Yes
poll_after_s integer No Minimum: 0.
replayed boolean No
status any No One of pending_approval, executing, compensating, succeeded, rejected, failed, rolled_back, needs_intervention, resolved_manually.
steps array of object No

Type: string. Pattern: ^[A-Za-z0-9_-]{16,128}$.

Field Type Required Description
idempotency_key IdempotencyKey No Pattern: ^[A-Za-z0-9_-]{16,128}$.
rationale Rationale No Optional, agent-supplied and unverified. Shown to approvers; never influences a decision. At most, in characters: 2000.
steps array of object Yes At most, in items: 16.
Field Type Required Description
code string No The error code. Absent for a malformed request, 401, 413, 500 and 503 without an operation refused.
detail string No The refusal’s fixed message, or what was malformed.
envelope Envelope No
status integer Yes
title string Yes The HTTP status phrase.
type string Yes

Optional, agent-supplied and unverified. Shown to approvers; never influences a decision.

Type: string. At most, in characters: 2000.

Field Type Required Description
idempotency_key IdempotencyKey No Pattern: ^[A-Za-z0-9_-]{16,128}$.
input object Yes The intent’s input, as its JSON Schema in the bundle says (the input of its MCP tool).
intent string Yes An intent type granted to the caller, for example procurement.create_purchase_order.
rationale Rationale No Optional, agent-supplied and unverified. Shown to approvers; never influences a decision. At most, in characters: 2000.