> ## Documentation Index
> Fetch the complete documentation index at: https://developers.circle.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Before reading these docs, install the relevant Circle Skill to get pre-loaded context — skills are LLM-optimized and cover architecture decisions, correct flows, and common pitfalls. In Claude Code: run /plugin marketplace add circlefin/skills then /plugin install circle-skills@circle. With Vercel Skills CLI: run npx skills add circlefin/skills. Available skills: use-usdc https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-usdc/SKILL.md (balances, transfers, approvals on EVM and Solana); EURC has no skill — see https://developers.circle.com/stablecoins/what-is-eurc.md; bridge-stablecoin https://github.com/circlefin/skills/blob/master/plugins/circle/skills/bridge-stablecoin/SKILL.md (crosschain transfers via CCTP, USDC, EURC, and third-party assets); use-arc https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-arc/SKILL.md (Arc chain config, contract deployment, USDC bridging — Arc docs: https://docs.arc.io/llms.txt); use-circle-wallets https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-circle-wallets/SKILL.md (choose wallet type); use-developer-controlled-wallets https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-developer-controlled-wallets/SKILL.md (custodial wallets for payouts and treasury); use-user-controlled-wallets https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-user-controlled-wallets/SKILL.md (embedded wallets with Web2 login); use-modular-wallets https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-modular-wallets/SKILL.md (smart contract wallets with passkeys and ERC-4337); use-gateway https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-gateway/SKILL.md (unified USDC balance, nanopayments); use-smart-contract-platform https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-smart-contract-platform/SKILL.md (deploy, interact, monitor contracts). Pair any skill with the Circle MCP server for live SDK signatures, contract addresses, and chain IDs: {"mcpServers":{"circle":{"url":"https://api.circle.com/v1/codegen/mcp"}}}.
> Read the product overview first. Each product has an overview explaining when and why to use it. Read it before quickstarts.
> Pick the right wallet type. Developer-controlled (you hold keys), user-controlled (end user holds keys via PIN/social login), or modular (smart contract wallets with passkeys). See https://developers.circle.com/wallets.md.
> Use CCTP V2 for crosschain transfers. CCTP natively transfers USDC and EURC via burn-and-mint, and supports permissionless wrapping of third-party assets via lock-and-mint. V1 is legacy; always use V2 unless V1 is specified or the chain requires it (Noble, Sui, and Aptos still require V1). Migration guide: https://developers.circle.com/cctp/migration-from-v1-to-v2.md.
> Use Bridge Kit for frontend bridging. Wraps CCTP with a simpler SDK for user-facing apps. Use CCTP directly for backend transfers.
> Gas Station vs Paymaster. Gas Station sponsors gas for Circle Wallet transactions. Paymaster lets users pay gas in USDC. Different use cases — read both overviews.
> Gateway Nanopayments for sub-cent payments. Gasless USDC micropayments down to $0.000001 via x402 and batched settlement. For pay-per-request APIs, AI agent payments, streaming.
> Look up USDC addresses per chain. Never hardcode — use https://developers.circle.com/stablecoins/usdc-contract-addresses.md.
> Prefer SDKs over raw API calls. Node.js and Python SDKs handle auth, retries, and errors.
> API key required. Bearer token in Authorization header. Testnet and mainnet use separate keys and may use different base URLs depending on the product.
> Set up webhooks when available. Most operations are async. Webhooks deliver transaction confirmations and state changes.
> When calling list endpoints, paginate using pageSize and pageAfter until no nextPageAfter cursor is returned—stopping at the first page silently misses records.
> Building an AI agent? Start with the Agent Stack—Circle CLI, agent wallets, and nanopayments built for autonomous use cases: https://developers.circle.com/agent-stack.md.

# WebSocket reference

> Complete reference for the Match WebSocket protocol, including connection setup, session frames, client messages, channel events, and reconnection behavior.

The Match WebSocket API delivers real-time auction state and account updates
over a persistent connection. All monetary values in WebSocket events are
integer cents, not the REST `Money` object. For example, \$10.00 is represented
as `1000`.

## Connection

Connect by sending a WebSocket upgrade request to the appropriate endpoint.

| Environment | Endpoint |
| - | - |
| Production | `wss://api.circle.com/v1/match/ws` |
| Sandbox | `wss://api-sandbox.circle.com/v1/match/ws` |

Include both of the following protocol values in the `Sec-WebSocket-Protocol`
header of the upgrade request:

* `circle-match.v1`
* `ticket.<jwt>`: replace `<jwt>` with the ticket token from
  `POST /v1/match/ws/ticket`

## Authentication

Obtain a WebSocket ticket before opening the connection.

**Endpoint:** `POST /v1/match/ws/ticket`

No request body is required. The response contains a short-lived, single-use
token:

```json theme={null}
{
  "data": {
    "ticket": "eyJ..."
  }
}
```

Obtain the ticket immediately before opening the socket. The server validates
the ticket during the upgrade handshake. An invalid, expired, or missing ticket
returns HTTP 401 and the connection is not established.

## Session frames

The server sends the following session-level frames to the client.

