/ API Reference v0.2

API Reference

BSA/OFAC compliance middleware for AI agent-initiated payments.

Base URL api.clearagent.dev Version 0.2.0 Protocol HTTPS Response JSON

Introduction

CLEARAGENT is a single-call compliance layer that sits between an AI agent and a payment rail. Send a KYA credential token and transaction details; receive a verdict — PROCEED, REVIEW, BLOCK, or UNKNOWN — in under 50ms.

The API runs on Cloudflare Workers at the edge. There is no server, no backend, no warm-up time. Every request is processed in the data center closest to the caller.

No Claude API at runtime. The screening engine is fully deterministic — 25 rules executed in sequence. The same inputs always produce the same verdict. No LLM inference occurs during a screen call.

Authentication

All endpoints except /v1/health and /v1/.well-known/jwks.json require a Bearer token in the Authorization header.

curl https://api.clearagent.dev/v1/screen \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{...}'

Contact [email protected] to request a credentialed API key.

Base URL

https://api.clearagent.dev

Verdict Reference

Every POST /v1/screen response includes a verdict field with one of four values:

VerdictMeaningRecommended action
PROCEEDAll 25 rules passed. Transaction is clear.Allow payment to execute.
REVIEWA spend policy, behavioral flag, or soft risk rule triggered.Route to compliance officer queue before executing.
BLOCKOFAC hit, invalid credential, or hard policy violation.Reject the transaction. Do not execute.
UNKNOWNNo KYA credential presented, or credential is structurally invalid.Hold transaction. Request credential from agent operator.
BLOCK is final. A BLOCK verdict from an OFAC hit or revoked credential cannot be overridden by institution policy. REVIEW verdicts are subject to institution-level configuration.

Error Codes

HTTP StatusCodeDescription
400missing_tokenNo KYA token provided in the request body.
400invalid_jsonRequest body is not valid JSON.
401unauthorizedMissing or invalid API key.
404not_foundAudit record txnId does not exist or has expired (90-day TTL).
405method_not_allowedWrong HTTP method for this endpoint.
500internal_errorWorker fault. Contact support with the txnId if available.

Register Agent

POST /v1/agents/register Auth required

Issue a W3C Verifiable Credential (ES256-signed JWT) for an AI agent. The operator wallet and legal name are OFAC-screened at issuance. The credential is valid for 91 days and stored in KV under cred:{agentId}.

Request body

FieldTypeRequiredDescription
agentNamestringrequiredHuman-readable name for the agent (e.g. "PayrollBot v2").
agentFrameworkstringoptionalFramework powering the agent: LangChain, CrewAI, OpenAI Assistants, AutoGen, etc.
underlyingModelstringoptionalUnderlying LLM: claude-sonnet-4-6, gpt-4o, etc. Model change after issuance triggers a REVIEW flag.
agentTypestringrequiredautonomous or supervised. Autonomous agents require human heartbeat attestation every 24h.
operatorWalletstringcryptoOperator Ethereum wallet address. OFAC-screened at issuance.
operatorEINstringtradfiOperator EIN for TradFi/ACH payment flows.
operatorLegalNamestringrequiredLegal entity name. Checked against OFAC CONS_ENHANCED name list.
purposestringrequiredPlain-language description of the agent's payment purpose.
spendPolicyobjectoptionalSpend limits and restrictions (see below).

spendPolicy object

FieldTypeDescription
maxSingleTxUSDCnumberMaximum single transaction value in USD. Transactions above this trigger REVIEW.
dailyLimitUSDCnumberCumulative daily spend ceiling in USD. Tracked per agent per UTC date.
allowedChainsstring[]Permitted payment chains: ETH, BASE, SOL, ACH, WIRE, SWIFT.
allowedRailsstring[]Permitted payment rails: USDC, ACH, WIRE, SWIFT, IBAN.
counterpartyScreeningstringScreening level: OFAC, OFAC+CONS.
noMixerProtocolsbooleanIf true, transactions to Tornado Cash, Railgun, or other mixers are blocked.

Example request

