Solana WebSocket and webhook APIs

Carbium RPC pushes Solana data to you two ways: WebSocket subscriptions on every plan, and signed webhooks to your own HTTPS address from Dev at $20 a month. Start with the choice: polling, a socket, a webhook or Carbon Stream.

WebSocket

8 methods

Subscribe to slots, accounts, programs, logs, signatures and blocks

Webhooks

1 credit

Per delivered event. Failed tries and setup calls are free

On Free

5 sockets

WebSocket is on every plan, from $0. Webhooks start on Dev

01 · Choose

Polling, WebSocket, webhook or Carbon Stream?

All four tell your code that something happened on Solana. They differ in who starts the conversation, what has to stay running, and what happens while you are away.

One change on chain, four ways to hear of it: asked for, pushed down a socket, posted to your server, or streamed. Purple is Carbium RPC, red is Carbon Stream.
  • JSON-RPC over HTTPS

    Polling

    Your code asks on a timer and gets the state at that moment. Every poll is a request, whether anything changed or not.

    Carbium RPC
  • Subscriptions over WSS

    WebSocket

    You open one socket and Carbium RPC pushes each change down it while it stays open. After a drop nothing is replayed.

    How subscriptions work
  • Signed HTTPS POST

    Webhook

    Carbium calls you: a finalized transaction that touches an address you listed is posted to your server, and tried again if it does not answer.

    How webhooks work
  • Yellowstone gRPC

    Carbon Stream

    A filtered gRPC stream of whole transactions, accounts and slots, for services that read the chain all day. From the Dev plan, on the same key.

    Carbon Stream
A balance or a status on a page that people reload
One request when the page opens is enough. Poll only while someone is looking.
Polling
A screen that changes the moment the chain does
One socket, and a subscription for each account or address you show.
WebSocket
Knowing that the transaction you just sent has landed
signatureSubscribe before you send. It notifies once and ends itself.
WebSocket
Deposits or payments to addresses you own
Nothing to keep connected: a delivery your server misses is tried again for about 27 hours.
Webhook
Alerts for thousands of user wallets
One webhook watches up to 100,000 addresses on Pro. A socket takes a subscription for each.
Webhook
Every transaction of a program, in your own database
The whole transaction is pushed, filtered by the accounts you name, and a restart can resume from a recent slot. A socket filters on one address per subscription and replays nothing.
Carbon Stream
Most products use more than one: a webhook for what the backend must record, a socket for what the screen shows, a JSON-RPC read after a reconnect.

02 · WebSocket

WebSocket subscriptions on Carbium RPC

Solana's own subscription protocol on wss://services.carbium.sh, with the key you already use for JSON-RPC. web3.js, Kit and any WebSocket client connect by changing the URL.

slotSubscribe
Each new slot.
5
rootSubscribe
Each new root.
5
signatureSubscribe
One notification when a transaction reaches the commitment you asked for. Then it ends.
5
accountSubscribe
An account's state when it changes. Token accounts and accounts of the covered programs notify; a plain SOL wallet under 1,000,000 SOL stays silent.
25
logsSubscribe
The logs of every transaction, or of those that mention one address. Failed transactions are included.
25 with a mention, 200 for all
slotsUpdatesSubscribe
Each step of a slot's life.
25
programSubscribe
Account changes under a program, for a covered set: SPL Token, Token-2022 and the main pool programs among them.
200
blockSubscribe
Each new block, or only the blocks with a transaction that mentions one address.
200
Then 20 credits per MiB the socket sends you. A refused subscription costs nothing. Commitment is finalized unless you set it. Every option, error and close code: the WebSocket skill file.

Not served, and what to use instead

  • transactionSubscribe is not served. Use logsSubscribe with one address in mentions, or a Carbon Stream transaction filter.
  • A plain SOL wallet stays silent on accountSubscribe. Subscribe to its logs and read getBalance, as the example further down does.
  • programSubscribe outside the covered set answers -32010 and is not charged. Use logsSubscribe with the program as the mention.
  • JSON-RPC methods such as getSlot do not run over the socket. Send them over HTTPS.
subscribe.mjs
// One socket, one subscription: every new slot, pushed to you.
// Node 22 and browsers have WebSocket built in.
const url = "wss://services.carbium.sh/?api-key=" + process.env.CARBIUM_KEY;
const ws = new WebSocket(url);

ws.onopen = () =>
  ws.send(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "slotSubscribe" }));

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  if (msg.id === 1)
    return console.log("subscription", msg.result ?? msg.error);
  if (msg.method === "slotNotification")
    console.log("slot", msg.params.result.slot);
};