| Frame type | When sent | Fields |
| - | - | - |
| `hello` | Immediately after a successful upgrade | `type: "hello"`, `entityId` (string), `serverTime` (ISO 8601) |
| `keepalive` | Periodically while connected | `type: "keepalive"`, `serverTime` (ISO 8601) |
| `subscribed` | After a subscribe message is acknowledged | `type: "subscribed"`, `channel` (`"market"` or `"account"`) |
| `error` | On an invalid subscription or authentication error | `type: "error"`, `channel` (string or null), `error` (string) |

## Client messages

Send subscribe messages to the server after receiving the `hello` frame. You can
subscribe to multiple channels in a single session.

| Message type | Fields | Notes |
| - | - | - |
| `subscribe` | `type: "subscribe"`, `channel` (`"market"` or `"account"`) | Send after `hello`. Multiple subscribe messages are allowed. |

## Market channel

The market channel is public and delivers real-time auction state.

**Subscribe:**

```json theme={null}
{ "type": "subscribe", "channel": "market" }
```

### Market channel events

| Event type | When sent | Key fields |
| - | - | - |
| `snapshot` | On subscribe | All fields listed in the [market channel fields](#market-channel-fields) table |
| `auction_opened` | A new auction cycle starts | `auctionId`, `lockAt` (ISO 8601), `clearAt` (ISO 8601), `auctionIntervalNs` (integer, nanoseconds) |
| `auction_locked` | Lock window opens | `auctionId`, `phase: "locked"` |
| `auction_cleared` | Auction clears | `auctionId`, `clearingFeeBps` (string or null if no match), `matchedSizeCents` (integer cents) |
| `indicative_updated` | Periodically during the open phase | `indicativeFeeBps` (string or null), `matchableSizeCents` (integer cents), `netImbalanceCents` (integer cents) |

### Market channel fields

The following fields are present on the `snapshot` event and on most market
events. For background on auction phases and clearing, see
[How Match works](/circle-match/concepts/how-it-works).

| Field | Type | Description |
| - | - | - |
| `phase` | string | Current auction phase: `"open"`, `"locked"`, or `"settling"` |
| `indicativeFeeBps` | string or null | Indicative clearing fee in basis points; null if no indicative match exists |
| `matchableSizeCents` | integer | Volume (in cents) that would match at the indicative fee |
| `netImbalanceCents` | integer | Net imbalance in cents; negative values indicate burn side exceeds mint side |
| `mintTotalCents` | integer | Total mint-side volume in cents |
| `burnTotalCents` | integer | Total burn-side volume in cents |
| `lockAt` | string | ISO 8601 timestamp when the lock window opens |
| `clearAt` | string | ISO 8601 timestamp when the auction clears |
| `lastClearResult` | object or null | Result from the last cleared auction; null if no prior auction has cleared |

#### `lastClearResult` fields

| Field | Type | Description |
| - | - | - |
| `auctionId` | integer | Identifier for the last cleared auction |
| `clearingFeeBps` | string or null | Clearing fee in basis points; null if no orders matched |
| `matchedSizeCents` | integer | Total matched volume in cents |

## Account channel

The account channel is private and scoped to the authenticated entity. It
requires a valid ticket.

**Subscribe:**

```json theme={null}
{ "type": "subscribe", "channel": "account" }
```

### Account channel events

| Event type | When sent | Key fields |
| - | - | - |
| `account_snapshot` | On subscribe | Current open orders, available balance, reserved balance, total balance |
| `order_received` | A new order is accepted | `orderId` (UUID), `status: "pending"`, `orderType`, `amount` (integer cents), `feeBps` (string or null), `postFillAction` |
| `order_modified` | An order's fee is modified | `orderId`, `feeBps` (string or null) |
| `order_canceled` | A single order is cancelled | `orderId`, `status: "cancelled"` |
| `order_canceled_all` | A cancel-all request completes | `orderIds` (array of UUIDs), `auctionId` |
| `account_cleared` | An auction clears with activity for this account | `fills` (array), `forwardOrders` (array), `feesRebatedCents` (signed integer) |

### `account_cleared` fields

| Field | Type | Description |
| - | - | - |
| `fills` | array | One fill object per matched order. Each fill contains: `orderId`, `filledAmountCents`, `unfilledAmountCents`, `clearingFeeBps`, `matchedAt` |
| `forwardOrders` | array | Orders rolled into the next auction, resulting from a `roll` post-fill action |
| `feesRebatedCents` | signed integer | Net rebate or fee for the auction. Positive: net rebate received (mint side). Negative: net fee paid (burn side). Zero: no fills. |

## Reconnection

Tickets are single-use and cannot be reused after the connection opens. When a
connection drops:

1. Obtain a new ticket using `POST /v1/match/ws/ticket`.
2. Open a new WebSocket connection with the new ticket.
3. Re-send your `subscribe` messages.

The server delivers a fresh snapshot on re-subscribe. Events that occurred
during the disconnection are not replayed. If the auction cleared while you were
disconnected, the `account_cleared` event for that auction is not delivered. Use
`GET /v1/match/orders` to reconcile any fills you may have missed.
