API

Retries & batch processing

Retry safely, avoid duplicate decisions, and handle partial batch failures.

On this page

Idempotency receipts

Supply a stable idempotency_key for the same logical verification. Receipts last 24 hours. Concurrent attempts are coordinated, and the completed receipt, recorded event, and monthly usage increment are committed together. An identical completed retry returns the existing decision without another event or quota charge.

Browser transport IP/user-agent observations are excluded from the request digest; authoritative server context IP/user-agent values are included. A scoring receipt does not make your order fulfillment idempotent. Protect fulfillment independently with your order or payment identifier.

Handle every batch item

typescript
const result = await bastion.batch(requests);
for (const item of result.results) {
  if (!item.success) {
    console.error('Verification failed', item.index, item.status, item.message);
    continue; // Do not approve this item.
  }
  const decision = item.decision!;
  console.log(item.index, decision.request_id, decision.action);
}
json
{
  "success": true,
  "data": {
    "accepted": 1,
    "results": [
      {
        "index": 0,
        "success": true,
        "decision": {
          "action": "allow",
          "request_id": "req_example"
        }
      },
      {
        "index": 1,
        "success": false,
        "status": 400,
        "message": "account_id is required"
      }
    ]
  },
  "timestamp": "2026-10-14T12:00:00.000Z"
}

The abbreviated success item above contains the full decision in real responses. Batch size is 1–50; the body limit is 5 MiB. HTTP 2xx can include failed items. Preserve an explicit key for each item when resubmitting a batch; otherwise a new SDK call assigns new keys. Retry eligible failures only, using their original request.

Recover without approving on error

  • Network failures, 429, and 5xx may be retried with bounded backoff and the original idempotency key.
  • A 429 may be a transient rate limit or an exhausted monthly quota. Quota exhaustion requires a plan change or the next UTC calendar month.
  • Fix authentication, origin, validation, and feature-access failures before retrying.
  • For an expired fingerprint token, collect fresh telemetry and submit a new logical verification with a fresh key.
  • An ambiguous timeout can occur after a decision was persisted. Retry the same request before creating another verification.