API reference

charge

POST/v1/charge

Agent paid access lifecycle

Purchase and manage paid resource access (fixed-price API calls, bounded

dataset access, prepaid compute seconds) through a single endpoint.

The operation field discriminates the lifecycle step. Charge is separate

from the security verbs (verify / feedback / challenge) and is not a verify

data-plane operation. Payment, permission, and delivery remain separate: a

security allow is never proof of payment, and buyers cannot assert

payment or delivery.

Every mutation requires an idempotency key. The Idempotency-Key header takes precedence over

body idempotencyKey.

Headers

Authorizationstringrequired

Bearer API key. Charge operations require the relevant charge scope:

Content-Typestringrequired

application/json

Request body

operationstringrequired

resource | quote | accept | status | cancel | reconcile | permission | reserve | usage | refund | configure | budget

sellerTenantIdstringrequired

Seller tenant that owns the resource or purchase.

idempotencyKeystringoptional

Retry dedupe key; header takes precedence over the body field.

operation-specific fieldsmixedoptional

quote: resourceId, quantity, operationDigest · accept: purchaseId, quoteVersion, maxAmount, currency · status/cancel/reconcile: purchaseId · permission: purchaseId, allowed, eventId? · reserve: purchaseId, executionId, operationDigest, units · usage: purchaseId, executionId, sequence, usedUnits, result · refund: purchaseId, amount · configure: resource · budget: buyerTenantId, limit.

Response

okbooleanrequired

Always true on a successful lifecycle result.

purchaseobjectoptional

Present for purchase operations. Includes quote, accepted, permission, payment, delivery, stopped, and next.

nextstringoptional

Suggested next step: accept | pay | wait | seller_permission | execute | reconcile | complete.

resourceobjectoptional

Present for configure and resource operations.

budgetobjectoptional

Present for budget: { limit, committed }.

reservationobjectoptional

Present on reserve: { executionId, granted, leaseUntil }.

  • 200 returns the ChargeResponse shape. 400 bad request, 401 unauthorized,
  • 403 missing the required charge scope, 409 idempotency conflict, 413
  • payload too large, 429 rate limited, 503 charge store unavailable return
  • the Error schema.
  • Use the configured test base URL and substitute your seller, resource, and server-computed operation digest. The all-zero digest in the wire examples is illustrative.
  • The buyer uses charge:buy for quote, accept, status, and cancel. The buyer owner uses charge:budget to set its own ceiling. The seller uses charge:configure for resources, charge:fulfill for permission, reserve, and usage, and charge:manage for status, refund, and reconciliation. Resource reads accept buyer or seller configuration scope.
  • Exact mutation retries recover the original intent and current purchase. A changed payload under the same key returns 409 idempotency_conflict. Replays do not grant another execution reservation.
Request
curl -fsS "$CHITMARK_API_BASE_URL/v1/charge" \
  -H "Authorization: Bearer $CHITMARK_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: chg:sess_9f3a" \
  -d '{
    "operation": "quote",
    "sellerTenantId": "org_acme",
    "resourceId": "api_calls_v1",
    "quantity": 1,
    "operationDigest": "0000000000000000000000000000000000000000000000000000000000000000"
  }'
Response
{
  "ok": true,
  "purchase": {
    "purchaseId": "purchase_01JQ…",
    "quote": {
      "version": "quote_01JR…",
      "sellerTenantId": "org_acme",
      "buyerTenantId": "org_buyer",
      "actingAgent": "agent_caller_1",
      "resource": {
        "resourceId": "api_calls_v1",
        "version": 1,
        "kind": "api_call",
        "unit": "call",
        "unitAmount": 100,
        "currency": "usd",
        "minQuantity": 1,
        "maxQuantity": 1,
        "maxAmount": 100,
        "quoteTtlSeconds": 300,
        "accessTtlSeconds": 3600,
        "enabled": true,
        "refundTerms": "unused_only"
      },
      "quantity": 1,
      "amount": 100,
      "currency": "usd",
      "operationDigest": "0000000000000000000000000000000000000000000000000000000000000000",
      "expiresAt": 1785800300000,
      "accessUntil": 1785803600000
    },
    "accepted": false,
    "permission": { "allowed": false, "source": "seller" },
    "payment": {
      "state": "pending",
      "authorizedAmount": 0,
      "capturedAmount": 0,
      "refundedAmount": 0,
      "refundState": "none",
      "disputedAmount": 0,
      "providerFee": null,
      "checkedAt": null,
      "source": "provider"
    },
    "delivery": { "source": "seller_report", "executions": [] },
    "stopped": false,
    "refundRequestedAmount": 0,
    "createdAt": 1785800000000,
    "updatedAt": 1785800000000
  },
  "next": "accept"
}