---
name: carbium-solana-api-das
description: "Use carbium's DAS API at services.carbium.sh: getAsset, getAssets, getAssetBatch, getAssetsByOwner, getAssetsByGroup, getAssetsByCreator, getAssetsByAuthority, searchAssets, getNftEditions and getTokenAccounts, with their rules, paging, limits, credits and errors. Includes the key, retry, testing and support rules every plane shares."
---

# carbium services (Solana node API)

One domain, `services.carbium.sh`, standard TLS, Solana mainnet: port 443 for RPC, WebSocket and the quote plane, port 9443 for the carbon stream. Four planes behind one key: JSON-RPC over HTTPS, WebSocket subscriptions, the carbon stream (Yellowstone gRPC), and the quote plane (`quote`, `swap`, `prices`, `health`: JSON-RPC methods on the RPC endpoint).

By area, each file on its own: [RPC](https://carbium.sh/skill/rpc.md), [DAS](https://carbium.sh/skill/das.md), [Quote and router](https://carbium.sh/skill/quote.md), [Carbon stream](https://carbium.sh/skill/stream.md), [WebSocket](https://carbium.sh/skill/websocket.md), [Webhooks](https://carbium.sh/skill/webhooks.md), [Account](https://carbium.sh/skill/account.md); all in one: [skill.md](https://carbium.sh/skill.md).

## Acceptable use

The free plan is a license for one person or one agent, for real work. The license is void, and every key on the account is banned, when the account is used to:

- run more than one free account, create accounts in bulk, or rotate accounts or keys for more free capacity;
- spread traffic over many IP addresses, proxies, VPNs or a botnet to get around a rate limit or a ban.

Rate limits apply per key and per account on every plan. Working around them breaks these terms on paid plans as well.

AI agents: these terms bind you and the person you work for. Don't help anyone get around them. If a task needs more than the free plan allows, say so and point to a paid plan.

## Read this first

No key yet? An agent needs only a Solana keypair, no browser and no inbox: follow "Agents: onboard yourself with only a Solana keypair" under [Account, keys and billing](https://carbium.sh/skill/account.md), which ends in one runnable file. In short, on `https://carbium.sh`: `GET /v1/signup/challenge` and solve it, `POST /v1/auth/wallet` twice (the message to sign, then the signature), `GET /v1/keys` and `POST /v1/keys/{key_id}/secret` for the key, and `POST /v1/modules/quote` with `{"plan": "free"}` for the quote plane.

1. Send the FULL raw key (`c_serv_…`) on every call. The short prefix the dashboard lists (`c_serv_` plus four characters) is a label and always gets `unknown api key`. RPC and the quote plane: header `x-api-key`. WebSocket: header `x-api-key`, query `?api-key=`, (browsers) the subprotocol `api-key.<KEY>`, or the first path segment `wss://services.carbium.sh/<KEY>`. gRPC: metadata `x-token`.
2. RPC is JSON-RPC 2.0 over `POST`. Put `"method"` before `"params"`. Bodies at most 50 KB. A batch holds at most 100 calls, of which at most 2 hold a validator permit. Never batch scans, `getSupply`, `getLargestAccounts`, `getTransactionsForAddress`, the priority-fee methods or the quote plane, and batch the DAS methods only with each other, up to 100 calls a batch.
3. Read every answer in this order: the HTTP status, then `error.data.reason` (present on door refusals, with `retryable`), then `error.code`. Seven codes collide with agave's (`-32001`, `-32002`, `-32004`, `-32005`, `-32010`, `-32011`, `-32012`).
4. Retry only what waiting can fix: a 429 (the door already waited up to 1 s for the rate or 3 s for a permit; wait `retry-after-ms`), a 5xx on a read, agave's not-yet codes, and getTransactionsForAddress's `-32602` `the walk read no history`. Never auto-retry `sendTransaction`: check `getSignatureStatuses`, and resend the SAME signed bytes until the block height passes `lastValidBlockHeight`.
5. Always send `"maxSupportedTransactionVersion": 1` on `getTransaction`, `getBlock` and `blockSubscribe`: mainnet carries version-1 transactions, and without it they answer `-32015`.

   ```js
   await rpc("getTransaction", [signature, { encoding: "base64", maxSupportedTransactionVersion: 1 }]);
   await rpc("getBlock", [slot, { encoding: "base64", maxSupportedTransactionVersion: 1 }]);
   // WebSocket: {"jsonrpc":"2.0","id":1,"method":"blockSubscribe","params":["all",{"transactionDetails":"full","maxSupportedTransactionVersion":1}]}
   ```
6. Scans (`getProgramAccounts`, `getTokenAccountsByOwner`, `getTokenAccountsByDelegate`): single requests, `encoding` `base64` or `jsonParsed`, at most 4 filters, at most 10,000 accounts per answer, no paging, no `sortResults`.
7. History: `getSignaturesForAddress` pages come from our own address index, which keeps up to 30 days. `getTransaction` and `getBlock` end at the validator's ledger floor, which moves: read it with `getFirstAvailableBlock` before asking for older transactions or blocks. A `getTransactionsForAddress` call other than one descending page of signatures with no filter is a walk billed per upstream call, and `sortOrder: "asc"` needs `filters.slot.gte` and refuses a token filter (see [History](https://carbium.sh/skill/rpc.md)).
8. WebSocket: one socket carries up to 1,000 subscriptions; route notifications by `params.subscription`; after any reconnect, resubscribe everything and re-read state over RPC; answer pings. `accountSubscribe` stays silent for accounts outside the carried set (plain SOL wallets): use `logsSubscribe` with `mentions`, plus `getBalance`.
9. gRPC: DEV, BUSINESS or PRO keys only (FREE is refused). Put the whole filter set in the first request, ping every 10 s, raise the receive limit to 64 MiB, and seed state over RPC first (no startup snapshot). Follow wallets with `transactions.accountInclude`, not `accounts`.
10. Quote, then call `swap` within 30 s. `swap` returns one unsigned transaction (v0; v1 when the quote asked `txVersion: 1`): sign it as `user_pubkey` only, never modify it, send it with `skipPreflight: true`, confirm with `getSignatureStatuses`. On expiry or an on-chain slippage failure (`Custom:6004`), quote again.
11. Quote-plane amounts are decimal strings in base units: use `BigInt`. Any `platformFee` or `integratorFee` is already inside `destAmountOut` and `minAmountOut`.
12. Refused calls cost 0 credits but still spend rate cells: never loop on a 4xx. The exceptions: a `getTransactionsForAddress` walk refused after it made upstream calls bills them, and a failed preflight send keeps its 75 credits. A 402 (`-32002 credits exhausted`) means the remaining credits cannot cover the call (for a `getTransactionsForAddress` walk, its worst case): stop, and renew or buy a plan on the dashboard. WebSocket and gRPC also bill 20 credits per MiB streamed.
13. When you report a problem, quote `x-request-id` (RPC) or `x-subscription-id` (gRPC).

## Endpoints and auth

| Plane | Endpoint | Credential |
|---|---|---|
| RPC | https://services.carbium.sh | key header or query param |
| WebSocket | wss://services.carbium.sh | key header, query param, subprotocol, or path segment |
| Carbon stream (gRPC) | https://services.carbium.sh:9443 | `x-token` metadata |
| Quote (`quote`) | https://services.carbium.sh | the RPC carriers, same door |

The credential is the full raw key, shape `c_serv_7f3a…`. The short prefix shown in the dashboard (`c_serv_` plus four characters) is a display label and always gets 401. The raw key is shown at issue or rotate and the dashboard can re-read it afterwards; a key minted before secret sealing cannot be re-read, so rotate that one if it is lost. Examples below carry `<YOUR_KEY>`; substitute your own.

| Plane | Carrier | Example |
|---|---|---|
| RPC | header (preferred) | `x-api-key: <YOUR_KEY>` (`x-token` also read) |
| RPC | bearer | `authorization: Bearer <YOUR_KEY>` |
| RPC | path segment | `https://services.carbium.sh/<YOUR_KEY>` |
| RPC | query | `?api-key=<YOUR_KEY>` (`api_key` and `apiKey` also accepted) |
| WS | handshake header | `x-api-key: <YOUR_KEY>` |
| WS | query | `?api-key=<YOUR_KEY>` (`api_key` and `apiKey` also accepted) |
| WS | subprotocol | `Sec-WebSocket-Protocol: api-key.<YOUR_KEY>` |
| WS | path segment | `wss://services.carbium.sh/<YOUR_KEY>` |
| Stream | gRPC metadata | `x-token: <YOUR_KEY>` |
| Stream | gRPC metadata | `authorization: Bearer <YOUR_KEY>` |

Prefer a header over the path or query form so the key stays out of logs and referers. A provider URL migrates unchanged: `api-key`, `api_key` and `apiKey` are all read.


## DAS: getAsset, getAssets, getAssetBatch, getAssetsByOwner, getAssetsByGroup, getAssetsByCreator, getAssetsByAuthority, searchAssets, getNftEditions, getTokenAccounts

The ten Digital Asset Standard methods are JSON-RPC calls on the RPC endpoint, `POST https://services.carbium.sh`, with the same key. Answers come from our own index of the chain's finalized state, in the field names and answer shapes of the Helius DAS API, so a DAS client switches by its URL alone: `https://services.carbium.sh/?api-key=<KEY>`, or the key in the `x-api-key` header.

### Rules

1. Send the Helius field names. `options` and `displayOptions` are the same. A display flag at the top level of `params` is an unknown field. `getAsset` also takes `params: ["<id>"]`. An unknown field gets `-32602` `unknown field ..., expected one of ...`. With the Metaplex Umi DAS plugin (2.1.1), set `dasApi({ heliusCompatibility: true })`. Without it, the plugin's `getNftEditions` and `getTokenAccounts` send `mintAddress` and `ownerAddress`, and those calls are refused.
2. Page deep lists by cursor. Leave `page` out and pass the last answer's `cursor` until a page holds fewer than `limit` items. `cursor` goes alone. `before` and `after` set id bounds and can go together. None of the three goes with `page`, and without `page` only `sortBy` `id` works.
3. `limit` goes up to 1,000, the default. `page` starts at 1, and `page` × `limit` stays at or under 500,000. `sortBy` takes `id`, `created`, `updated`, `recent_action` or `none`, with `sortDirection` `asc` or `desc`, and defaults to `id` `desc`. `created` and `none` return id order, as the index holds no creation time. `updated` and `recent_action` sort by the newest slot that wrote the asset.
4. In a list answer, `total` counts the items on this page. `showGrandTotal` adds `grand_total`, the full count, on the `getAssetsBy*` lists and `searchAssets`, but not on one that includes fungibles; `getTokenAccounts` and `getNftEditions` carry none. `cursor` is the last item's id. It is absent on an empty page, in page mode (the answer carries `page`) and when you paged by `before` or `after`. `last_indexed_slot` is the newest finalized slot the index holds.
5. `getAssets` and `getAssetBatch` are one call. They take at most 1,000 `ids`, repeats allowed, and return a positional array with `null` where an id is not held. An id that is not a valid address refuses the whole call with `-32602` `Pubkey Validation Err: <v> is invalid`.
6. Batch DAS calls only with each other. A DAS batch answers HTTP 200 with an array in request order, each element with its own `id` and its own result or error. A batch takes all its cells at once, one per call plus one for each 4 KB of body past the first, so a full batch of 100 calls fits the 150-cell burst. It holds one place in flight, and its calls run one after another under one 5 s limit. A call still waiting at the limit comes back as `-32011` `das upstream timed out`, uncharged: send it again. A batch that mixes DAS with any other served method gets 400 `-32602` `this method is not batchable`, and a batch that holds an unknown name, a proof or signature method included, gets one 200 `-32601` `method not found` for the whole batch.
7. `getAssetsByGroup` does not read `groupKey`: `groupValue` names a collection whatever the key says. The same holds for a `searchAssets` `grouping` in any of its forms: `["collection", v]`, `{"collection": v}` or `{"group_key": k, "group_value": v}`.
8. `searchAssets` serves `ownerAddress`, `creatorAddress` with `creatorVerified`, `authorityAddress`, `grouping`, `interface`, `tokenType`, `frozen`, `delegate` and `burnt`. `tokenType` needs `ownerAddress` beside it and goes with neither `interface` nor `compressed`. `delegate` needs `ownerAddress` or `grouping`. Every other filter is refused by name with `-32602` ``this index does not serve the `<name>` filter``: `negate` (other than `false`), `conditionType` (other than `"all"`), `ownerType`, `supply`, `supplyMint`, `compressible`, `royaltyTargetType`, `royaltyTarget`, `royaltyAmount`, `jsonUri`, `not`, `name`, `collections`, `createdAt`, `collectionNft`, `isAgent`, `agentToken` and `assetSigner`. Apply those on your side.
9. A `searchAssets` with no `ownerAddress`, `authorityAddress`, `creatorAddress` or `grouping` reaches its first 10,000 items by `page`; go on by `cursor`. It also refuses `showGrandTotal`, `sortBy` `updated` or `recent_action`, `burnt: true` and `interface` `MplCoreGroup`. Name one of the four to use them.
10. `showNativeBalance` on `getAssetsByOwner`, and on `searchAssets` with `ownerAddress`, adds `nativeBalance: {"lamports": <balance>}`, with no `price_per_sol` or `total_price`. When the balance read takes more than 1 s, or a batch's 5 s limit runs out first, the answer comes without it. `showFungible` (getAssetsByOwner only; on searchAssets use `tokenType`), `showZeroBalance`, `showCollectionMetadata` and `showGrandTotal` change the answer, and `showUnverifiedCollections` adds `verified: true` to each grouping. `showRawData`, `requireFullIndex`, `showSystemMetadata`, `showClosedAccounts` and `showInscription` are accepted and change nothing.
11. `getTokenAccounts` takes `owner`, `mint` or both, sorts by account address, and its `cursor` is the last account's address. With `mint` alone it lists any number of holders by `cursor`, and `page` reaches the first 10,000. An owner with more than 10,000 token accounts is refused with `-32012`, and so is a fungible list of that owner (`showFungible`, or `searchAssets` `tokenType` `all` or `fungible`). Name both an owner and a mint instead.
12. `getNftEditions` takes `mint`, `limit` and `page` only, and sorts by edition number. A `cursor` is refused as an unknown field, so page by `page`. `max_supply` is `null` when the supply is unlimited.

### Limits

Each DAS call costs 1 credit and 1 cell, plus 1 cell for each 4 KB of body past the first, at 3 / 15 / 75 / 150 req/s (FREE / DEV / BUSINESS / PRO), counted per account, so all of an account's keys share one bucket, with a 150-cell burst on every plan. Each key holds 1 / 2 / 4 / 8 DAS calls in flight (FREE / DEV / BUSINESS / PRO), and a batch holds one place. A call over the rate waits for its turn when that comes within 1 s, and a call with no place in flight waits up to 3 s. One still not admitted gets 429.

| Size or time | Limit |
|---|---|
| Request body | 50 KB |
| Batch | 100 calls |
| `limit` | 1,000, also the default |
| `ids` on getAssets and getAssetBatch | 1,000 |
| `page` × `limit` | 500,000; 10,000 on a searchAssets with no owner, creator, authority or grouping, and on getTokenAccounts by mint |
| Token accounts per owner | 10,000 |
| Answer | 8 MiB per call, or per whole batch |
| Time | 5 s per call, and one 5 s limit for a whole batch |

### Billing

Each served call costs 1 credit, and each served element of a batch costs 1, so a batch of three costs 3. These cost nothing: an error answer, a batch element that fails, times out or goes over the answer cap, a call refused before it runs (key, rate, credits, size) and the `nativeBalance` read. Every admitted call spends its rate cell, one that ends in an error included.

### Coverage

The index holds:
- Token Metadata NFTs (`V1_NFT`), programmable NFTs (`ProgrammableNFT`), fungibles (`FungibleToken`, `FungibleAsset`), Core assets, collections and groups (`MplCoreAsset`, `MplCoreCollection`, `MplCoreGroup`), and mints with no metadata account (`Custom`), on SPL Token and Token-2022, the Token-2022 metadata extension included. Mint extensions appear in `mint_extensions`.
- For Core: plugins, external plugins, `mpl_core_info` (`num_minted`, `current_size`), parent groups and `asset_signer`.
- Editions. A master reports its print supply and maximum, and a print its `edition_number` and `master_edition_mint`.
- Burnt assets. `getAsset` answers a burnt asset that has a metadata account with `burnt: true`, and a burnt mint with none answers not found. The `getAssetsBy*` lists leave burnt assets out, except burnt Core assets. `searchAssets` lists them unless `burnt` picks one side, except a token NFT burnt before the index began with no holder seen, which it never lists.
- Mints with no metadata account. `getAsset` answers one with an empty `content`, as `Custom`, or as `FungibleToken` or `FungibleAsset` for a fungible mint. It appears in lists only among an owner's held fungibles. It shows the supply, decimals and extensions on chain. `getAsset` answers its `ownership.owner` as `""`, and an owner's held-fungibles list shows that owner and the state of their account.

The index does not hold:
- Compressed NFTs. They are absent from every answer. `compressed: true`, `tree` (with `ownerAddress` or `grouping`) and `tokenType` `compressedNft` (with `ownerAddress`) answer an empty page. The proof and signature methods (`getAssetProof`, `getAssetProofBatch`, `getAssetProofs`, `getAssetSignatures`, `getSignaturesForAsset`) answer `-32601`.
- The off-chain JSON document. `content.json_uri` is its address only and is never fetched, so `content.files` is `[]`, `content.links` is `{}`, and `content.category` and the off-chain keys are absent. Fetch the document yourself when you need it.
- Prices. `token_info` carries no `price_info`.
- These fixed fields: `uses` is `null`, `royalty.target` is `null`, `royalty.locked` is `false`, and `compression` reads as uncompressed. A collection grouping appears only when the collection is verified. Plain list items leave out `mint_authority` and `freeze_authority`, which `getAsset` carries.
- On `searchAssets`, `interface` `V1_PRINT` or `LEGACY_NFT` matches nothing.

### Errors

Errors from the index come with HTTP 200 and their own code. A call refused before it runs comes with its own HTTP status. Decide by the code: the message can carry your own values, and an index error that arrives with no message reads `das upstream refused the request` under the same code.

| HTTP | Code | Message | What to do |
|---|---|---|---|
| 200 | `-32000` | `Database Error: RecordNotFound Error: Asset Not Found` | The index holds no such asset (getAsset) or no such master edition (getNftEditions). Do not retry at once. |
| 401, 403 | `-32001` | the key messages | Fix the key, its scope or the calling address. Do not retry. |
| 402 | `-32002` | `credits exhausted` | Buy a plan or upgrade. Do not retry. |
| 429 | `-32005` | `rate limit exceeded` (`RATE_LIMITED`) | Wait `retry-after-ms`, then retry. Lower your rate if it repeats. |
| 429 | `-32005` | `DAS lane capacity exceeded: das_lane` (`SLOT_CAP_EXCEEDED`) | Too many calls in flight. Wait `retry-after-ms`, retry, and send fewer at once. |
| 502 | `-32011` | `das upstream unreachable`, `das upstream error`, `das upstream read failed` | Retry with backoff. |
| 502 | `-32011` | `das upstream response too large` | The answer is over 8 MiB. Ask for a smaller `limit` or fewer `ids`, or split the batch. Do not resend it unchanged. |
| 503 | `-32011` | `compat verbs not initialised` | Retry with backoff a few times, then stop. |
| 504, or 200 inside a batch | `-32011` | `das upstream timed out` | No answer within 5 s. Retry. For a list, ask for a smaller `limit`. In a batch, send that element again. |
| 200 | `-32012` | `token accounts refused: the subject holds more than the hot store's 10000-account cap; name an owner and a mint` | Name both an owner and a mint. Do not retry. |
| 200 | `-32012` | `showFungible refused: the owner holds more than the hot store's 10000 token accounts; list without it` | On getAssetsByOwner, list without `showFungible`. On searchAssets, ask for `tokenType` `nonFungible`. |
| 200 | `-32021` | `index is behind the chain, retry` | The index trails the chain by more than 32 slots. Retry with backoff. |
| 200 | `-32022` | `index is repairing a gap, retry later` | Retry later with long waits. Do not loop. |
| 200 | `-32023` | `index is not built yet` | Retry later. |
| 200 | `-32024` | `token accounts refused: the hot store deferred the read; retry` | Retry with backoff. |
| 200 | `-32026` | `index is busy, retry`, `hot store is busy, retry` | Retry with jittered backoff. |
| 413 | `-32600` | `request body exceeds the byte cap` | The body is over 50 KB. Split it. |
| 400 | `-32600` | `batch exceeds the cardinality cap` | The batch has more than 100 calls. Split it. |
| 400 | `-32600` | `malformed json-rpc body`, `duplicate method key`, `params before method`, `method beyond position cap` | Fix the body. Put `"method"` before `"params"`, within the first 1 KB. |
| 200 | `-32601` | `method not found` | The method name is unknown, the proof and signature methods included. Do not retry. |
| 400 | `-32602` | `this method is not batchable` | Batch DAS calls only with DAS calls. |
| 200 | `-32602` | `missing field ...`, `unknown field ..., expected one of ...`, `invalid type: ...`, `invalid value: ...`, `unknown variant ...`, `Pubkey Validation Err: <v> is invalid`, `Validation Error: Invalid pubkey <v>`, `Cursor Validation Err: <v> is invalid`, `invalid params: ...`, `Validation Error: Must provide either 'owner' or 'mint'`, `Validation Error: Must provide 'mint'` | Fix the params. Do not retry. |
| 200 | `-32602` | `Pagination Error. Limit should not be greater than 1000.`, `Pagination Error. Only one pagination parameter supported per query.`, `Pagination Error. No Pagination Method Selected.` (`page: 0`), `Pagination Sorting Error. Only sorting based on id is supported for this pagination option.`, `Batch Size Error. Batch size should not be greater than 1000.`, `Paginating beyond 500000 items is not supported. ...`, `Paginating beyond 10000 items of a search with no ... is not supported. ...`, `Paginating beyond 10000 token accounts of a mint is not supported. ...` | Fix the paging. Past a window, go on by `cursor`. |
| 200 | `-32602` | ``this index does not serve the `<name>` filter``, ``this index serves the `delegate` filter only with `ownerAddress` or `grouping` ``, ``this index serves <what> on searchAssets only with `ownerAddress`, `authorityAddress`, `creatorAddress` or `grouping` ``, and the `token_type` and `tree` validation errors | Drop the filter and apply it on your side, or name an owner, creator, authority or grouping. |
| 200 | `-32603` | `the index could not finish this read in time` | Narrow the request with a smaller `limit` or a named owner, creator, authority or grouping, then send it. |
| 200 | `-32603` | `Internal error`, `das upstream refused the request` | Retry with backoff a few times, then stop. |
| 200 | `-32700` | `Parse error` | Send valid JSON-RPC 2.0: an object or array, `"jsonrpc": "2.0"`, an `id`, and params as an object or array. |

### Quick start

```bash
URL="https://services.carbium.sh"   # CARBIUM_KEY holds the full raw key
# one asset
curl -s "$URL" -H 'content-type: application/json' -H "x-api-key: $CARBIUM_KEY" \
  -d '{"jsonrpc":"2.0","id":1,"method":"getAsset","params":{"id":"<ASSET_ID>"}}'

# a wallet's assets, page by page
curl -s "$URL" -H 'content-type: application/json' -H "x-api-key: $CARBIUM_KEY" \
  -d '{"jsonrpc":"2.0","id":1,"method":"getAssetsByOwner","params":{"ownerAddress":"<OWNER>","limit":1000}}'
# next page: the same body plus "cursor":"<result.cursor>"; stop at a page of fewer than 1000 items

# a search anchored on an owner
curl -s "$URL" -H 'content-type: application/json' -H "x-api-key: $CARBIUM_KEY" \
  -d '{"jsonrpc":"2.0","id":1,"method":"searchAssets","params":{"ownerAddress":"<OWNER>","tokenType":"nonFungible","limit":100}}'

# every holder of a token, page by page
curl -s "$URL" -H 'content-type: application/json' -H "x-api-key: $CARBIUM_KEY" \
  -d '{"jsonrpc":"2.0","id":1,"method":"getTokenAccounts","params":{"mint":"<MINT>","limit":1000}}'
# next page: the same body plus "cursor":"<result.cursor>"

# a DAS batch of two: HTTP 200, an array in request order
curl -s "$URL" -H 'content-type: application/json' -H "x-api-key: $CARBIUM_KEY" \
  -d '[{"jsonrpc":"2.0","id":1,"method":"getAsset","params":{"id":"<ASSET_ID>"}},
       {"jsonrpc":"2.0","id":2,"method":"getAssetsByGroup","params":{"groupKey":"collection","groupValue":"<COLLECTION>","limit":10}}]'
```

### A client with retries (Node 18+, global fetch)

```js
// carbium-das.mjs
const URL = "https://services.carbium.sh";
const KEY = process.env.CARBIUM_KEY; // full raw key

// Codes that waiting can fix. -32022 and -32023 need a later run: do not loop on them. Every other code is final, and so are
// two messages that ask for a smaller request.
const RETRY = new Set([-32005, -32011, -32021, -32024, -32026, -32603]);
const LATER = new Set([-32022, -32023]);
const NARROW = new Set(["das upstream response too large", "the index could not finish this read in time"]);
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

export class DasError extends Error {
  constructor(status, e) {
    super(`HTTP ${status} ${e?.code} ${e?.message}`);
    Object.assign(this, { status, code: e?.code, later: LATER.has(e?.code) });
  }
}

export async function das(method, params, { maxAttempts = 4 } = {}) {
  const body = JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }); // method before params
  for (let attempt = 1; ; attempt++) {
    const res = await fetch(URL, { method: "POST", headers: { "content-type": "application/json", "x-api-key": KEY }, body });
    const j = await res.json().catch(() => ({ error: { code: -32700, message: `HTTP ${res.status}, non-JSON body` } }));
    if (!j.error) return j.result;
    const e = j.error;
    const retry = RETRY.has(e.code) && !NARROW.has(e.message);
    if (!retry || attempt >= maxAttempts) throw new DasError(res.status, e);
    const hint = Number(res.headers.get("retry-after-ms")) || Number(res.headers.get("retry-after")) * 1000 || 0;
    await sleep(Math.max(hint, Math.min(250 * 2 ** (attempt - 1), 4000)) + Math.random() * 250);
  }
}

// Every item of a list, by cursor. getTokenAccounts answers token_accounts; the other lists answer items.
export async function* walk(method, params, limit = 1000) {
  let cursor;
  for (;;) {
    const r = await das(method, { ...params, limit, ...(cursor && { cursor }) });
    const rows = r.items ?? r.token_accounts;
    yield* rows;
    if (rows.length < limit || !r.cursor) return;
    cursor = r.cursor;
  }
}

// examples
const asset = await das("getAsset", { id: "<ASSET_ID>" });
for await (const a of walk("getAssetsByOwner", { ownerAddress: "<OWNER>" })) console.log(a.id, a.interface);
let holders = 0;
for await (const t of walk("getTokenAccounts", { mint: "<MINT>" })) if (t.amount > 0) holders++;
```

### How we test it

1. Pick real subjects of every kind the index holds: Token Metadata NFTs, programmable NFTs, master and print editions, Core assets and collections, Token-2022 mints with extensions, and fungibles. Add wallets, creators, authorities and collections to list. Our two sets hold 1,251 requests across the ten methods, naming 1,000 assets, and 167 collection requests, with paging, display options and bad inputs.
2. Send every request to the reference DAS API once, one call at a time, and keep the answers.
3. Send the same bodies to `https://services.carbium.sh`, one call at a time. Compare every field exactly by its JSON path, leaving out `last_indexed_slot` and `price_info` on both sides. Compare lists as the set of ids (`address` for token accounts, `mint` for editions) and their order. Compare errors by code, and by message with your own values cut out.
4. Set aside the fields of the off-chain document behind `json_uri`, since the index does not fetch it. For any other difference, read the account on chain at `finalized` to see which answer the chain holds.
5. Walk whole collections with `getAssetsByGroup` (`limit` 1000, `sortBy` id ascending) on both sides. Then ask for each collection's hashlist by id through `getAssetBatch`, 1,000 ids at a time, and compare the id sets. An id only the reference returns should be one it marks `burnt: true`.
6. Walk every holder of a token with `getTokenAccounts` by `mint` and `cursor`, on both sides. Read any account found on one side only with `getMultipleAccounts` at `finalized`. It should be closed or empty.
7. Send the exact bodies the Metaplex Umi DAS plugin 2.1.1 and the Helius SDK 3.5.0 send, the request bodies from the reference docs, 21 bad inputs and a batch. Compare HTTP status, error code and message, answer shape and row count.
8. Compare `last_indexed_slot` with `getSlot` at `finalized`, many times over, to see how far the index trails the chain.

Results, measured 2026-11-21:
- 10,382 of 10,386 compared assets (99.96%) equal on every on-chain field.
- Every live asset found and none extra across three Core collections walked whole (5,561, 2,222 and 374 assets) and a 6,202-asset hashlist asked by id.
- Every holder with a balance returned once, for a token with more than 11,500 token accounts.
- The same status, code, message and answer shape on every request form of the ten methods, with `nativeBalance` in lamports.
- The index within 16 slots of the finalized chain on 99.99% of 101,252 readings over six hours.

### Common mistakes

- Paging deep with `page`. Past 500,000 items it is refused, and past 10,000 on an unanchored searchAssets or on a mint's token accounts. Walk by `cursor`.
- Reading `total` as the full count. It counts this page only. Ask for `showGrandTotal`.
- Expecting images, attributes, `content.files` or `content.links` from the off-chain JSON. Fetch `content.json_uri` yourself.
- Sorting by `created` and expecting creation order. It returns id order.
- Mixing DAS and other RPC methods in one batch.
- Using the Umi DAS plugin without `heliusCompatibility: true`.
- Retrying a `-32602`, or looping on `-32022`.
- Sending more calls at once than the plan's in-flight cap allows. Queue them per key.

### Agent checklist

- Call `https://services.carbium.sh` with the full key in `x-api-key` or `?api-key=`.
- Send the Helius field names, and put `"method"` before `"params"`.
- Walk lists by `cursor` with `limit` 1000 until a page comes back short.
- Keep calls in flight per key within your plan; a batch counts as one. Batch DAS calls only with each other, up to 100 a batch.
- Retry `-32005`, `-32011`, `-32021`, `-32024`, `-32026` and `-32603` with jittered backoff, and honour `retry-after-ms`; narrow the request instead on `response too large` and `could not finish this read in time`. Retry `-32022` and `-32023` later. Stop on every other code.
- Apply unserved `searchAssets` filters on your side. Name an owner, creator, authority or grouping before you use `showGrandTotal`, `burnt: true`, `interface` `MplCoreGroup` or the `updated` and `recent_action` sorts.
- Fetch off-chain JSON yourself, and expect no prices and no compressed NFTs.
- Budget 1 credit per served call.

## Cross-plane: key states, credits, limits, retry

### Key states (all `-32001`; `error.data.reason` names the state)

| Message (exact) | HTTP (RPC/quote) | WS handshake | gRPC status | reason | What to do |
|---|---|---|---|---|---|
| `unknown api key` | 401 | 401 | UNAUTHENTICATED | `UNKNOWN_KEY` | Fix the carrier or send the whole key. A rotated key is unknown. Do not retry. |
| `api key suspended: the plan term ended; renew on the dashboard` | 401 | 401 | UNAUTHENTICATED | `KEY_SUSPENDED` (+`status_reason:"term_ended"`) | Rare: a key issued after a paid term ended, before the account moved to Free. Renew on the dashboard; once the account is on Free, its keys work at Free limits. |
| `api key suspended; contact support` | 401 | 401 | UNAUTHENTICATED | `KEY_SUSPENDED` | Stop and contact support. |
| `api key revoked` | 401 | 401 | UNAUTHENTICATED | `KEY_REVOKED` | The key was revoked or deleted. Stop and issue a new key. |
| `api key disabled; contact support` | 401 | 401 | UNAUTHENTICATED | `KEY_BANNED` | Stop and contact support. |
| `api key is not enabled for rpc` / `websocket` / `grpc` / `quote` / `das` | 401 | **403** (websocket) | UNAUTHENTICATED | `SCOPE_RPC_MISSING` / `SCOPE_WS_MISSING` / `SCOPE_GRPC_MISSING` / `SCOPE_QUOTE_MISSING` / `SCOPE_DAS_MISSING` | Add the scope to the key on the dashboard. |
| `client ip address is not on this api key's allowlist; add it on the dashboard or with PATCH /v1/keys/{id}/allowlist` | **403** | **403** | PERMISSION_DENIED | `IP_NOT_ALLOWED` | Call from an address on the key's IP allowlist, or add this one (up to 16 addresses or CIDRs; an empty list admits any address). |
| `session expired` | 401 | 401 | UNAUTHENTICATED | `EXPIRED_SESSION` | Dashboard session tokens only: sign in again. |
| `missing api key` (WS only) | n/a | 401 | n/a | n/a | Attach a carrier. |
| `streaming is not included in this tier; upgrade the plan` | n/a | n/a | PERMISSION_DENIED | n/a | FREE has no gRPC stream. Upgrade the plan. |

A key that is revoked, rotated, suspended or banned, or whose account is deleted, also ends its open connections within about 2 s: a WebSocket closes with `1008 key_revoked`, `key_suspended` or `key_banned`, and a Carbon stream ends UNAUTHENTICATED with the message above (a rotated key's stream reads `api key revoked`).

Scopes are per key: `rpc`, `ws`, `grpc`, `quote`, `das`. Change them on the dashboard. The 10 DAS methods need `das`, which a new key has unless you leave it out. Quote-plane verbs need only `quote` and are never batched. The account must also hold the quote module, or calls get 403 `-32050 "module not enabled for this account"`.

RPC body shape: `{"jsonrpc":"2.0","id":<your id>,"error":{"code":-32001,"message":"unknown api key","data":{"reason":"UNKNOWN_KEY","retryable":false}}}`. `error.data.retryable` is true exactly for the pressure band (429). A reply to an admitted call carries `x-request-id`; quote it to support. The WS handshake refusal body is `{"error":{"message":"..."}}`, not JSON-RPC.

### Credits

- `402`, `-32002`, `"credits exhausted"`, reason `CREDITS_EXHAUSTED`, `retryable:false`, `Retry-After: 1`. A 402 means the account's remaining credits cannot cover the call. On WS the handshake does not check credits: a subscribe answers `-32002` inside the socket, and a live socket whose streamed bytes cannot be paid closes with **1008 `credits_exhausted`**. On gRPC it is `RESOURCE_EXHAUSTED` `credits exhausted` (`consumer_credits_exhausted` on an open stream): do not retry. On RPC and WS do not retry either (after a 1008 close, reconnect once after about 5 s): buy a plan or upgrade on the dashboard (each month of an RPC plan adds its credits; a Quote plan adds none). Near the end of a balance a node can answer 402 while the last credits sit reserved at other nodes; they return within minutes.
- `429`, `-32005`, `"credits for this account are still loading on this node; retry after Retry-After"`, reason `CREDITS_PENDING`, `retryable:true`, `Retry-After: 1`, `retry-after-ms: 1000`. The account has credits, but this node has not loaded them yet (a new account's first calls, a burst that spent this node's share, or just after a node restart). It is not a 402: wait and send it again. On WS it is a subscribe reply `-32005` with `data.retryAfterMs` 1000, and the socket stays open; on gRPC it is `RESOURCE_EXHAUSTED` with that message and `retry-after: 1`. A live stream can end on it too: a WS socket closes `1013 credits_pending` (reconnect after about 1 s and re-subscribe), and a gRPC stream ends `UNAVAILABLE` with that message and `retry-after: 1` (resubscribe after it); the bytes already sent are billed.
- Refused calls cost 0 credits, except a getTransactionsForAddress walk refused after it made upstream calls, which bills those calls, and a failed preflight send, which keeps its 75 credits.
- What spends credits:
  - **RPC**: each method's credits, in the Credits column of the [RPC method catalogue](https://carbium.sh/skill/rpc.md). Token scans also bill per row returned, and a getTransactionsForAddress walk per upstream call it makes, as their catalogue rows show.
  - **WS and gRPC**: 5 per slot/root/signature subscription, 25 per account/logs-mentions/slotsUpdates subscription (gRPC: an `accounts` filter with an `account` list, or a `transactions` filter narrowed by account), 200 per program/logs-all/block subscription (gRPC: an `accounts` filter with `owner`, `blocks`, `blocksMeta`, `entry` or a transaction firehose), plus 20 per MiB delivered. A gRPC stream that delivers no data books 0 credits.
  - **Quote plane**: 0 credits; calls count against the account's quote plan. They are answered even when the account's credits are spent: a call that costs 0 credits is never refused for credits.

### Rate limits

Rates are per account (all its keys share one bucket), in cells per second; every method's cells and the plan rates are in the [RPC method catalogue](https://carbium.sh/skill/rpc.md). On RPC and the quote plane, a call over its plan rate that fits within 1 s waits and is served, and a call short of a concurrency slot waits up to 3 s for one; only then comes the 429. WebSocket and gRPC refuse at once. A 429 has `-32005` and one of these messages: `rate limit exceeded` (`RATE_LIMITED`), `heavy-class rate limit exceeded` (`HEAVY_CLASS_LIMITED`), `blocking-slot capacity exceeded: <pool> pool`, `scan-index lane capacity exceeded: chot_lane`, `DAS lane capacity exceeded: das_lane`, `quote lane capacity exceeded: quote_lane` or `free quote plan at capacity: ...` (`SLOT_CAP_EXCEEDED`), `overloaded` (`LOAD_SHED`), or, on the Free plan and the free quote plan, `free tier limit for your network reached: ...` (`FREE_SUBNET_LIMITED`: all free keys calling from one network share one budget) and `free tier at capacity on this node: ...` (`FREE_TIER_BUSY`), and `credits for this account are still loading on this node; retry after Retry-After` (`CREDITS_PENDING`: the node has not loaded the account's credits yet, as on a new account's first calls, after a burst that spent this node's share, or just after a node restart). The one 429 with another code is `-32010` `scan index temporarily unavailable, retry` (`CHOT_INDEX_UNAVAILABLE`). Every 429 on RPC and the quote plane carries `Retry-After` in whole seconds and `retry-after-ms`, which is exact; prefer the ms header (a browser can read only `Retry-After`). On gRPC the status is `RESOURCE_EXHAUSTED` with `retry-after` metadata in seconds. On a WS handshake it is 429 with `Retry-After`, and the messages include `connection or subscription cap exceeded` and `overloaded or draining`.

### One retry and backoff policy (all planes)

Backoff means: wait the larger of the server's hint (`retry-after-ms`, else `Retry-After` × 1000) and `250 ms × 2^(attempt−1)` capped at 4 s, plus 0 to 250 ms of random jitter. Never cut a server hint to 4 s. Stop after 4 attempts unless the row says otherwise.

| Error class | Where | Retry? | How | When to stop |
|---|---|---|---|---|
| 400 / -32600 / -32602 (malformed, bad params, batch refused, body over 50 KB with HTTP 413) | RPC, quote, swap, prices | No (getTransactionsForAddress's `-32602` `the walk read no history`: yes, as a 429) | Fix the request. | Immediately. |
| -32601 `method not found` / `method not served` (HTTP 200) | RPC | No | Use a served method. | Immediately. |
| 401 / -32001, 403 / -32001 `IP_NOT_ALLOWED`, WS 401/403, gRPC UNAUTHENTICATED | all | No | Fix or renew the key, add the scope, or call from an allowed address. | Immediately. |
| 403 / -32050 `module not enabled for this account` | quote, swap, prices, health | No | Add it with `POST https://carbium.sh/v1/modules/quote`, your session or a Full control account API key, and the JSON body `{"plan": "free"}` (the free plan), or on the dashboard's MODULES page. | Immediately. |
| gRPC PERMISSION_DENIED | gRPC | No | Act on the message (see the [gRPC error table](https://carbium.sh/skill/stream.md)): `streaming is not included in this tier` means upgrade the plan, the allowlist message means call from a listed address, and the rest mean fix the filter or the request. | Immediately. |
| 402 / -32002, WS subscribe `-32002` | RPC, WS | No | Buy a plan or upgrade. | Immediately. |
| WS close 1008 `credits_exhausted` | WS | Once | Reconnect once after about 5 s and re-subscribe; if the subscribes answer `-32002`, buy a plan or upgrade; if they answer `-32005` `CREDITS_PENDING`, wait `retryAfterMs` and resend. | After that one reconnect. |
| WS close 1013 `credits_pending`, gRPC UNAVAILABLE `credits for this account are still loading on this node; retry after Retry-After` | WS, gRPC | Yes | Reconnect after about 1 s (gRPC: after the `retry-after`) and re-subscribe; do not buy anything. | Back off after 3 failed reconnects. |
| gRPC RESOURCE_EXHAUSTED `credits exhausted` / `consumer_credits_exhausted` | gRPC | No | Buy a plan or upgrade. | Immediately. |
| 429 / -32005 (including the Free network limits and, on calls that cost credits, `CREDITS_PENDING`), gRPC RESOURCE_EXHAUSTED (rate, or `credits for this account are still loading on this node; retry after Retry-After`) | all | Yes | Back off, honouring `retry-after-ms`. Lower concurrency (quote: at most 8 in flight per key). | 4 attempts, then lower your request rate. |
| 429 / -32010 `CHOT_INDEX_UNAVAILABLE` (scan index behind) | RPC scans | Yes | Back off from 100 ms (100, 200, 400 ... capped at 5 s), honouring `retry-after-ms`. | About 6 tries, then surface the error. |
| 503 / -32011 and other 503s (breaker, upstream down, `cooling down`, `stale`) | RPC, quote, swap, prices | Yes | Back off, honouring `Retry-After`. | 4 attempts. For a `swap` call, quote again if more than 30 s have passed since the quote. |
| 504 (scan over its deadline) | RPC | Yes, once | Narrow the request. | 1 retry. |
| Network error or timeout, no response | all | Yes | Back off. | 4 attempts. A `sendTransaction` with no response may have landed: check the signature status before sending again. |
| 200 / -32051 `no route`, -32054 | quote | No (see the [why table](https://carbium.sh/skill/quote.md)) | Change the pair or size, or wait the named window. | Do not loop faster than every 30 s. |
| 200 / -32055 | quote, swap | Only with a changed ask | Raise `maxAccounts` (at most 64), lower `amount_in`, or quote without `maxAccounts` and `swapTag`. | Once per change. |
| 200 / -32053 | quote | Only with a much smaller amount | The engine already tried the part under `error.data.max_amount_in`: quote again well under it. | If `why` is `partial_below_fee`, or `max_amount_in` is 0, stop. |
| 400 / -32095, -32074; 200 / -32081, -32082, -32083, -32096; 200 / -32093 | swap | Quote again | Get a new `quote`, then `swap`. | 3 rounds. |
| 200 / -32098 | swap | No | The wallet must hold `gate_min` of `gate_mint`. | Immediately. |
| 200 / -32099 | swap | No | Stop for this token. | Immediately. |
| On-chain `Custom:6004` (under the slippage floor) | after send | Quote again | `quote`, `swap`, sign, send again. | 3 rounds. |
| On-chain, any other `Custom` code | after send | No | It is the venue's own error (see [Signing, sending and confirming](https://carbium.sh/skill/quote.md)). | Immediately. |
| Blockhash expired (block height > `lastValidBlockHeight`, not landed) | after send | Quote again | Never re-sign the old message. | 3 rounds. |
| WS close 1013 `slow_consumer` / `delivery_overload_retry` | WS | Yes | Reconnect with backoff, read faster, subscribe to less. | Back off further after 3 closes in a row. |
| WS close 1012 `draining` / `stream_gap_reseed_required` | WS | Yes | Reconnect at once with jitter and re-subscribe everything; re-read state you may have missed. | Back off after 3 failed reconnects. |
| WS close 1001 `idle_timeout` (900 s idle) / `no_pong` (300 s without a pong) | WS | Yes | Reconnect. Answer server pings (sent every 30 s); a pong counts as traffic. | Fix the client. |
| gRPC RESOURCE_EXHAUSTED `consumer_lagged: your stream fell behind the ring; reduce filters or read faster` | gRPC | Yes | Wait `retry-after` (2 s); reduce filters. | Back off after 3 in a row. |
| gRPC UNAVAILABLE / DEADLINE_EXCEEDED | gRPC | Yes | Back off and resubscribe. | 4 attempts, then 30 s waits. |
| gRPC OUT_OF_RANGE `gap: re-seed required` (`fromSlot` too old, or a gap in the upstream feed) | gRPC | Yes, after a re-seed | Reload state over RPC, then resubscribe with no `fromSlot` (or with `fromSlot >= firstAvailable`). | Back off after 3 in a row. |
| gRPC INVALID_ARGUMENT | gRPC | No | Fix the request. | Immediately. |

## Common mistakes

- The short dashboard prefix (`c_serv_` plus four characters) instead of the whole key.
- `x-api-key` on the gRPC stream: it reads metadata `x-token` (or `authorization: Bearer`).
- A FREE key on the gRPC stream: not a wrong key, FREE has no stream (`PERMISSION_DENIED` `streaming is not included in this tier; upgrade the plan`).
- `"params"` before `"method"`, or a third permit method in one batch.
- `maxSupportedTransactionVersion` absent or 0 on `getTransaction`, `getBlock` or `blockSubscribe`.
- Retrying a 4xx unchanged, or re-signing a transaction that may still land.
- Calling RPC methods over the WebSocket: they answer `-32601`.
- Expecting `accountSubscribe`, or a gRPC `accounts` list, to stream a plain SOL wallet.
- Other providers' quote params (`inputMint`, `outputMint`, `amount`, `onlyDirectRoutes`): this quote takes `src_mint`, `dst_mint`, `amount_in`, `slippage_bps`, an optional `dex` (or `dexes`), an optional `txVersion`, an optional `swapTag`, an optional `maxAccounts` and an optional `integrator_fee_bps` with `integrator_fee_account` (or `fee_bps` with `treasury`), and refuses any other name.


## Testing

Every call reaches Solana mainnet. A transaction you sign and send moves real funds.

- **Is it up, with no key:** `GET https://services.carbium.sh/livez` answers 204. The stream's `grpc.health.v1.Health/Check` answers `SERVING`.
- **First call with a key:** `getHealth` or `getSlot`, 1 credit each.
- **The quote API costs 0 credits.** `quote`, `swap` and `prices` count against the quote plan's rate (on the free quote plan also against the shared budget below), and `health` against the account's cached-read rate. `quote` builds nothing and moves nothing. `swap` returns an unsigned transaction: nothing happens until a wallet signs and sends it.
- **The free plan is enough for a test:** one free grant of credits, once (`GET /v1/balance` shows `granted`), 1 key, 5 cached reads a second, 3 DAS calls a second, 5 WebSocket connections and 10 subscriptions. The carbon stream and webhooks need the DEV, BUSINESS or PRO plan. `POST /v1/webhooks/{id}/test` sends one signed test delivery, billed as one event when it is delivered.
- **In tests and CI:** one account, one key held as a secret, a slow steady rate well under the plan's limit. Free callers on one network share 20 requests a second.
- **Never probe, scan or load test the service without written consent** ([Terms](https://carbium.sh/terms), 6.7). To time it, use the capped run on the [benchmark page](https://carbium.sh/benchmark.html). A free account refused for rate in most hours of a day is suspended.
- A refused call costs 0 credits and still spends rate: never loop on a 4xx. Two refusals do bill: a `getTransactionsForAddress` walk refused after it made upstream calls, and a send whose preflight failed.

## Support

Write to support@carbium.sh. Send the `x-request-id` of the answer you are asking about when it has one (the `x-subscription-id` for the carbon stream), the UTC time and the method. For a payment, send its `id` from `GET /v1/payments`, and for USDC or USDT also the transaction signature. Never send a raw API key: send its dashboard prefix (`c_serv_` plus four characters). Security reports: [security.txt](https://carbium.sh/.well-known/security.txt).