ws.onclose = (event) => console.log("closed", event.code, event.reason);
Run against the live service on 22 November 2026. From a browser, pass the key as a WebSocket subprotocol, api-key. followed by the key, and it stays out of the URL. Give a key that ships to a browser the WebSocket scope only.

03 · Reconnect

Keep a socket alive, and recover when it drops

A socket will drop: a deploy, a network change, a closed laptop. Subscriptions do not survive it and nothing is replayed, so a client has four jobs.

  1. Reconnect with backoff

    Start at half a second and double up to 30 seconds, with jitter. Stop on close code 1008: the key or the credits ran out while connected. A handshake refused at the start (the key, the connection cap or the rate) closes with 1006 before any open, so check the key and your open sockets if the first connect never opens.

  2. Subscribe again

    Subscription ids belong to one connection. Send every subscribe again and map the new ids.

  3. Read what you missed

    Read the state again over JSON-RPC, with getAccountInfo or getSignatureStatuses, before you trust new notifications.

  4. Read fast

    A socket whose queue fills is closed with 1013 slow_consumer. Do less per message, or split subscriptions over more sockets.

reconnect.mjs
// A socket that comes back: reconnect with backoff, subscribe again,
// and read over HTTPS what you missed. Nothing is replayed.
const URL = "wss://services.carbium.sh/?api-key=" + process.env.CARBIUM_KEY;
const WANT = [{ method: "slotSubscribe" }]; // every subscription you need
let wait = 500;

function connect() {
  const ws = new WebSocket(URL);
  const live = new Map(); // this connection's ids: they change every time

  ws.onopen = () => {
    wait = 500;
    WANT.forEach((sub, id) =>
      ws.send(JSON.stringify({ jsonrpc: "2.0", id, ...sub })));
  };

  ws.onmessage = (event) => {
    const msg = JSON.parse(event.data);
    if ("id" in msg) {
      if (msg.error) return console.error(msg.error.message);
      live.set(msg.result, WANT[msg.id]);
      return console.log("live", WANT[msg.id].method, "as", msg.result);
    }
    const sub = live.get(msg.params.subscription);
    if (sub) console.log(sub.method, JSON.stringify(msg.params.result));
  };

  ws.onclose = (event) => {
    console.error("closed", event.code, event.reason);
    // 1008: the key or the credits, while connected. A person has to fix
    // that, a loop cannot. A refused handshake closes with 1006.
    if (event.code === 1008) return;
    setTimeout(connect, wait + Math.random() * 250);
    wait = Math.min(wait * 2, 30000);
  };
}

connect();
Run against the live service on 22 November 2026: dropped on purpose, it came back by itself with a new subscription id. carbium.sh's WebSocket skill file lists every close code and what to do on each.

Three figures behind every socket

  • 1,000 subscriptions a socket

    Open one socket and reuse it. Open a second only past that, inside your plan's connection cap.

  • A ping every 30 seconds

    The server pings, and closes a socket that has not answered for 300 seconds. Browsers, Node 22 and the ws package answer for you.

  • One address per mention

    logsSubscribe takes one address in mentions. Use one subscription per address.

04 · Webhooks

Webhooks: a signed POST per finalized transaction

Give Carbium an HTTPS address and a list of Solana addresses. A finalized transaction that touches one of them is posted to you, signed, with no socket to hold open. On Dev, Business and Pro.

  1. Create it

    On the dashboard's Webhooks tab, or with one API call: a key, your HTTPS address and the addresses to watch. A program id counts as an address, and tx_status narrows it to successful or failed transactions. The signing secret is shown once, so store it.

  2. Receive

    One POST per transaction: a JSON array of one, in the shape getTransaction returns. A body over 64 KB arrives in a short form with the signature, and you read the rest with getTransaction.

  3. Verify

    Check the HMAC-SHA256 signature over the raw body with your secret, before you parse it. Refuse a timestamp more than five minutes off.

  4. Answer, then work

    Answer 2xx within 15 seconds and do the work after. A redirect is not followed and counts as a failed try.

Webhook reference
receive.mjs
// receive.mjs: check the signature on the raw body, answer 200, then work.
import { createServer } from "node:http";
import { createHmac, timingSafeEqual } from "node:crypto";

function verify(secret, headers, raw) {
  const id = headers["webhook-id"], ts = headers["webhook-timestamp"];
  if (!secret || !id) return false;
  // refuse a stamp more than 5 minutes from this clock
  if (!(Math.abs(Date.now() / 1000 - Number(ts)) <= 300)) return false;
  const key = Buffer.from(secret.slice("whsec_".length), "base64");
  const mac = createHmac("sha256", key).update(id + "." + ts + ".");
  const want = Buffer.from("v1," + mac.update(raw).digest("base64"));
  const sent = String(headers["webhook-signature"] || "").split(" ");
  return sent.some((sig) => {
    const got = Buffer.from(sig);
    return got.length === want.length && timingSafeEqual(got, want);
  });
}

