Start free

API documentation

Base URL https://api.sovereign-shield.net. Everything below is the complete, current surface; new here? The setup guide walks it in order.

Authentication

Three credentials, three jobs. Never confuse them:

CredentialSent asWhat it does
API key (ss_...)Authorization: BearerAuthenticates requests, spends credits. Created at signup in the dashboard; inactive until your email is confirmed. Rotating it keeps your credits.
Management token (ssm_...)X-Manage-KeyEdits policy and acts on approvals. Minted in the dashboard, shown once. The API key can never do these things, so a hijacked agent cannot loosen its own guard.
Provider keyAuthorization / x-api-key (gateway only)Your OpenAI/Anthropic/Gemini key, forwarded untouched to your provider. We never store it.

Missing or unknown key: 401. Valid but inactive key (email not confirmed): 403 with a message saying exactly that.

Credits & billing

1 credit scans up to 1,000 characters, rounded up, minimum 1 per request; a 20,000-character document bills 20. Every response reports billed and carries an X-Credits-Remaining header. Credits never expire; packs are one-time purchases from the dashboard.

ModeCostWhat runs
"fast"0 credits, alwaysDeterministic rules only. The free tier; unlimited within rate limits.
"auto" (default)per 1,000 charsDeterministic first; anything not clearly decided escalates to the 3-model consensus. Out of credits? auto degrades to the free deterministic verdict with billed: 0 and a note, never a surprise 402.
"consensus"per 1,000 charsPanel required; returns 402 when out of credits.
Gateway calls bill a flat 1 credit and are refunded automatically if the upstream provider fails, returns garbage, or the input is blocked before forwarding.

Errors

StatusMeaning
400Malformed request: missing text/action, invalid JSON, or a policy that fails validation (the response lists every problem).
401Missing or unknown credential.
402Not enough credits (explicit consensus mode, gateway, or guard). Response includes required and current credits.
403Valid key, not yet activated (confirm your email), or wrong password on account actions.
404Unknown route, or an approval token that is not pending on your key.
409/guard/check with no policy configured; set one first.
429Auth endpoints rate limit: 8 attempts per 10 minutes per IP.
502Gateway upstream failed; the credit is refunded.
Fail-closed is a guarantee, not a mood: if the verifier itself errors, times out, or the panel disagrees, the input or action is refused. Build retries assuming a block means no.
POST/scan

Scan text for prompt injection, jailbreaks, and agent manipulation before your model reads it.

Request body

FieldTypeDescription
text requiredstringThe text to scan. Inputs over 8,000 characters are scanned in overlapping chunks and combined fail-closed (any chunk blocking blocks the whole input).
modestring"auto" (default) · "fast" (deterministic only, free) · "consensus" (panel required).
sourcestring"user" (default) or "untrusted" for content your agent ingested: web pages, emails, documents, tool output. Untrusted mode flags any embedded attempt to steer the AI.

Response

{ "allowed": false, "verdict": "block", "score": 100,
  "reason": "Blocked an attempt to extract the system's own prompt.",
  "rule": "system_prompt_extraction", "chunks": 1, "billed": 1 }
FieldDescription
allowedThe only field you must act on.
score0-100 suspicion score from the deterministic tier.
rulePresent when a named rule produced the block: which rule it was.
chunks / billedHow the input was split and what it cost. chunk_results lists per-chunk verdicts when split.
llm_validated / escalatedWhether the consensus panel confirmed the verdict.
POST/verify-action

Judge one OS-level action before executing it. Deterministic, milliseconds, 1 credit.

Request body

FieldTypeDescription
action_type requiredstringOne of: ANSWER, BROWSE, CAT, DELETE_FILE, GET_CONTENT, READ_FILE, REPLY, SAY, SHELL_EXEC, THINK, TYPE, WRITE_FILE. Unknown types still get the always-on malicious-payload scan.
payloadstringThe action's argument (the command, the path, the text).
invoker_rolestringWho asked; recorded in the decision.

Response

{ "allowed": false, "verdict": "block",
  "reason": "Shell execution is permanently disabled.", "billed": 1 }
SHELL_EXEC and DELETE_FILE are permanently disabled at the engine level; privileged account operations (unlock, MFA disable, admin grant) are hard-blocked no matter how the payload is worded.
POST/check-output

Validate a model's proposed output against your ground-truth state using preset rules. Catches the confident answer that contradicts the data it claims to come from. 1 credit.

Request body

FieldTypeDescription
proposal requiredobjectThe model's proposed output.
stateobjectYour ground truth to validate against.
rules requiredarrayPreset rules only (range, type, one_of, regex, anti-pattern detectors, ...). Arbitrary code is refused. Discover the catalogue at GET /check-output/rules.

Example

curl -X POST https://api.sovereign-shield.net/check-output \
  -H "Authorization: Bearer ss_YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"proposal": {"refund": 9500}, "state": {"order_total": 120},
       "rules": [{"rule": "range", "args": ["refund"], "kwargs": {"min_val": 0, "max_val": 120}}]}'

{ "valid": false, "errors": [...], "feedback_vector": "..." }  # feed it into the next prompt
POST/guard/check