curl -X POST https://api.clearagent.dev/v1/agents/register \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentName": "PayrollBot v2",
    "agentFramework": "LangChain",
    "underlyingModel": "claude-sonnet-4-6",
    "agentType": "autonomous",
    "operatorLegalName": "Acme Corp",
    "operatorWallet": "0xYourWalletAddress",
    "purpose": "Automated USDC payroll disbursements to contractors",
    "spendPolicy": {
      "maxSingleTxUSDC": 10000,
      "dailyLimitUSDC": 50000,
      "allowedChains": ["ETH", "BASE"],
      "counterpartyScreening": "OFAC+CONS",
      "noMixerProtocols": true
    }
  }'

Example response

{
  "agentId": "agt_Xk9mQ2Rz",
  "token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
  "credential": {
    "@context": ["https://www.w3.org/2018/credentials/v1", "https://kya.protocol/v1"],
    "type": ["VerifiableCredential", "KYAAgentCredential"],
    "issuer": "did:kya:clearagent-alpha",
    "credentialSubject": {
      "agentId": "agt_Xk9mQ2Rz",
      "agentName": "PayrollBot v2",
      "agentType": "autonomous",
      "operatorLegalName": "Acme Corp",
      "spendPolicy": { "maxSingleTxUSDC": 10000, "dailyLimitUSDC": 50000, "allowedChains": ["ETH","BASE"] },
      "complianceAttestation": {
        "ofacAtIssuance": "CLEAR",
        "screenedAt": "2026-03-11T14:22:00Z",
        "credentialStatus": "ACTIVE"
      }
    },
    "expirationDate": "2026-06-10T14:22:00Z"
  }
}

Screen Transaction

POST /v1/screen Auth required

Screen a proposed transaction against the 25-rule compliance engine. Returns a verdict in under 50ms. A txnId is generated for every call and the full result is written to the tamper-evident audit log (90-day retention).

Request body

FieldTypeRequiredDescription
tokenstringrequiredKYA credential JWT. Accepts Bearer, VerifiableCredential, ProofPack, or JWT scheme prefixes, or raw token.
amountnumberrequiredTransaction amount in USD.
chainstringoptionalPayment chain: ETH, BASE, SOL, ACH, WIRE, SWIFT.
railstringoptionalPayment rail: USDC, ACH, WIRE, SWIFT, IBAN.
cpWalletstringcryptoCounterparty Ethereum wallet address. OFAC-screened.
cpNamestringoptionalCounterparty legal name. Checked against OFAC CONS_ENHANCED name list.
cpTypestringoptionalCounterparty type: individual, business, exchange.
protocolstringoptionalProtocol or platform name. Used for mixer/privacy protocol detection.

Example request

curl -X POST https://api.clearagent.dev/v1/screen \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
    "amount": 4500,
    "chain": "ETH",
    "rail": "USDC",
    "cpWallet": "0xRecipientWalletAddress",
    "cpName": "Contractor LLC",
    "cpType": "business"
  }'

Example response — PROCEED

{
  "verdict": "PROCEED",
  "txnId": "txn_A8bKmQ3x",
  "rule": null,
  "reason": "All compliance checks passed.",
  "agentId": "agt_Xk9mQ2Rz",
  "agentName": "PayrollBot v2",
  "operatorLegalName": "Acme Corp",
  "credentialStatus": "ACTIVE",
  "ofacSource": "kv:live",
  "screenedAt": "2026-03-11T14:23:01Z",
  "latencyMs": 38
}

Example response — BLOCK (OFAC hit)

{
  "verdict": "BLOCK",
  "txnId": "txn_B7cNpR4y",
  "rule": "R6_COUNTERPARTY_WALLET_OFAC",
  "reason": "Counterparty wallet matches OFAC SDN list: Lazarus Group / DPRK (Ronin Bridge, $620M, Mar 2022)",
  "agentId": "agt_Xk9mQ2Rz",
  "screenedAt": "2026-03-11T14:23:44Z",
  "latencyMs": 29
}

25-Rule Screening Precedence

