x402 payment flow

Payment enforcement happens at the Caddy gateway. The API publishes payment requirements through discovery and OpenAPI; the gateway verifies and settles via the facilitator.

1. Preflight Call a paid route without PAYMENT-SIGNATURE. Gateway returns 402 with PAYMENT-REQUIRED.
2. Sign Client wallet builds and signs the USDC transfer payload expected by the facilitator.
3. Retry Resend the request with PAYMENT-SIGNATURE. Caddy verifies and settles via facilitator.
4. Success Paid route returns 200 and may include PAYMENT-RESPONSE settlement metadata. For a session SKU, present AMAROK-SESSION on later research GETs instead of a new signature.

Required headers

Typical accept policy fields

Per-route pricing (defaults)

Confirm against live discovery before integrating. Documented defaults:

Per-request 402 is the default. Bundle and session are additive: pay GET /v1/alpha/bundle once for a composite payload, or POST /v1/alpha/session and present AMAROK-SESSION on covered research GETs. Do not replay PAYMENT-SIGNATURE.

Unsigned execution quotes

  1. Call free GET /v1/alpha/execution/shapes to learn supported builders.
  2. Preflight paid POST /v1/alpha/execution/quotes, satisfy its x402 requirement, and retry with PAYMENT-SIGNATURE.
  3. Sign only the returned userSignIndexes / unsignedTxnsBase64, then submit through your own Algod client.

Amarok never receives wallet keys and never submits orders. meta.executionSubmitted is always false.

MCP server (agent tools)

Agents can connect to the remote Amarok MCP endpoint instead of calling HTTP endpoints directly. The MCP layer is walletless: paid tools return payment requirements first, then accept a caller-supplied paymentSignature on retry.

Cursor and Claude Desktop configs: quickstart. Full tool list: MCP documentation.

{
  "mcpServers": {
    "amarok": {
      "url": "https://amarok-mcp.compx.io/mcp"
    }
  }
}

Common failure modes

curl -i https://amarok-api.compx.io/v1/alpha/opportunities