Every API here is available over the APIs.io API and to AI agents over MCP.
openapi: 3.2.0
info:
title: VITNA API (Phase 1) Engagement API
version: 1.1.0
description: 'The compliance evidence layer for AI agents. Pre-flight compliance checks agents call before they act (consent, breach reportability, EU AI Act classification, cross-border), and audit-grade, signed records of what they did. Phase 1 surface covers region routing labels (one database region is in use today), DPIA/ROPA generation, Data Subject Rights (scoped: answerable only for events linked to a subject via principal_ref at ingest, from the point linkage begins; earlier events are permanently unattributable and cannot be linked retroactively), consent lifecycle, Sahamati AA integration, breach notification, and INR/Razorpay billing for DPDP-IN owners (switched off pending merchant onboarding). Also includes one-command agent self-provisioning (/api/setup, mints a restricted trial key with no signup), a destructive-action safety pre-flight (/api/preflight/action-check), scoped engagement sessions with signed evidence bundles (/api/engagement/*), and account claim by a person, from the claim link (/claim).'
contact:
name: COSTRINITY
email: dpo@costrinity.xyz
url: https://www.costrinity.xyz/
license:
name: Proprietary
url: https://vitna.costrinity.xyz/terms
servers:
- url: https://vitna.costrinity.xyz
description: Production
- url: https://vigil-staging.vercel.app
description: Staging (preview branch)
tags:
- name: Engagement
paths:
/api/engagement/open:
post:
summary: Open a scoped engagement session; VITNA evaluates every later action against…
description: 'The session belongs to the agent that opened it. The session record stores opened_by_agent_id: the agent whose API key made the request (read from the key, also beside a session cookie), or null when the signed-in owner opened it. From then on only that agent''s key, or the signed-in owner, can act in the session, read it, poll its holds or close it. Only the signed-in owner can start a drill in it on demand (since 2026-11-01).'
tags:
- Engagement
security:
- ApiKey: []
- Bearer: []
- Session: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- scope_policy
properties:
scope_policy:
type: object
properties:
allowed_domains:
type: array
items:
type: string
allowed_actions:
type: array
items:
type: string
description: Non-empty; forbid everything else.
max_writes:
type:
- integer
- 'null'
expires_at:
type:
- string
- 'null'
metadata:
type: object
description: 'Optional. Stored with the session, each secret or regulated identifier the detectors find replaced with "[redacted: <label>]". Each piece of text, list or object in the payload that lies more than 32 levels deep, after the first 1,000 items of a list, or after the first 10,000 pieces of text in the payload is not read by the detectors and is replaced as a whole with "[redacted: beyond scan limit]"; a number, true or false, or null there is kept, unless its key is past the text limit. At most 1,000 such parts in one request, across all its payloads, are replaced where they are; a payload whose parts would go past that is replaced whole instead, with {"value": "[redacted: beyond scan limit]"}. The keys of the objects in the payload are read too, each as a piece of text before its value, and count toward those 10,000. Where a key holds a leaked secret or a regulated identifier, the object it is in is replaced as a whole with "[redacted: <label>]", or, for a key at the top level of the payload, the whole payload with {"value": "[redacted: <label>]"}. A key after the first 10,000 pieces of text is not read, so it and the keys after it in its object, with their values, are replaced together by one entry, "[redacted: beyond scan limit]", whose value is how many entries it replaces, and count as one such part; when the object already has a key of that name before them, that key''s value is replaced by the count. Before 2026-10-06 the detectors read 8 levels deep and the first 100 items of a list, read no keys, and left what lay beyond as sent. At most 4,096 characters as JSON, as sent and as stored; longer is refused with 400.'
webhook_url:
type: string
description: 'Optional https alert URL (SSRF-guarded): a per-session copy. Receives a signed engagement_alert for each deny and hold in this session (in shadow mode, for bait only), in addition to the owner''s alert channel; it never replaces the owner''s channel, which only the signed-in owner sets. When both are the same URL it is posted once. A hold alert names the hold and its deadline and carries no link that can approve or deny it. Under 2,048 characters. Set with an API key it must use https''s default port (443), and the session posts to it in one try, at most 10 alerts a minute per session and 30 a minute across an owner''s key-opened sessions (per server instance); over that the copy is skipped, the owner''s channel still gets the alert, and the action''s alert says session_copy_skipped (since 2026-10-29).'
responses:
'200':
description: '{session_id, status:"open", scope_policy, webhook_configured, opened_at}'
'400':
description: allowed_actions must be non-empty, or bad webhook_url, or webhook_url of 2,048 characters or more, or a webhook_url set with an API key on a port other than 443, or metadata over 4,096 characters as JSON
'401':
description: Forbidden
'402':
description: 'plan_limit_exceeded (active engagements: free 3 / pro 100 / team 500 / enterprise unlimited). An open session counts while it is in use: it opened or had an action checked within idle_minutes (10), or a hold in it is waiting for a person. To the signed-in owner the answer carries active, open and idle_minutes; to an agent''s API key (since 2026-11-01) only the plan, the limit and idle_minutes, since the account''s counts tell one agent how busy the others are.'
operationId: postApiEngagementOpen
x-operation-id-source: derived
/api/engagement/action:
post:
summary: 'Per-action decision loop: evaluate one action against the session policy +…'
description: 'Bound to the agent that opened the session: With an API key (x-vitna-key, x-vigil-key, x-api-key or Authorization: Bearer, a restricted trial key included, even beside a session cookie) it works only in a session that key''s own agent opened. Any other session of the owner (another agent''s, one the signed-in owner opened, or one opened before 2026-10-05, which records no agent) answers a key exactly as an unknown session id does (404 session_not_found, after the same validation and metering), so the id is not confirmed, and nothing is recorded in that session. The signed-in owner acts in any session.'
tags:
- Engagement
security:
- ApiKey: []
- Bearer: []
- Session: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- session_id
- type
properties:
session_id:
type: string
format: uuid
type:
type: string
description: Whitespace-free action identifier, e.g. dns.write.
target:
type:
- string
- 'null'
description: 'Text or null: a target sent as any other JSON value is refused with 400. Before 2026-10-06 it was ignored and not checked.'
payload:
description: 'Optional. The call''s arguments, a JSON object. A payload that is not a JSON object (text, a number, true or false, or an array) is kept whole as {"value": <the payload as sent>} and checked like any other field. A held call''s argument excerpt shows it that way. Before 2026-10-05 text, a number or true or false was not checked, and an array was checked one key per index. Each piece of text, list or object in the payload that lies more than 32 levels deep, after the first 1,000 items of a list, or after the first 10,000 pieces of text in the payload is not read by the detectors and is replaced as a whole with "[redacted: beyond scan limit]"; a number, true or false, or null there is kept, unless its key is past the text limit. At most 1,000 such parts in one request, across all its payloads, are replaced where they are; a payload whose parts would go past that is replaced whole instead, with {"value": "[redacted: beyond scan limit]"}. The keys of the objects in the payload are read too, each as a piece of text before its value, and count toward those 10,000. Where a key holds a leaked secret or a regulated identifier, the object it is in is replaced as a whole with "[redacted: <label>]", or, for a key at the top level of the payload, the whole payload with {"value": "[redacted: <label>]"}. A key after the first 10,000 pieces of text is not read, so it and the keys after it in its object, with their values, are replaced together by one entry, "[redacted: beyond scan limit]", whose value is how many entries it replaces, and count as one such part; when the object already has a key of that name before them, that key''s value is replaced by the count. Before 2026-10-06 the detectors read 8 levels deep and the first 100 items of a list, read no keys, and left what lay beyond as sent. A call with such a part is not allowed: it counts as one threat of category scan_limit, label "beyond scan limit", at severity high, once per call however many parts were replaced (in the engagement action, in the payload, the context or both), and the echo shows the marker in their place. Before 2026-10-06 such a part was not counted, so a call whose only risky text lay beyond the limits was allowed; earlier on 2026-10-06 the engagement action counted it once for the payload and once more for the context. In scope, such a call is held for a person. Its reason is "threat_flag: " and the categories of its flags in the order found, joined by ", ", with scan_limit named once, so with no other flag it reads "threat_flag: scan_limit" (an action type listed in hold_actions gives "hold_action: <type>" instead). A match in a key counts like a match in a value, and the echo shows the object that key is in replaced when it holds a secret. Before 2026-10-06 keys were not read, so a secret or a dangerous command sent as a key was allowed and echoed as sent. The context is read the same way.'
context:
description: 'Optional. Any JSON value, read the way payload is and checked apart from it, as are type and target, so a key in one cannot hide a value in another. A context that is not a JSON object is kept whole as {"value": <the context as sent>}. When a key is in two of these parts, redacted_action and a held call''s argument excerpt keep each part whole under its own name; a part replaced whole is {"value": <the marker>} there, so its value key counts. Before 2026-10-06 the parts were merged before the check, so a context key hid a payload value of the same name, and a context sent as text was not checked.'
_meta:
type: object
description: Optional W3C trace context (traceparent / tracestate).
responses:
'200':
description: '{decision:"allow"|"deny"|"hold", reason, threat_flags[], vigil_decision{...signature...}, alert, enforced_by:"caller"}. On deny or hold, alert is {dispatched:true, channels:["owner","session"]} naming which webhooks were posted to (the owner''s alert channel and the session''s webhook_url; never their addresses), or {dispatched:false, reason:"no_webhook_configured"}. In a session opened with an API key the session''s copy can be skipped, and alert then carries session_copy_skipped: "paced" (over 10 a minute for the session or 30 for the owner) or "port" (not https''s default port); with no owner channel either, alert is {dispatched:false, reason:"session_copy_skipped", session_copy_skipped}. The pace is counted on each server instance, and a session URL that is the owner''s channel is posted once, as the owner''s, and not counted. A hold''s routed_to records owner:webhook and session:webhook for exactly those. Restricted key: vigil_decision unsigned + trial:true. In an account switched to shadow mode (PUT /api/owners/enforcement) a deny or hold is answered decision "allow" with shadow {would_have: "deny"|"hold"}, alert {dispatched:false, reason:"shadow_mode"} and no hold; vigil_decision keeps the real verdict, and its reason, like the top-level one, begins "shadow, not enforced: ". A burst still raises the rate alert, rate_alert {fired, count, shadow: true}, counting only the calls VITNA would have held or blocked but answered allow, and posts it to the owner''s alert webhook, where one is set, as a shadow_rate_alert event. Bait is denied in either mode.'
'400':
description: session_id and type required; type must be whitespace-free; target, when sent, must be text or null
'401':
description: Forbidden
'404':
description: 'session_not_found: no such session on the account, or an API key asked about a session its own agent did not open'
'409':
description: 'session_closed: the session is closed and takes no new actions. {error, session_id, closed_at}. Nothing is recorded or metered.'
'429':
description: Restricted-key caps
'503':
description: audit_record_write_failed (fail-closed)
operationId: postApiEngagementAction
x-operation-id-source: derived
/api/engagement/close:
post:
summary: Close a session and emit a signed, offline-verifiable Ed25519 evidence bundle…
description: 'Bound to the agent that opened the session: With an API key (x-vitna-key, x-vigil-key, x-api-key or Authorization: Bearer, a restricted trial key included, even beside a session cookie) it works only in a session that key''s own agent opened. Any other session of the owner (another agent''s, one the signed-in owner opened, or one opened before 2026-10-05, which records no agent) answers a key 404 session_not_found, as an unknown id does, and nothing is signed or written. The signed-in owner closes any session.'
tags:
- Engagement
security:
- ApiKey: []
- Bearer: []
- Session: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- session_id
properties:
session_id:
type: string
format: uuid
responses:
'200':
description: '{evidence_package, package_signature (Ed25519), verification{...}}. The close ends every hold still waiting, as expired (decided_by system:session_closed), so the bundle carries each hold with an outcome. When the session has denies or holds recorded in shadow mode, summary.shadow {decisions, note} says how many were not enforced; otherwise it is absent. A close of a session already closed (since 2026-10-30) answers with the bundle its close issued, unchanged (same generated_at, same signature), plus reissued: true and a note, and writes nothing.'
'401':
description: Forbidden
'403':
description: restricted_key_forbidden (signed evidence is a claimed-account capability)
'404':
description: 'session_not_found: no such session on the account, or an API key asked about a session its own agent did not open'
'409':
description: 'session_closed: the session was already closed and its bundle cannot be given again. {error, session_id, closed_at}. A session closes once and has one bundle: since 2026-10-30 a second close, or one that raced the first, records no second close and answers 200 with that same bundle, unchanged (same generated_at, same signature) and reissued: true. It answers 409 instead when the session was closed before then, when the bundle rebuilt from its records no longer matches the hash its close recorded, or when the key it was signed or checked with has been replaced. Never a second, different bundle. Any hold of a closed session read later ends as the close ends one.'
'429':
description: 'reissue_paced: the session is closed and its bundle was asked for again twice in the last minute, or ten times by the same caller (an agent''s key, or the signed-in owner), counted on each server instance, failed asks included. {error, session_id, closed_at, retry_after_seconds}; Retry-After says when to ask again.'
'503':
description: 'close_write_failed: the close, or the outcome of one of its waiting holds, could not be recorded, or its trace context could not be read, so no bundle was issued and the session is still open. Retry. bundle_read_failed: the session is closed, but its bundle could not be read or checked again just now. bundle_sign_unavailable: the session is closed, but its bundle cannot be signed again just now. Retry either to get it.'
operationId: postApiEngagementClose
x-operation-id-source: derived
/api/engagement/hold:
get:
summary: Status of one hold (pending, approved, denied, expired).
description: 'Bound to the agent that opened the hold''s session: With an API key (x-vitna-key, x-vigil-key, x-api-key or Authorization: Bearer, a restricted trial key included, even beside a session cookie) only the holds of sessions that key''s own agent opened can be read. Any other hold of the owner answers a key 404 hold_not_found, as an unknown id does, before the read could record an expiry. The signed-in owner reads any hold.'
tags:
- Engagement
security:
- ApiKey: []
- Bearer: []
- Session: []
parameters:
- name: hold_id
in: query
required: true
schema:
type: string
format: uuid
responses:
'200':
description: '{hold_id, session_id, status, deadline, decided_at, decided_by?, drill?}; decided_by and drill once the hold has an outcome'
'401':
description: Forbidden
'404':
description: hold_not_found
operationId: getApiEngagementHold
x-operation-id-source: derived
/api/engagement/hold/decide:
get:
summary: Confirmation page for a signed decision link. A GET never decides.
tags:
- Engagement
parameters:
- name: hold_id
in: query
required: true
schema:
type: string
format: uuid
- name: token
in: query
required: true
schema:
type: string
responses:
'200':
description: HTML page with approve and deny
'404':
description: invalid link
operationId: getApiEngagementHoldDecide
x-operation-id-source: derived
post:
summary: Approve or deny a hold.
tags:
- Engagement
security:
- Session: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- hold_id
- outcome
properties:
hold_id:
type: string
format: uuid
outcome:
type: string
enum:
- approve
- deny
token:
type: string
responses:
'200':
description: '{hold_id, status, decided_by, decided_at, deadline, drill}; after the deadline, or once the hold''s session has closed, the status is expired and the decision is not recorded'
'403':
description: agent_keys_cannot_resolve_holds, or forbidden
'404':
description: hold_not_found
operationId: postApiEngagementHoldDecide
x-operation-id-source: derived
/api/engagement/hold/pending:
get:
summary: The signed-in owner's holds waiting for a decision (no outcome, deadline not…
tags:
- Engagement
security:
- Session: []
responses:
'200':
description: '{now, holds: [{hold_id, session_id, action, action_detail, reason, held_at, deadline}]}'
'401':
description: session_required
'403':
description: agent_keys_cannot_list_holds
operationId: getApiEngagementHoldPending
x-operation-id-source: derived
/api/engagement/hold/canary:
post:
summary: Open a canary (drill) hold through the same path as a real one; labelled a…
description: 'Signed-in owner only (since 2026-11-01). With an API key (x-vitna-key, x-vigil-key, x-api-key or Authorization: Bearer, a restricted trial key included, even beside a session cookie) it is refused 403 session_required before anything is read: a drill alerts like a real hold (the owner''s hold email once hold email can go, the owner''s alert webhook, the dashboard), so a key that could start drills could fill its owner''s inbox and webhook with them. A drill stands in for a realistic risky call, one of the session''s own hold_actions when its policy has any. The signed-in owner can start one in any session of the account; another owner''s session is 404 session_not_found. The drills a session''s policy schedules (canary_interval_minutes) are bounded for the account: at most one in each quarter hour of the clock across all its sessions, a session''s first one interval or more after it opened, none in shadow mode.'
tags:
- Engagement
security:
- Session: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- session_id
properties:
session_id:
type: string
format: uuid
responses:
'200':
description: '{hold_id, status: pending, deadline, notified}'
'401':
description: 'Unauthorized: no signed-in session, or owner_id names another account'
'403':
description: 'session_required: the request carried an API key'
'404':
description: session_not_found
'409':
description: 'session_closed: the session is closed and takes no new drills. {error, session_id, closed_at, note}. Nothing is recorded.'
'503':
description: hold_write_failed
operationId: postApiEngagementHoldCanary
x-operation-id-source: derived
/api/engagement/list:
get:
summary: List the owner's engagements with state, scope, decision counts, and plan…
description: 'Each engagement carries opened_by_agent_id (null when none is recorded). With an API key (x-vitna-key, x-vigil-key, x-api-key or Authorization: Bearer, a restricted trial key included, even beside a session cookie) only the sessions that key''s own agent opened are listed, and count is theirs; since 2026-11-01 its metering is {plan, created_total of its own sessions, active_limit}. To the signed-in owner metering counts the whole account, because the plan''s cap does: metering.active is the open sessions in use that count against active_limit (opened or acted in within idle_minutes, or holding a waiting hold), metering.open is every open session. The signed-in owner sees every session.'
tags:
- Engagement
security:
- ApiKey: []
- Bearer: []
- Session: []
parameters:
- name: owner_id
in: query
schema:
type: string
format: uuid
responses:
'200':
description: '{count, metering, engagements[]}'
'401':
description: Forbidden
operationId: getApiEngagementList
x-operation-id-source: derived
/api/engagement/get:
get:
summary: One engagement's full status + itemized decisions (owner-scoped)
description: 'Bound to the agent that opened the session: With an API key (x-vitna-key, x-vigil-key, x-api-key or Authorization: Bearer, a restricted trial key included, even beside a session cookie) it works only in a session that key''s own agent opened. Any other session of the owner (another agent''s, one the signed-in owner opened, or one opened before 2026-10-05, which records no agent) answers a key 404 session_not_found, as an unknown id does. The signed-in owner reads any session. opened_by_agent_id names the opening agent, or is null when none is recorded.'
tags:
- Engagement
security:
- ApiKey: []
- Bearer: []
- Session: []
parameters:
- name: session_id
in: query
required: true
schema:
type: string
format: uuid
- name: owner_id
in: query
schema:
type: string
format: uuid
responses:
'200':
description: EngagementDetail
'400':
description: session_id required
'401':
description: Forbidden
'404':
description: session_not_found
operationId: getApiEngagementGet
x-operation-id-source: derived
components:
securitySchemes:
ApiKey:
type: apiKey
in: header
name: x-vigil-key
description: 'Per-agent API key. Format: vitna_<64-char-hex>; legacy vigil_ keys remain valid. Send on /api/ingest.'
Bearer:
type: http
scheme: bearer
bearerFormat: vitna_<key> (legacy vigil_<key> accepted)
description: 'Same key as x-vigil-key, sent as `Authorization: Bearer <key>`.'
Session:
type: apiKey
in: cookie
name: vigil_session
description: 'Operator dashboard session cookie. Set by a sign-in: the second step of a password sign-in (/api/auth/verify-pin), or, for an address whose mail Google handles (Gmail or a Google Workspace domain) while VITNA''s mail cannot reach Gmail, the password alone (/api/owners); GitHub; a passkey; or a claim.'
CronSecret:
type: http
scheme: bearer
description: Bearer ${CRON_SECRET}. Only the Vercel cron infrastructure should hold this.