Skip to main content
The BotShield API is a small set of JSON operations over HTTPS. Your server calls it to confirm BotShield Gate results, and your agent calls it to ask a human to confirm an action. Two things differ from a typical REST API, and both matter on day one: every operation answers HTTP 200 even when it fails, and the result is wrapped in a data envelope. Read the response envelope before you write a client.

Base URL

Every path on this page is relative to the base URL, so POST /sdk/create-session is POST https://api.botshield.ai/operations/sdk/create-session. Send and accept application/json. GET operations take their input as query parameters. Development and Production share the base URL. The credential you send selects the environment, and a gate is looked up in the environment of the key that calls it: bs_dev_… and pk_test_… keys reach Development gates, and bs_production_… and pk_live_… keys reach Production gates. The same gate key (scope) can exist in both environments, as two separate gates. A key whose environment has no Active gate with that gate key gets an error.

Credentials

Send the credential as a bearer token: Authorization: Bearer <credential>. See Keys and environments for how to create, rotate, and revoke keys.

Which operation takes which credential

POST /sdk/create-verification-link does not accept an API key or a site key. It accepts only the grant token from create-session, and the token is consumed by the call. Create a new session for each verification request.

The response envelope

Every operation answers HTTP 200 with a JSON object that has a top-level data property.
  • Success. Most operations nest the result once more, so you read data.data. Two operations return the result directly under data: GET /verification/status and POST /sdk/logout.
  • Failure. An operation that rejects your request still answers HTTP 200. The error is at data.error, and data.error.statusCode holds the status the error stands for (401, 403, 404, 409, and so on).
Always check data.error before you read the result.
Only three cases use a real non-200 status: HTTP 400 when the request body fails input validation, HTTP 403 with RATE_LIMITED when you exceed a rate limit, and HTTP 500 for an unhandled failure. Errors covers each shape and includes a helper that handles all of them.

Worked example

(census is the SDK’s name for BotShield Gate.) For the two operations that are not double-nested, read the fields from data itself:
status is one of pending, completed, pass, expired, failed, not_found, or error. Two values mean the human is verified: completed (the human confirmed on their phone) and pass (a Recent Presence pass, where the widget reports success with token: null). A pass record reads expired 60 seconds after the check, so call this operation as soon as the widget reports success. Never test for completed alone.

Operations

BotShield Gate

  • POST /sdk/create-session: open a five-minute, single-use grant and get a bss_… grant token.
  • POST /sdk/create-verification-link: create a verification request for a gate and get its request_id, its links, and its expires_at. expires_at is the request’s own expiry, five minutes after creation, and is the same instant GET /verification/status reports for that request.
  • GET /verification/status: read the current status of a verification request.
  • POST /sdk/verify-token: validate an attestation token and read its claims. The operation is open and the token is not bound to an audience, so compare claims.organization_id with your own organization ID and claims.request_id with the request you started. Copy your Organization ID from the Console under Settings → Developer Tools → API Keys. The create-session response also returns it as organization.id.
  • POST /sdk/revoke-verification: end the pending requests one user has for a gate, so a new one can be created. Returns revoked_count.
  • POST /sdk/logout: revoke an unused grant token.

Agents Ask

  • POST /agent/bind-session: start linking a human to your agent and get a link code.
  • GET /agent/check-binding: check whether the human claimed the code, and receive their opaque_id.
  • POST /agentlink/inquire: propose an action for the human to Confirm or Deny.
  • GET /agentlink/check-status: read the outcome of a proposal. Supports a long-poll of up to 25 seconds.
  • POST /agentlink/cancel: withdraw a proposal that is still waiting.

Verify signatures locally

BotShield signs attestation tokens and Proofs of Resolution with ES256. The public keys are published as a standard JWKS:
This URL is served as plain JSON, outside the data envelope, with Cache-Control: public, max-age=300. Cache it for five minutes and select the key by the kid in the token header. If the key set cannot be built, the URL answers HTTP 503 with {"keys": [], "error": "jwks_unavailable"}. Keep using your cached copy and retry. Tokens are issued with iss set to https://api.botshield.ai. See Verify on your server for attestation tokens and Proof of Resolution for Agents Ask.

Next steps

Errors

Every error shape, status code, and a typed unwrap helper.

Rate limits

Limits by key type and how to back off.

TypeScript SDK

Call the API with typed methods.

Keys and environments

Create and manage the credentials on this page.