const seen = new Set(); // use a database in production

createServer((req, res) => {
  const parts = [];
  req.on("data", (chunk) => parts.push(chunk)).on("end", () => {
    const raw = Buffer.concat(parts);
    if (!verify(process.env.WHSEC, req.headers, raw))
      return res.writeHead(401).end();
    res.writeHead(200).end(); // inside 15 seconds, before the work

    const id = req.headers["webhook-id"];
    if (seen.has(id)) return; // a retry of an event you already have
    seen.add(id);
    for (const tx of JSON.parse(raw)) {
      const signature = tx.transaction?.signatures[0] ?? tx.signature;
      if (tx.test) console.log("test event");
      else console.log(tx.slot, signature);
    }
  });
}).listen(8080); // behind your HTTPS name on port 443
The receiver of the webhook reference, with one addition: it skips an event id it has already seen. Checked offline on 22 November 2026 with deliveries signed by a test secret: it took a good signature and refused a wrong secret, a changed body and an old timestamp.

What a delivery promises

  • At least once, in no order

    A delivery can repeat, and deliveries are not ordered. Skip a webhook-id you have seen, and sort by slot where order matters.

  • 8 tries over about 27 hours

    After 5 seconds, 5 minutes, 30 minutes, then 2, 5, 10 and 10 hours. Meanwhile up to 10,000 events or 64 MiB wait per webhook. Past that the oldest are dropped, and so is an event after its last try. A webhook takes at most 200 transactions of one slot.

  • Off after 5 days

    A webhook whose every try fails for 5 days is switched off. Fix the receiver, send a test event, then switch it back on.

Not offered

  • Parsed payloads. The body is the raw transaction, in the shape a Helius raw webhook sends.
  • Account-change webhooks. A webhook fires on transactions.
  • Batches. One transaction per POST.
  • Replay of past events. Read them with getSignaturesForAddress and getTransaction.
  • Delivery to Discord.
  • The System, Token, Token-2022, Associated Token, ComputeBudget and Vote programs as watched addresses.

05 · Limits

WebSocket and webhook limits on every plan

Limits are per account, and all of an account's keys share them. The prices are read from carbium.sh.

Carbium RPC plans: monthly price, WebSocket connections and subscriptions, webhooks, addresses per webhook, webhook deliveries a second and Carbon Stream streams
LimitFreeDevBusinessPro
Per month$0$20$250$500
WebSocket connections51502501,000
Subscriptions across them105,00020,00050,000
WebhooksNot included52550
Addresses per webhookNot included1,00025,000100,000
Deliveries a secondNot included1050200
Carbon Stream streamsNot included525100
Opening a subscription costs 5, 25 or 200 credits by its weight, then 20 credits per MiB sent. A delivered webhook event costs 1 credit. Read on carbium.sh on 22 November 2026: rate limits.

06 · Example

Watch a wallet, start to finish

The job most apps start with, and the one place where the obvious subscription stays silent.

  1. Subscribe to its logs

    logsSubscribe with the wallet as the one mention fires for every transaction that names it, failed ones included. It costs 25 credits to open.

  2. Read the balance

    On each notification, read getBalance over HTTPS. A plain SOL wallet sends nothing on accountSubscribe, so this pair is the way.

  3. Add its tokens

    Token accounts do notify. Add an accountSubscribe for each one you show, on the same socket.

  4. Put the backend on a webhook

    For alerts while nobody has the app open, list the same wallet on a webhook, from Dev. A delivery your server misses, during a restart say, is tried again for about 27 hours.

Building a wallet?

Balances, token lists, live updates and swaps, on one key.

Carbium for wallets
watch-wallet.mjs
// Watch one wallet: a notification for every transaction that names it,
// then its SOL balance over HTTPS.
const KEY = process.env.CARBIUM_KEY;
const opts = { commitment: "confirmed" };
const WALLET = "YOUR_WALLET_ADDRESS";

const rpc = (method, params) =>
  fetch("https://services.carbium.sh", {
    method: "POST",
    headers: { "content-type": "application/json", "x-api-key": KEY },
    body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
  }).then((res) => res.json());

const ws = new WebSocket("wss://services.carbium.sh/?api-key=" + KEY);

ws.onopen = () =>
  ws.send(JSON.stringify({
    jsonrpc: "2.0", id: 1, method: "logsSubscribe",
    params: [{ mentions: [WALLET] }, opts],
  }));

