Skip to content

Agent API Reference

Everything your AI agent needs to introduce itself, understand your boundaries, and start working together.

Quick Start

1. Get an API key from the dashboard
Authorization: Bearer clr_live_a1b2c3d4...
2. Connect your agent
POST /api/v1/agent/connect
{
  "agentName": "Shopping Assistant",
  "agentType": "shopping",
  "platform": "claude",
  "capabilities": ["shopping", "payment"]
}
3. Check before acting
POST /api/v1/agent/check
{
  "action": "purchase",
  "transaction": {
    "amount": 49.99,
    "currency": "USD",
    "merchantName": "Amazon",
    "merchantDomain": "amazon.com",
    "category": "electronics"
  }
}

Endpoints

  • POST/api/v1/agent/connect
    Register agent and establish connection
  • POST/api/v1/agent/check
    Pre-action rule evaluation
  • GET/api/v1/agent/rules
    Fetch configured rules
  • GET/api/v1/agent/soul
    Fetch soul.md personality
  • GET/api/v1/agent/stores
    Fetch trusted/blocked stores

Response Codes

CodeMeaning
200Success
201Agent created (pending confirmation)
400Validation error
401Invalid or missing API key
403Agent suspended, pending, or kill switch active
404Agent not found
429Rate limit exceeded

Check Response

{
  "result": "allow" | "deny" | "escalate",
  "ruleId": "SF-001",
  "ruleName": "Per-Transaction Spending Cap",
  "reason": "Transaction amount $49.99 is within limit of $500",
  "approvalRequired": {
    "tier": 1,
    "method": "notification",
    "timeout": 300
  },
  "evaluatedRules": 42,
  "timestamp": "2026-02-20T12:00:00.000Z"
}

Governance Checkout Endpoints

Governance-mode checkout endpoints for agent-driven purchase flows. ClawdRules evaluates rules, approves or denies transactions, and the agent handles payment externally. After paying, the agent reports a receipt back to complete the checkout. All amounts are in the smallest currency unit (cents for USD).

  • POST/api/v1/agent/checkout
    Create a new checkout session
  • GET/api/v1/agent/checkout
    Read checkout status
  • PUT/api/v1/agent/checkout/update
    Update checkout items
  • POST/api/v1/agent/checkout/complete
    Request approval to proceed
  • GET/api/v1/agent/approval/{approvalId}
    Poll approval status
  • POST/api/v1/agent/checkout/receipt
    Report payment receipt (final step)
  • POST/api/v1/agent/checkout/cancel
    Cancel a checkout
  • POST/api/v1/agent/kill-switch
    Emergency kill switch

Governance Flow

ClawdRules is governance-only: it evaluates rules and approves/denies transactions, but does not process payments. The agent pays externally (e.g., via Stripe, a browser, or another payment provider) and then reports a receipt back to ClawdRules to complete the checkout.

  1. Create checkout — agent submits cart items for rules evaluation
  2. Rules check — ClawdRules returns allow, deny, or escalate
  3. Request approval — agent calls complete to move to approved
  4. Poll approval — if escalated, agent polls until approved/denied/expired
  5. Pay externally — agent processes payment through its own payment method
  6. Report receipt — agent posts receipt to complete the checkout

Checkout Status Machine

not_ready_for_payment  ──(update items)──>  ready_for_payment
        │                                          │
        │                                     (complete)
        │                                          │
        │                                          ▼
        │                                      approved
        │                                          │
        │                                    (receipt)
        │                                          │
        └─────────(cancel)──────>  canceled         ▼
                                               completed

not_ready_for_payment — Initial state after creation. Items present but checkout not yet validated.

ready_for_payment — Items validated, rules passed. Ready for approval.

approved — Governance approved. Agent should now pay externally and report a receipt.

completed — Receipt received. Order finalized.

canceled — Checkout was canceled by agent, denied by rules, or expired.

POST/api/v1/agent/checkout

Create a new checkout session. Runs governance rules on the cart items. Returns status not_ready_for_payment or ready_for_payment.

// Request body
{
  "items": [
    {
      "name": "Wireless Headphones",   // required, max 200 chars
      "unit_amount": 4999,              // required, cents (positive int, max 99999999)
      "quantity": 1,                    // required, positive int, max 10000
      "sku": "WH-100",                 // optional, max 100 chars
      "category": "electronics"         // optional, max 100 chars
    }
  ],
  "currency": "USD",                    // optional, default "USD", ISO 4217
  "merchant_name": "TechShop",          // optional, max 200 chars
  "merchant_domain": "techshop.com",    // optional, max 200 chars
  "category": "electronics",            // optional, max 100 chars
  "metadata": { "ref": "order-123" }    // optional, under 10KB JSON
}

GET/api/v1/agent/checkout

Read the current checkout status. Pass checkout_id as a query parameter.

GET /api/v1/agent/checkout?checkout_id=chk_abc123

// Returns full CheckoutResponse (same shape as all checkout endpoints)

PUT/api/v1/agent/checkout/update

Update items, merchant, or metadata on an existing checkout. Only valid when status is not_ready_for_payment or ready_for_payment.

// Request body
{
  "checkout_id": "chk_abc123",          // required
  "items": [                            // optional — replaces all items
    {
      "name": "Wireless Headphones",
      "unit_amount": 3999,
      "quantity": 2,
      "sku": "WH-100",
      "category": "electronics"
    }
  ],
  "merchant_name": "TechShop",          // optional
  "merchant_domain": "techshop.com",    // optional
  "category": "electronics",            // optional
  "metadata": { "ref": "updated-456" }  // optional
}

