# How to Automate Twitch Stream Alerts using the API

- Tool: API Automations
- Difficulty: Intermediate
- Fix time: 30-60 minutes
- Compatibility: Free Twitch developer account. App Access Token (Client Credentials) for webhook transport. Public HTTPS URL required for webhook transport; WebSocket transport needs no public URL.
- Last updated: May 2026

## TL;DR

Automate Twitch stream-live alerts using EventSub subscriptions — PubSub was fully decommissioned April 14, 2025, so EventSub is now mandatory. Subscribe to stream.online and stream.offline event types using an App Access Token, then your webhook or WebSocket receives a notification and posts the alert to Discord, Slack, or email. Webhook transport handles up to 10,000 subscription cost units; WebSocket is simpler for hobby projects.

## Best practices

- Always verify the Twitch-Eventsub-Message-Signature on incoming webhook payloads using HMAC-SHA256 computed over raw bytes — never trust unverified events
- Echo the challenge as plain text (Content-Type: text/plain), not JSON — this is the most common mistake when setting up EventSub for the first time
- Call GET /streams after a stream.online event rather than relying on the event payload alone — the event only contains the broadcaster ID, while /streams provides title, game, and viewer count
- Append a cache-busting query parameter (e.g., ?t=<timestamp>) to Twitch thumbnail URLs before embedding them in Discord or Slack to force a fresh image load
- Store EventSub subscription IDs in a database so you can audit, delete, and recreate them without losing track of active subscriptions
- Delete subscriptions for channels you no longer need to alert on — subscription cost accumulates against max_total_cost, and Twitch deactivates subscriptions with repeated delivery failures

## Frequently asked questions

### Can I still use PubSub for stream alerts?

No. Twitch fully decommissioned PubSub on April 14, 2025. Any code still using PubSub will receive no events. EventSub (webhook, WebSocket, or Conduit transport) is the only supported real-time event system. The migration guide is at dev.twitch.tv/docs/pubsub/.

### Do I need a public URL to use EventSub?

Only for webhook transport. If you do not have a public HTTPS server, use WebSocket transport instead: connect to wss://eventsub.wss.twitch.tv/ws and create subscriptions using a User Access Token. WebSocket is simpler for hobby projects following a single channel but is limited to a max_total_cost of 10 per client_id+user_id tuple (roughly 10 subscriptions).

### Why do my EventSub subscriptions stay in 'pending' status?

Your webhook endpoint did not return the challenge value within 10 seconds of receiving the webhook_callback_verification message. Make sure your endpoint: (1) is publicly accessible over HTTPS, (2) returns Content-Type: text/plain with HTTP 200, (3) returns the raw challenge string (not wrapped in JSON). After fixing, delete the pending subscription and resubscribe.

### How many channels can I monitor for stream alerts?

With webhook transport, the default max_total_cost is 10,000 and grows as more users authorize your app. Each stream.online subscription costs 1 unit, so you can theoretically monitor up to 10,000 channels by default. With WebSocket transport, you are limited to max_total_cost of 10 per client_id+user_id tuple.

### Is the Twitch API free to use?

Yes, the Twitch Helix API and EventSub are free with no per-request charges. You need a free Twitch account and a registered developer application at dev.twitch.tv/console/apps. The only cost is hosting your own webhook server (or using a paid serverless platform if you prefer).

### What happens if my webhook server is down and I miss events?

Twitch retries failed event deliveries for a period before marking the subscription as notification_failures_exceeded and revoking it. Subscribe to the revocation message type in your handler and set up alerting for it. To catch up on missed events, call GET /streams after your server recovers to check current live status directly.

### Can RapidDev help build a custom Twitch alert integration?

Yes. RapidDev has built 600+ apps including real-time Twitch alert systems, multi-channel Discord bots, and streamer dashboards. Book a free consultation at rapidevelopers.com.

---

Source: https://www.rapidevelopers.com/api-automations/how-to-automate-twitch-stream-alerts-using-the-api
© RapidDev — https://www.rapidevelopers.com/api-automations/how-to-automate-twitch-stream-alerts-using-the-api
