Skip to main content

Consent API

Requires the admin bearer, or, from 0.4.0, the consent token (AGENTIC_AUTH_CONSENT_TOKEN): a credential that may call this endpoint and nothing else. Give a connector proxy or gateway the consent token, never the admin token.

POST /v1/consent​

The human act that roots a session's authority. Pins one immutable policy version for the whole session's lifetime.

Request body (ConsentCreate):

{
"scope": "kb-search-agent",
"user_sub": "user:alice",
"ttl_seconds": 1800
}

scope: 1–255 chars. user_sub: 1–255 chars. ttl_seconds: optional, 60–86400 (default set by server config).

With AGENTIC_AUTH_VERIFIED_CONSENT_ENABLED=true, the consenting human comes from the user's IdP token, which the control plane verifies itself against the principal IdP:

{
"scope": "kb-search-agent",
"subject_token": "<the user's access token or ID token from your IdP>",
"subject_token_type": "urn:ietf:params:oauth:token-type:access_token"
}
  • subject_token is required, and an asserted user_sub alone is refused.
  • user_sub is optional. If given, it must equal the verified iss#sub.
  • The token's audience must be one of AGENTIC_AUTH_CONSENT_IDP_AUDIENCES.
  • subject_token_type is …:access_token (the default) or …:id_token.
  • With client mapping on (AGENTIC_AUTH_CLIENT_MAPPING_ENABLED), scope may be omitted: it is the scope of the agent the token's client (azp) maps to. If given, it must match.

The token is never stored, only its SHA-256. With verified consent off, sending a subject_token is refused rather than ignored, so a caller can never believe a session was verified when it was not.

Response — 201 (ConsentRead):

{
"session_id": "...",
"root_grant": "<JWT — the hop-1 token>",
"policy_version": 1,
"scope": "kb-search-agent",
"user_sub": "user:alice",
"hop_budget": 4,
"expires_at": "2026-09-22T13:00:00Z"
}

With verified consent, user_sub is the verified issuer#subject, and the response adds "principal_source": "verified" and, when a client mapping chose the scope, "client_id". Both are omitted otherwise, so the 0.3.0 response shape is unchanged.

Errors:

StatusMeaning
401subject_token_invalid: the token failed verification. details.check names the rule: signature, issuer, audience, expired, not_yet_valid, algorithm or malformed
403client_not_authorized: the token's client is not mapped to an agent, or its agent has no pinned manifest. details.next is cold_start; with sandboxing on and a mapped client, details.sandbox names the agent's sandbox route
404Unknown scope — no compiled policy exists
409policy_recompile_required — the compiled policy predates a required schema version; resubmit the manifest to recompile
422subject_token_required (verified consent is on and no token was sent), subject_mismatch (an asserted user_sub disagrees; it is not echoed back), or a validation error
503idp_unavailable: the IdP's keys could not be fetched. Retryable, never an allow

A refusal before a session exists has no audit row. It is counted in agentic_auth_consent_refusals_total{reason} and logged with a token fingerprint.