POST/api/v1/agent/checkout/complete

Request approval to proceed with the purchase. Only valid when status is ready_for_payment. If rules allow it, transitions to approved. If escalated, the agent must poll the approval endpoint until resolved. No payment tokens are needed — the agent pays externally after approval.

// Request body
{
  "checkout_id": "chk_abc123"           // required
}

// Response on approval:
{
  "id": "chk_abc123",
  "status": "approved",
  "approval_required": null,
  ...
}

// Response when escalated (requires human approval):
{
  "id": "chk_abc123",
  "status": "ready_for_payment",
  "approval_required": {
    "approval_id": "apr_xyz",
    "tier": 2,
    "method": "notification",
    "timeout": 300,
    "status": "pending"
  },
  ...
}

POST/api/v1/agent/checkout/cancel

Cancel an active checkout. Valid from any status except completed. Transitions to canceled.

// Request body
{
  "checkout_id": "chk_abc123",  // required
  "reason": "User changed mind"  // optional, max 500 chars
}

GET/api/v1/agent/approval/{approvalId}

Poll the status of a pending approval. Use this when the complete endpoint returns an escalated response with an approval_id. Poll until status is no longer pending.

GET /api/v1/agent/approval/apr_xyz

// Response:
{
  "approval_id": "apr_xyz",
  "status": "pending" | "approved" | "denied" | "expired",
  "checkout_id": "chk_abc123",
  "tier": 2,
  "method": "notification",
  "reason": null,                       // populated on deny
  "decided_at": null,                   // populated when resolved
  "expires_at": "2026-02-22T12:05:00.000Z"
}

POST/api/v1/agent/checkout/receiptFINAL STEP

Report a payment receipt after the agent has paid externally. This is the final step in the checkout flow. Only valid when status is approved. Transitions to completed.

// Request body
{
  "checkout_id": "chk_abc123",          // required
  "receipt": {
    "external_id": "pi_xxxxxxxx",       // required — payment provider's transaction ID
    "provider": "stripe",               // required — payment provider name
    "amount_charged": 4999,             // required — actual amount charged in cents
    "currency": "USD",                  // optional, default matches checkout currency
    "paid_at": "2026-02-22T12:02:00Z", // optional, defaults to now
    "metadata": {                       // optional
      "card_last4": "4242",
      "confirmation_url": "https://..."
    }
  }
}

// Response:
{
  "id": "chk_abc123",
  "status": "completed",
  "order": {
    "id": "ord_abc123",
    "checkout_session_id": "chk_abc123",
    "external_payment_id": "pi_xxxxxxxx",
    "provider": "stripe",
    "amount_charged": 4999,
    "completed_at": "2026-02-22T12:02:00.000Z"
  },
  ...
}

POST/api/v1/agent/kill-switch

Emergency kill switch. Immediately suspends the agent and cancels all active checkouts. Requires explicit confirmation. This action is irreversible — the agent must be manually re-enabled from the dashboard.

// Request body
{
  "confirm": true,                      // required — must be true
  "reason": "Suspicious activity"       // required — why the kill switch was triggered
}

// Response:
{
  "success": true,
  "agent_status": "suspended",
  "active_checkouts_canceled": 3,
  "timestamp": "2026-02-22T12:00:00.000Z"
}

Checkout Response Shape

All checkout endpoints return the full CheckoutResponse object. This is the canonical shape:

{
  "id": "chk_abc123",
  "status": "approved",                 // see status machine above
  "currency": "usd",
  "line_items": [
    {
      "id": "li_item1",
      "item": { "name": "Wireless Headphones", "quantity": 1, "sku": "WH-100" },
      "base_amount": 4999,
      "subtotal": 4999,
      "tax": 0,
      "total": 4999
    }
  ],
  "merchant_name": "TechShop",
  "merchant_domain": "techshop.com",
  "category": "electronics",
  "totals": [
    { "type": "subtotal", "display_text": "Subtotal", "amount": 4999 },
    { "type": "tax", "display_text": "Tax", "amount": 0 },
    { "type": "total", "display_text": "Total", "amount": 4999 }
  ],
  "messages": [],
  "rule_result": "allow",
  "rule_name": "Per-Transaction Spending Cap",
  "reason": "Transaction amount $49.99 is within limit of $500",
  "approval_required": null,            // null when approved, object when escalated
  "order": null,                        // populated after receipt is reported
  "expires_at": "2026-02-22T13:00:00.000Z",
  "created_at": "2026-02-22T12:00:00.000Z"
}

Checkout Error Codes

Errors follow the format: { type, code, message, param? }

CodeTypeMeaning
checkout_not_foundinvalid_requestNo checkout with that ID exists
checkout_expiredinvalid_requestCheckout session has expired
checkout_not_readyinvalid_requestCheckout is not in the correct state for this operation
checkout_completedinvalid_requestCannot modify a completed checkout
rules_deniedinvalid_requestTransaction denied by governance rules
approval_pendinginvalid_requestApproval is still pending — poll the approval endpoint
approval_deniedinvalid_requestHuman reviewer denied the transaction
approval_expiredinvalid_requestApproval request timed out
approval_not_foundinvalid_requestNo approval with that ID exists
receipt_mismatchinvalid_requestReceipt amount does not match approved checkout total
kill_switch_activeforbiddenAgent is suspended — kill switch was triggered
validation_errorinvalid_requestRequest body validation failed
malformed_jsoninvalid_requestRequest body is not valid JSON