Evaluate a named tool call against your server-side policy: the same judgment the gateway applies automatically, exposed as a call for agents you wire yourself. Bills 1 credit plus 1 per string parameter scanned.

Request body

FieldTypeDescription
action requiredstringThe tool name, e.g. "transfer_funds".
paramsobjectThe call's parameters; conditions and injection scanning run against them.
approval_tokenstringRedeem a granted approval (single-use, bound to the exact action + params).

Decision order

deny list → default-deny allowlist → parameter conditions (max/min/allowlist/denylist; a missing, non-numeric, or non-finite value is a violation) → CoreSafety primitives → parameter injection scan → approval gate → allow.

Response verdicts

"verdict": "allow" | "block" | "needs_approval"   # needs_approval includes approval_token
No policy configured returns 409. Set one first; new dashboard accounts start on {"default": "deny"}.
POST/v1/chat/completions
POST/v1/messages POST/v1beta/models/{model}:generateContent

The enforcing gateway. Point your SDK's base URL at us; requests are scanned on the way in (tool results treated as untrusted, plus a whole-conversation split-payload check), forwarded to your provider, and tool calls your policy denies are removed from the response before your framework can dispatch them. Streaming is real: text streams live; tool-call deltas are held, judged complete, and re-emitted only if allowed.

Headers

HeaderDescription
X-Shield-Key requiredYour SovereignShield API key. Bills 1 credit per call.
Authorization / x-api-key / x-goog-api-keyYour provider's own auth, forwarded untouched (Anthropic also forwards anthropic-version).
X-Shield-UpstreamOverride the upstream base URL. Defaults: OpenRouter / api.anthropic.com / generativelanguage.googleapis.com.

What comes back

# a denied tool call is gone from choices[].message.tool_calls, and:
"shield": { "allowed": ["get_weather"],
  "blocked": [{ "name": "transfer_funds", "reason": "denied: ..." }] }

# an input blocked before forwarding returns a refusal completion with
# finish_reason "content_filter" and shield.input_blocked; the credit is refunded.
Actions marked needs_approval are denied at the gateway (a proxy cannot pause mid-response for a human); route those through /guard/check.
GETPUTPATCH/policy

Read, replace, or granularly edit your key's policy. Auth: X-Manage-Key, or your dashboard session. Every write is validated first; a malformed policy is rejected with the full list of problems.

Policy shape

{ "default": "deny",                       # deny = allowlist mode (recommended)
  "allow": ["get_weather"],
  "deny": ["drop_database"],
  "require_approval": ["send_email"],
  "conditions": { "transfer_funds": [{ "param": "amount", "max": 1000 },
                                     { "param": "to", "allowlist": ["acct_A"] }] },
  "scan_params": { "*": true },            # injection-scan string params
  "primitive": { "run_shell": "SHELL_EXEC" } # map to hard OS-level blocks }

PATCH ops

{"op": "allow" | "deny" | "require_approval" | "unallow" | "undeny" |
       "unrequire_approval", "action": "name"}
{"op": "add_condition", "action": "name", "condition": {...}}
{"op": "clear_conditions", "action": "name"}
{"op": "set_default", "value": "allow" | "deny"}
GET/approvals POST/approvals/{token}/approve POST/approvals/{token}/deny

Your key's needs-approval queue. Auth: X-Manage-Key or dashboard session; strictly scoped to your own key (another key's tokens are invisible and unactionable). GET accepts ?status=pending|approved|denied|used. An approved token is redeemable via /guard/check exactly once.

POST/auth/manage-token

Mint (or rotate) your management token. Auth: dashboard session; requires a verified account. Shown once; the previous token stops working immediately. The dashboard's "Generate management token" button calls exactly this.

Command line client

Everything on this page is available as a zero-dependency CLI. Install it, log in once, and the endpoints become commands.

pip install sovereignshield
ss login --api-key ss_... --manage-token ssm_...
CommandDoes
ss statusaccount, credits, and the current policy at a glance
ss scan "text"scan input; also -f file, stdin piping, --source untrusted
ss verify SHELL_EXEC "..."judge an action before it runs
ss check tool --param k=vevaluate a tool call against your policy
ss allow / deny / ask NAMEadd an exception (and un-prefixed forms to remove one)
ss limit tool param --max Nbound a parameter; --min, --in a,b, --not-in c
ss default deny | allowset the posture
ss approvals / approve / rejectwork the approval queue
Exit codes make it scriptable: 0 allowed, 2 blocked, 1 error. So ss scan "$INPUT" || handle_block just works in a shell script or CI job.

Credentials live in ~/.sovereignshield/config.json (owner-read only), and the environment variables SOVEREIGNSHIELD_API_KEY / SOVEREIGNSHIELD_MANAGE_TOKEN override it for CI.

GET/billing/packs GET/billing/checkout?credits=N

/billing/packs is public and lists sizes, prices, and per-credit rates. /billing/checkout (session or Bearer key) 303-redirects to Stripe checkout for that pack; the webhook credits your key the moment payment confirms, idempotently.

GET/health

Unauthenticated liveness check; also reports whether the consensus panel is configured.

{ "status": "ok", "consensus_configured": true }

Read enough?

100 free credits, no card. The setup guide takes you from zero to fail-closed in ten minutes.

Start free →