ws.onmessage = async (event) => {
  const msg = JSON.parse(event.data);
  if (msg.method !== "logsNotification") return;
  const { signature, err } = msg.params.result.value;
  const balance = await rpc("getBalance", [WALLET, opts]);
  // a refused or failed read carries an error and no result
  if (!balance.result) return console.error("getBalance", balance.error);
  const sol = balance.result.value / 1e9;
  console.log(signature, err ? "failed" : "ok", sol, "SOL");
};
Run against the live service on 22 November 2026, on a busy public address: each line it printed was a signature, its result and a balance.

Questions

The references on carbium.sh cover every call. For anything else, ask the team on the Carbium Discord.

WebSocket reference

What is the difference between a WebSocket and a webhook on Solana?

A WebSocket is a connection your code opens and holds: Carbium RPC pushes notifications down it while it is open, and nothing is replayed after a drop. A webhook is a call Carbium makes to your HTTPS address per finalized transaction that touches an address you listed, tried again for about 27 hours when your server does not answer.

When is polling the better choice?

When a delay of a few seconds is fine, or the job runs on a schedule. A JSON-RPC call needs no open connection and works from anywhere. Move to a subscription once most of your requests only ask whether anything is new.

Carbium RPC

Which Solana WebSocket subscriptions does Carbium RPC serve?

Eight, on wss://services.carbium.sh: slotSubscribe, slotsUpdatesSubscribe, rootSubscribe, accountSubscribe, programSubscribe, logsSubscribe, signatureSubscribe and blockSubscribe. programSubscribe serves a covered set of programs, and accountSubscribe notifies for token accounts and for accounts of those programs.

WebSocket reference

Does Carbium RPC serve transactionSubscribe?

No. The socket answers it with method not found. Use logsSubscribe with one address in mentions, or a Carbon Stream transaction filter, which pushes the whole transaction.

Carbon Stream

Why does accountSubscribe stay silent for my wallet?

A plain SOL wallet under 1,000,000 SOL is acknowledged but stays silent while it holds SOL, and a subscription that never fired has its credits refunded when it closes. Use logsSubscribe with the wallet as the mention and read getBalance over HTTPS on each notification. Token accounts notify on accountSubscribe directly.

How many WebSocket connections does each plan allow, and what does a subscription cost?

Per account, Free holds 5 connections and 10 subscriptions, Dev holds 150 connections and 5,000 subscriptions, Business holds 250 connections and 20,000 subscriptions, Pro holds 1,000 connections and 50,000 subscriptions. One connection holds up to 1,000 subscriptions. Opening one costs 5, 25 or 200 credits by its weight, then 20 credits per MiB the socket sends you. A refused subscription is not charged.

Compare all plans and limits

Which plans include webhooks, and what are the caps?

Dev, Business and Pro, from $20 a month. They register 5, 25 and 50 webhooks per account, watch up to 1,000, 25,000 and 100,000 addresses per webhook, and deliver up to 10, 50 and 200 events a second per account. Free has no webhooks. A delivered event costs 1 credit, and so does a delivered test event; a failed try and the calls that create, change or delete a webhook cost nothing.

Rate limits on carbium.sh

What happens to webhook events while my server is down?

A delivery with no 2xx answer within 15 seconds is tried again after 5 seconds, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours and 10 hours: 8 tries over about 27 hours. Meanwhile up to 10,000 events or 64 MiB wait per webhook; past that the oldest are dropped, and so is an event after its last try. A webhook whose every try fails for 5 days is switched off until you turn it back on.

Can a webhook send parsed transactions or account changes?

No. Each delivery is one raw transaction in the shape getTransaction returns, as a Helius raw webhook sends it, signed with HMAC-SHA256. Parsed payloads, account-change webhooks, Discord delivery, batching and replay of past events are not offered.

Can I open the socket from a browser?

Yes. A browser cannot set headers, so pass the key as a WebSocket subprotocol, api-key. followed by the key, which keeps it out of the URL. Anyone using the page can read that key, so give it the WebSocket scope only, or hold the socket on your backend.

When should I move from WebSocket to Carbon Stream?

When you need one filter over many accounts, or a restart that resumes from a recent slot. Carbon Stream is native Yellowstone gRPC, on Dev, Business and Pro. A socket filters on one address per subscription and replays nothing.

Carbon Stream: Solana gRPC streaming

Start on a socket, add a webhook when you need one

Carbium RPC runs on bare-metal servers Carbium owns in Switzerland. WebSocket subscriptions come with every plan, on the key you use for JSON-RPC. Webhooks and Carbon Stream start on Dev.

Back to Carbium RPC