Rules are evaluated in order — first match wins. BLOCK rules take precedence over REVIEW rules.

#Rule IDVerdictTrigger
1R1_NO_CREDENTIALUNKNOWNNo token or structurally invalid JWT
2R2_CREDENTIAL_STATUSBLOCKCredential status is REVOKED, EXPIRED, or SUSPENDED
3R3_OPERATOR_OFAC_ISSUANCEBLOCKOperator wallet matched OFAC at issuance
4R4_OPERATOR_WALLET_LIVEBLOCKOperator wallet matches live OFAC SDN (re-screened every call)
5R5_OPERATOR_NAME_OFACBLOCKOperator legal name matches OFAC CONS_ENHANCED entity list
6R6_COUNTERPARTY_WALLET_OFACBLOCKCounterparty wallet matches OFAC SDN
7R7_COUNTERPARTY_NAME_OFACBLOCKCounterparty name matches OFAC entity list
8R8_OWNERSHIP_TRANSFERBLOCKOwnership transfer flag set — credential must be re-issued
9R9_CHAIN_POLICYREVIEWTransaction chain not in allowedChains
10R10_SINGLE_TX_LIMITREVIEWTransaction amount exceeds maxSingleTxUSDC
11R11_DAILY_LIMITREVIEWTransaction would exceed dailyLimitUSDC
12R12_FLEET_DAILY_LIMITREVIEWFleet aggregate daily limit would be exceeded
13R13_COUNTERPARTY_WHITELISTREVIEWCounterparty not on approved whitelist (when whitelist is set)
14R14_MIXER_PROTOCOLBLOCKProtocol field matches known mixer/privacy protocol
15R15_MODEL_CHANGEDREVIEWUnderlying model has changed since credential issuance
16R16_VELOCITY_FLAGREVIEWUnusual transaction velocity detected
17R17_UNUSUAL_HOURREVIEWTransaction outside normal operating hours
18–25R18–R25Additional rail, counterparty type, and policy rules
ALL_CLEARPROCEEDNo rules triggered

Create Fleet

POST /v1/fleets/create Auth required

Create a fleet spend envelope under an operator. Agents can be assigned to a fleet, which enforces an aggregate daily spend limit across all agents in the fleet. Useful for organizations running multiple agents under a shared budget.

curl -X POST https://api.clearagent.dev/v1/fleets/create \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fleetName": "Finance Operations Fleet",
    "operatorLegalName": "Acme Corp",
    "dailyLimitUSDC": 200000
  }'

Create Delegate

POST /v1/delegates/create Auth required

Mint a child agent credential from a parent agent credential. The child credential inherits the parent's policy and can only narrow it — it cannot expand spend limits or add chains beyond what the parent allows. Delegation depth is capped at 3 levels.

Register User

POST /v1/users/register Auth required

Issue a 30-day individual user credential. Valid for supervised agent contexts only — autonomous agents cannot be assigned user credentials. User credentials are stored under user:{userId} in KV with a 31-day TTL.

Human Attestation

POST /v1/agents/:id/attest Auth required

Record a human heartbeat re-attestation for an autonomous agent. Autonomous agents must be re-attested every 24 hours. If attestation is stale, transactions over $10,000 are automatically escalated to REVIEW. Attestation records are stored under attest:{agentId} with a 25-hour TTL.

curl -X POST https://api.clearagent.dev/v1/agents/agt_Xk9mQ2Rz/attest \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "attestedBy": "[email protected]",
    "note": "Routine daily attestation"
  }'

Review Disposition

POST /v1/reviews/:txnId Auth required

Post a BSA officer's disposition on a transaction that received a REVIEW verdict. This is the human-in-the-loop endpoint: when the screening engine flags a transaction for review (spend policy, velocity anomaly, model change, etc.), a compliance officer calls this endpoint to record their decision.

Path Parameters

NameTypeRequiredDescription
txnIdstringYesTransaction ID from the /v1/screen response (format: txn_XXXXXXXX)

Request Body

