Twitter Webhook API: 4 Ways to Push X Posts to Your Server

Get X posts pushed to your server: X's webhook APIs, no-code polling and WebSocket relays compared, with CRC, signature checks, limits and costs for 2026.

$199/mo for 50 accounts after a 3-day, 5-account trial

Published April 30, 2026 · Updated November 11, 2026 · 13 min read · TweetStream team

Yes, X has a webhook API. Its V2 Webhooks API pushes events to your HTTPS URL from the X Activity API (any public account's posts, billed per event), the Account Activity API (only accounts subscribed to your app, now being deprecated) and Filtered Stream webhooks (Enterprise only). The alternatives are no-code polling, a third-party webhook service, or a real-time WebSocket feed you relay to your own endpoints.

The 4 ways to get X posts POSTed to your server

There are four routes to new X posts arriving at your server as HTTP requests. X's own webhooks are the most direct. No-code tools poll on a schedule. Third-party services watch accounts for you and POST what they find. A real-time WebSocket feed with a short relay you run gives you control over signing, retries and fan-out. They differ most in which accounts they can cover, how long a post waits before delivery, and who handles failed deliveries.

Scroll horizontally to compare →

Four ways to get X posts POSTed to your server
RouteAccounts and timingCost and delivery
X webhooks (V2 Webhooks API)Any public account through the X Activity API; owned or subscribed accounts through the Account Activity API; rule matches through Filtered Stream webhooks (Enterprise). X states no latency figure.Per event on pay-per-use, e.g. $0.005 per post.create. Signed POSTs; X lists retry and recovery support and a replay endpoint.
No-code polling (IFTTT, Zapier)IFTTT checks one X user per applet every hour on Free, 15 minutes on Starter and 5 minutes on Pro and Pro+. The widely shared Zapier recipe uses the "My Tweet" trigger, so it relays only your own posts.The tool's plan price. A post waits for the next check.
Third-party webhook servicestwitterapi.io: filter rules checked every 0.05 to 86,400 seconds. Xanguard: any public accounts you track.twitterapi.io: $0.00015 per tweet plus a per-check minimum; one POST with a 1-second timeout and no retries. Xanguard: from $19/month for 10 accounts; HMAC-signed, up to 3 retries on network errors or 5xx.
TweetStream WebSocket plus your relayAccounts you choose, pushed over one WebSocket as they are detected. Posts can also go straight to a Discord webhook per account.From $199/mo for up to 50 accounts. TweetStream does not send generic HTTP webhooks: your relay signs, retries and dead-letters.

Sources: X V2 Webhooks API · X API pricing · IFTTT applet · Zapier to Discord tutorial · twitterapi.io webhooks · Xanguard webhooks · TweetStream pricing

Reviewed 2026-11-11 from each provider's own pages; Xanguard's post is dated January 24, 2026. Timing and retry details are what each provider documents, not measurements by TweetStream.

X's own webhooks, explained

X delivers webhook events through one V2 Webhooks API, and three products feed it. Which one you can use depends on whose posts you want and what plan you have. The X Activity API is the one most people searching for a Twitter webhook need: its post.create event works for any public account, without that account authorizing your app. The Account Activity API, the older product most guides still describe, is being deprecated in favor of it.

  • Choose X's webhooks when you already have an X developer app, watch a moderate list of accounts, and per-event billing suits your posting volume
  • They also suit teams that want push delivery to an HTTPS endpoint and would rather not keep a socket client running
  • Look elsewhere if you need protected accounts (never delivered), a stated delivery latency, or a fixed monthly price

Scroll horizontally to compare →

X's webhook products as of November 2026
ProductWhose postsLimits and price
X Activity APIAny public account: post.create and post.delete are public events, subscribed by user ID with no user OAuth. Protected accounts are never delivered. Also available as a persistent HTTP stream at GET /2/activity/stream.Up to 1,500 subscriptions self-serve, 75,000 Enterprise, 150,000 Partner. $0.005 per post.create. The pricing page lists post.delete as not billed; the Activity API page bills every delivered Post event as a Post.
Account Activity APIOwned or subscribed accounts only; subscribing a user takes OAuth 1.0a 3-legged. Marked "being deprecated" with the X Activity API as the replacement.Pay-per-use: 3 subscriptions and 1 webhook. Enterprise: 5,000+ subscriptions and 5+ webhooks.
Filtered Stream webhooksPosts matching your filter rules. Currently available to Enterprise developers.25,000+ rules per project, up to 2,048 characters each. Returned posts count toward the monthly Post cap.

Sources: X Activity API · Account Activity API · Filtered Stream webhooks · X API pricing

From docs.x.com, read 2026-11-11. X changes these products often; check the linked pages before you build.

Setting up an X webhook: CRC and signatures

Registering an X webhook takes an app-only Bearer token and a public HTTPS URL with no port number. Before X sends any events, it proves you control the endpoint with a CRC challenge, and it repeats the check later. X's docs describe the schedule two ways: hourly in one section, and every 30 minutes only if the webhook has not validated in the past 24 hours in another. Build for either. The receiver below answers the CRC and verifies signed POSTs on the raw body; set X_CLIENT_SECRET to your app's OAuth 2.0 client secret, not the Bearer token.

Scroll horizontally to compare →

What an X webhook endpoint must handle
CheckWhat X sendsWhat you return
CRC challengeGET with a crc_token query parameter, on registration, on PUT /2/webhooks/:webhook_id and periodically200 with {"response_token": "sha256=<base64 HMAC-SHA256 of crc_token>"}, keyed with the OAuth 2.0 client secret (or the OAuth 1.0 consumer secret for older apps)
Signed eventPOST with X-Twitter-Webhooks-Signature-OAuth2 (recommended) or the legacy X-Twitter-Webhooks-Signature, both sha256=<base64> over the raw bodyRecompute the HMAC on the raw bytes, compare in constant time, reject mismatches with 401
TimingExpects an acknowledgement within 10 seconds200 after a fast durable write, then process from a queue. A wrong CRC response marks the webhook invalid at once; repeated timeouts or 4xx and 5xx errors do after 28 hours without a successful check

Sources: X V2 Webhooks API · X webhooks quickstart

From docs.x.com, read 2026-11-11. The sample was run locally against a CRC request and signed and unsigned POSTs.

X webhook receiver: CRC response and signature check

js
// X webhook receiver: answers the CRC check and verifies signed POSTs.
// Node.js 22, no dependencies. Save as receiver.mjs and run behind HTTPS on port 443.
import { createHmac, timingSafeEqual } from "node:crypto";
import { createServer } from "node:http";
 
const CLIENT_SECRET = process.env.X_CLIENT_SECRET; // OAuth 2.0 client secret (recommended)
const CONSUMER_SECRET = process.env.X_CONSUMER_SECRET; // OAuth 1.0 consumer secret, legacy apps only
const sign = (secret, data) => `sha256=${createHmac("sha256", secret).update(data).digest("base64")}`;
const matches = (header, secret, body) => {
  if (!header || !secret) return false;
  const expected = Buffer.from(sign(secret, body));
  const received = Buffer.from(String(header));
  return received.length === expected.length && timingSafeEqual(received, expected);
};
 
createServer((req, res) => {
  if (req.method === "GET") {
    const crcToken = new URL(req.url, "http://localhost").searchParams.get("crc_token");
    if (!crcToken) return res.writeHead(400).end();
    res.writeHead(200, { "content-type": "application/json" });
    return res.end(JSON.stringify({ response_token: sign(CLIENT_SECRET ?? CONSUMER_SECRET, crcToken) }));
  }
 
  if (req.method !== "POST") return res.writeHead(405).end();
 
  const chunks = [];
  let size = 0;
  req.on("data", (chunk) => {
    size += chunk.length;
    if (size > 1_000_000) req.destroy(); // cap the body at 1 MB
    else chunks.push(chunk);
  });
  req.on("end", async () => {
    const body = Buffer.concat(chunks); // verify the raw bytes, before any JSON parsing
    // When the OAuth 2.0 header is present it decides; the legacy header counts only without it.
    const oauth2 = req.headers["x-twitter-webhooks-signature-oauth2"];
    const signed =
      oauth2 !== undefined
        ? matches(oauth2, CLIENT_SECRET, body)
        : matches(req.headers["x-twitter-webhooks-signature"], CONSUMER_SECRET, body);
    if (!signed) return res.writeHead(401).end();
    let event;
    try {
      event = JSON.parse(body.toString("utf8"));
    } catch {
      return res.writeHead(400).end();
    }
    try {
      await enqueue(event); // durable write first: a 200 tells X the event is yours
    } catch (error) {
      console.error("enqueue failed", error);
      return res.writeHead(500).end(); // report the failure instead of losing the event
    }
    res.writeHead(200).end(); // X waits at most 10 seconds, so keep enqueue fast
  });
}).listen(Number(process.env.PORT ?? 8080));
 
async function enqueue(event) {
  console.log(JSON.stringify(event)); // replace with a durable write to your queue or database
}

No-code options and their delay

No-code tools are the quickest way to get a post into another app, and they suit logging, social media workflows and a personal Discord channel. They poll. IFTTT's "Send a Webhook when a specific X user tweets" applet checks every hour on Free, every 15 minutes on Starter and every 5 minutes on Pro and Pro+, according to its applet page in November 2026. The most-shared Zapier tutorial for Twitter to Discord uses the "My Tweet" trigger, which only sees your own account. Neither is built for trading, where a post that arrives minutes late is already priced in. If Discord is the only destination, the Discord guide linked below covers it step by step.

Relay a real-time feed into your own webhooks

If you want posts from any account at your own endpoints with signatures and retries you control, run a relay. TweetStream supplies the feed over one WebSocket; the relay is your code, and it is short. It keeps one connection open, filters events, signs each outbound request with an HMAC over a timestamp and the body, and retries failed deliveries with backoff and jitter away from the receive path. Signing the timestamp lets your receivers reject replayed requests, a gap X's own signature format leaves to you because it signs only the body.

  • Consume events once from one TweetStream WebSocket and fan out from there
  • Normalize and filter payloads before signing, so every receiver sees one shape
  • Sign timestamp.body with HMAC-SHA256 and send both, so receivers can reject old or altered requests
  • Retry 5xx, 429 and network errors with backoff and jitter, never inside the WebSocket message handler
  • Cap deliveries in flight, dead-letter what still fails, and use platform plus post ID as the idempotency key

Relay TweetStream posts to your endpoint as signed webhooks

js
// Relay TweetStream posts to your own endpoint as signed webhooks.
// Node.js 22 (built-in WebSocket and fetch), no dependencies. Save as relay.mjs.
import { createHmac } from "node:crypto";
 
const { TWEETSTREAM_API_KEY, WEBHOOK_URL, WEBHOOK_SECRET } = process.env;
const RETRY_DELAYS_MS = [1_000, 5_000, 30_000];
const MAX_IN_FLIGHT = 8; // deliveries running at once
const MAX_QUEUED = 1_000; // beyond this, dead-letter instead of growing memory
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
 
async function deliver(post) {
  const body = JSON.stringify(post);
  for (let attempt = 0; ; attempt++) {
    // Sign the timestamp with the body so a receiver can reject replays.
    const timestamp = String(Date.now());
    const signature = createHmac("sha256", WEBHOOK_SECRET).update(`${timestamp}.${body}`).digest("hex");
    try {
      const res = await fetch(WEBHOOK_URL, {
        body,
        headers: {
          "content-type": "application/json",
          "idempotency-key": post.key,
          "x-relay-signature": signature,
          "x-relay-timestamp": timestamp,
        },
        method: "POST",
        signal: AbortSignal.timeout(5_000),
      });
      await res.body?.cancel(); // release the connection; the body isn't needed
      if (res.ok) return;
      if (res.status < 500 && res.status !== 429) break; // the receiver rejected it: don't retry
    } catch (error) {
      console.warn(`delivery of ${post.key} failed: ${error.message}`);
    }
    if (attempt >= RETRY_DELAYS_MS.length) break;
    await sleep(RETRY_DELAYS_MS[attempt] * (0.5 + Math.random())); // backoff with jitter
  }
  console.error(`dead letter ${post.key}`); // write to durable storage in production
}
 
// A bounded queue: a slow or down endpoint can't pile up unlimited requests.
const queue = [];
let inFlight = 0;
function enqueue(post) {
  if (queue.length >= MAX_QUEUED) return console.error(`dead letter ${post.key} (queue full)`);
  queue.push(post);
  drain();
}
function drain() {
  while (inFlight < MAX_IN_FLIGHT && queue.length > 0) {
    inFlight++;
    void deliver(queue.shift()).finally(() => {
      inFlight--;
      drain();
    });
  }
}
 
let attempt = 0;
function connect() {
  const socket = new WebSocket("wss://ws-global.tweetstream.io/ws", [
    "tweetstream.v1",
    `tweetstream.auth.token.${TWEETSTREAM_API_KEY}`,
  ]);
  let closed = false;
  let stableTimer;
  // Reset the backoff only after 30 s of uptime, so a server that accepts and
  // then closes (bad key, connection limit) still gets increasing delays.
  socket.addEventListener("open", () => {
    stableTimer = setTimeout(() => (attempt = 0), 30_000);
  });
  socket.addEventListener("message", (message) => {
    const { t, op, d } = JSON.parse(message.data);
    if (t !== "tweet" || op !== "content") return;
    // Posts are keyed by (platform, tweetId); platform defaults to twitter.
    const platform = d.author?.platform ?? "twitter";
    // Queue, don't await: a slow endpoint must never hold up the socket.
    enqueue({
      author: d.author?.handle,
      createdAt: d.createdAt,
      key: `${platform}:${d.tweetId}`,
      platform,
      text: d.text,
      tweetId: d.tweetId,
    });
  });
  const reconnect = () => {
    if (closed) return;
    closed = true;
    clearTimeout(stableTimer);
    setTimeout(connect, Math.min(30_000, 1_000 * 2 ** attempt++));
  };
  socket.addEventListener("close", reconnect);
  socket.addEventListener("error", reconnect);
}
 
connect();

Send posts straight to Discord

When the destination is Discord, skip the relay. TweetStream posts each tracked account's posts to a Discord webhook you choose, set per account from the dashboard or with PATCH /api/account-settings, which also takes keyword filters. Discord is the only webhook destination TweetStream delivers to; the account settings API accepts only discord.com and discordapp.com webhook URLs.

Receiver best practices

Whichever route you pick, the receiving side follows the same rules. The usual problems are slow handlers, duplicate deliveries and endpoints that stopped passing validation without anyone noticing.

  • Acknowledge with 200 immediately and do the work from a queue; X allows 10 seconds, and twitterapi.io's webhooks time out after 1 second
  • Deduplicate on platform plus post ID (platform defaults to twitter), since retries and replays can deliver the same event twice
  • Check GET /2/webhooks for a webhook X has marked invalid after failed CRC checks, and re-enable it with PUT /2/webhooks/:webhook_id
  • X documents retry and recovery support and a replay endpoint, but publishes no retry schedule, so reconcile against your own records after an outage
  • Test locally through a tunnel to a public HTTPS URL, since X will not call a URL with a port

Webhook or WebSocket?

A webhook suits systems that want one HTTP request per event. A WebSocket suits a process that stays connected and reacts at once, such as a trading bot. TweetStream detects X posts in typically 166 ms, measured from X's post timestamp to first receipt on a TweetStream server. The live figures are at tweetstream.io/speedcheck. For the full tradeoff between the two delivery models, read the WebSocket vs webhook guide.

Questions

Does Twitter (X) have a webhook API?
Yes. X's V2 Webhooks API sends events to an HTTPS URL you register for three products: the X Activity API, the Account Activity API and Filtered Stream webhooks. Your endpoint has to pass a CRC check and respond within 10 seconds (docs.x.com, as of November 2026).
Can I get X webhooks for accounts I don't own?
Yes, through the X Activity API. Its post.create and post.delete events are public, so you can subscribe to an account by user ID without that user's OAuth. Posts from protected accounts are never delivered. The Account Activity API only covers accounts subscribed through OAuth 1.0a with your app.
Are X webhooks free?
No. As of November 2026, X bills X Activity API webhook events per event on pay-per-use: $0.005 per post.create, $0.010 per follow event and $0.005 per profile update. The pricing page lists post.delete as not billed, though the Activity API page says every delivered Post event is billed as a Post. Charges are deduplicated within a 24-hour UTC window, and X's pricing page lists no free tier.
How do I verify an X webhook?
Answer X's CRC GET by returning {"response_token": "sha256=<base64 HMAC>"}, where the HMAC-SHA256 of the crc_token is keyed with your app's OAuth 2.0 client secret (or the OAuth 1.0 consumer secret if the app has only that). Then check X-Twitter-Webhooks-Signature-OAuth2 on every POST; fall back to the legacy X-Twitter-Webhooks-Signature only when that header is absent, as it is for OAuth 1.0-only apps: compute the same HMAC over the raw request body and compare in constant time.
Does TweetStream send webhooks?
To Discord, yes: TweetStream can post each tracked account's posts to a Discord webhook you set, with optional keyword filters. TweetStream does not send generic HTTP webhooks. To reach your own server, read the WebSocket and post to your endpoints from a small relay you run, which then owns signing and retries.
How do I build a Twitter notification bot?
Use one WebSocket consumer as the event source and post the events you want to Discord, Telegram, Slack or your own alerting from your backend. Keep sends idempotent with platform plus post ID as the key (platform defaults to twitter), and retry them outside the WebSocket receive callback so a slow destination never delays the feed.

Run this workflow with TweetStream

TweetStream delivers posts, deletes, pins, profile and follow changes, and token and OCR enrichment as WebSocket events. Try it with the accounts from this guide.

$199/mo for 50 accounts after a 3-day, 5-account trial