FieldTypeRequiredDescription
dispositionstringYesAPPROVED | REJECTED | ESCALATE_SAR
reviewedBystringYesReviewer name or employee ID (BSA audit trail)
notesstringNoFree-text rationale for the decision

Example Request

curl -X POST https://api.clearagent.dev/v1/reviews/txn_a1b2c3d4 \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "disposition": "APPROVED",
    "reviewedBy": "J. Smith, BSA Officer",
    "notes": "Reviewed velocity flag — within normal operating pattern for this agent."
  }'

Response (200)

Returns the full updated audit record with disposition fields appended:

{
  "txnId": "txn_a1b2c3d4",
  "verdict": "REVIEW",
  "ruleTriggered": "VELOCITY_SPIKE",
  "reason": "Transaction velocity exceeded 3x rolling average",
  "disposition": "APPROVED",
  "reviewedBy": "J. Smith, BSA Officer",
  "reviewedAt": "2026-03-15T14:22:01Z",
  "notes": "Reviewed velocity flag — within normal operating pattern for this agent.",
  "sarEscalated": false,
  ...
}

Dispositions

ValueMeaningEffect
APPROVEDTransaction is compliantAudit record updated. Payment can proceed.
REJECTEDTransaction denied by reviewerAudit record updated. Payment should not proceed.
ESCALATE_SARSuspicious activity — SAR candidateSets sarEscalated: true on the audit record. Route to SAR filing workflow.

Error Responses

StatusCondition
400Transaction verdict is not REVIEW (CLEAR/BLOCK/UNKNOWN cannot be dispositioned)
404Transaction ID not found (expired or never written)
409Disposition already recorded (idempotency guard — prevents double-disposition)
422Invalid disposition value or missing reviewedBy

Get Audit Record

GET /v1/audit/:txnId Auth required

Retrieve a tamper-evident audit record by its txnId. Every /v1/screen call generates a txnId (format: txn_XXXXXXXX) and writes the full result plus request inputs to KV. Records are retained for 90 days.

curl https://api.clearagent.dev/v1/audit/txn_A8bKmQ3x \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "txnId": "txn_A8bKmQ3x",
  "verdict": "PROCEED",
  "rule": null,
  "reason": "All compliance checks passed.",
  "agentId": "agt_Xk9mQ2Rz",
  "agentName": "PayrollBot v2",
  "operatorLegalName": "Acme Corp",
  "credentialStatus": "ACTIVE",
  "ofacSource": "kv:live",
  "screenedAt": "2026-03-11T14:23:01Z",
  "_request": {
    "amount": 4500,
    "chain": "ETH",
    "cpWallet": "0xRecipient...",
    "cpName": "Contractor LLC",
    "rail": "USDC"
  }
}
90-day hot retention. KV records expire after 90 days. For BSA 5-year record-keeping requirements, institutions should implement a scheduled bulk export to their own long-term store. A bulk export endpoint is on the roadmap.

Health Check

GET /v1/health Public — no auth required

Returns API version, OFAC list status, KV connectivity, and signing key state. No authentication required.

curl https://api.clearagent.dev/v1/health
{
  "status": "ok",
  "version": "0.2.0",
  "ofac": {
    "source": "kv:live",
    "count": 77,
    "syncedAt": "2026-03-11T02:00:14Z"
  },
  "kv": "connected",
  "signingKey": "production"
}

JWKS Public Key

GET /v1/.well-known/jwks.json Public — no auth required

Returns the P-256 public key in standard JWKS format. Use this endpoint to independently verify any KYA credential JWT without calling the CLEARAGENT API — any standard JWT library that supports ES256 can verify the signature.

curl https://api.clearagent.dev/v1/.well-known/jwks.json
{
  "keys": [{
    "kty": "EC",
    "crv": "P-256",
    "use": "sig",
    "alg": "ES256",
    "kid": "cc-v1",
    "x": "...",
    "y": "..."
  }]
}
Independent verification. Any party that receives a KYA credential can verify its authenticity without trusting CLEARAGENT — fetch the JWKS endpoint once, cache the public key, and verify all future tokens locally. This is the standard W3C Verifiable Credential verification pattern.