All guides

November 23, 2026 · 5 min read

YouTube Webhook for New Videos, Including the Full Transcript

In short

YouTube's push notifications only tell you a video ID. Get a webhook for each new video that carries its full transcript, and verify it in Node and Python.

YouTube has no simple webhook that sends a new video's content. Its only push option, PubSubHubbub (WebSub), sends an Atom notification with the video ID and title, and you still have to fetch captions yourself. To get a webhook that includes the full transcript, create a TranscriptYT watch: POST /v1/watches with a channel or search phrase and a webhook_url, and each new upload arrives as a signed JSON POST with its text and timestamped segments.

What YouTube's own push notifications give you

YouTube's push notifications use the PubSubHubbub protocol, now called WebSub. You send a subscription request to Google's hub for a channel's feed, answer the hub's verification challenge on your callback URL, and from then on the hub POSTs an Atom XML entry to that URL when the channel publishes or updates a video.

The entry has the video ID, the channel ID, the title, and a link. That is enough to know something happened, but not what was said. To get the words you then call another service for captions, and for a fresh upload those captions frequently do not exist yet. You also have to renew the subscription before its lease runs out, handle duplicate notifications for edits, and keep a list of every channel you have subscribed to.

  • No transcript or caption text in the notification.
  • Subscriptions expire and must be renewed on a schedule.
  • Updates to old videos trigger notifications too, so you need your own de-duplication.
  • Search terms are not supported; you can only follow channels.

A webhook that carries the transcript

A TranscriptYT watch does the subscribing, polling, caption fetching, and retrying for you. It checks every hour, and when it finds a new upload it fetches the transcript and POSTs everything in one request. Create one with a channel (@handle, URL, or UC... ID) or a query, plus your HTTPS webhook_url. The full API reference is in the docs, and the channel monitoring guide covers email delivery and no-code setups.

The response includes a secret starting with whsec_. It is shown once. Save it as an environment variable on the server that receives the webhook.

curl -X POST "https://transcript-yt.com/v1/watches" \
  -H "Authorization: Bearer $TRANSCRIPTYT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"channel": "https://www.youtube.com/@mkbhd", "webhook_url": "https://example.com/hooks/youtube", "ai": true}'

What the webhook body looks like

Every delivery is a POST with event set to video.transcript. The watch object tells you which watch fired, and kind is channel or search. video.source says whether the text came from YouTube captions or from AI speech-to-text, and auto_generated tells you whether the captions were YouTube's automatic ones. Segments carry start and duration in seconds, so you can link to any moment with a t= parameter.

Three headers come with it: X-TranscriptYT-Event (video.transcript), X-TranscriptYT-Delivery (a unique delivery ID), and X-TranscriptYT-Signature (sha256= followed by a hex HMAC).

{
  "event": "video.transcript",
  "delivered_at": "2026-11-23T14:02:11Z",
  "watch": { "id": "...", "kind": "channel", "target": "UC...", "label": "Marques Brownlee" },
  "video": {
    "id": "...",
    "url": "https://www.youtube.com/watch?v=...",
    "title": "...",
    "author": "Marques Brownlee",
    "channel_id": "UC...",
    "duration_seconds": 1034,
    "language": "en",
    "auto_generated": true,
    "source": "captions"
  },
  "transcript": {
    "text": "...",
    "segments": [ { "start": 0.24, "duration": 3.84, "text": "..." } ]
  }
}

Verify the signature in Node.js

The signature is an HMAC-SHA256 of the raw request body, keyed with the full watch secret including the whsec_ prefix. Compute it over the exact bytes you received, before any JSON parsing, because re-serializing the body changes it. In Express that means express.raw on this route instead of express.json. Compare in constant time, and check the lengths first because timingSafeEqual throws on buffers of different sizes.

import crypto from "node:crypto";
import express from "express";

const app = express();
const SECRET = process.env.TRANSCRIPTYT_WATCH_SECRET; // whsec_...

app.post("/hooks/youtube", express.raw({ type: "application/json" }), (req, res) => {
  const header = req.get("X-TranscriptYT-Signature") || "";
  const received = Buffer.from(header.replace(/^sha256=/, ""), "hex");
  const expected = crypto.createHmac("sha256", SECRET).update(req.body).digest();
  if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) {
    return res.status(401).send("bad signature");
  }

  const event = JSON.parse(req.body.toString("utf8"));
  console.log(event.video.title, event.transcript.text.length);
  res.sendStatus(200);
});

app.listen(3000);

Verify the signature in Python

The same check in Flask. request.get_data() returns the raw bytes; hmac.compare_digest does the constant-time comparison. In FastAPI, read the body with await request.body() and apply the same three lines.

import hashlib, hmac, json, os
from flask import Flask, abort, request

app = Flask(__name__)
SECRET = os.environ["TRANSCRIPTYT_WATCH_SECRET"].encode()  # whsec_...

@app.post("/hooks/youtube")
def youtube_hook():
    raw = request.get_data()
    expected = "sha256=" + hmac.new(SECRET, raw, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(expected, request.headers.get("X-TranscriptYT-Signature", "")):
        abort(401)

    event = json.loads(raw)
    print(event["video"]["title"], len(event["transcript"]["segments"]))
    return "", 200

Make your handler reliable

A delivery counts as accepted when your endpoint answers with a 2xx status. Anything else, or no answer, means it is retried every hour for up to 48 hours. The transcript credit is charged once when the transcript is fetched, so retries cost nothing. If every delivery fails for 3 days, the watch pauses itself; resume it with PATCH /v1/watches/{id} and {"paused": false}.

  • Return 200 quickly and do slow work (summaries, embeddings, database writes) in a background job.
  • Store the X-TranscriptYT-Delivery ID and skip IDs you have already processed, since a retry can arrive after a slow success.
  • Reject requests with a missing or wrong signature with 401, and never log the secret.
  • Check video.source: speech_to_text means there were no captions and the audio was transcribed, which only happens on watches with ai set to true.
  • Keep the endpoint on HTTPS with a valid certificate; webhook_url must be https.

Testing your endpoint

You do not have to wait for a real upload to test the handler. Build a sample body like the one above, sign it yourself with the secret, and POST it to your local server. If your handler accepts that request and rejects the same body with one character changed, the verification is correct.

Once it is live, GET /v1/watches/{id} shows the watch's recent videos and the status of each delivery, which is the quickest way to see whether a missing video was never found, is waiting for captions, or failed to deliver.

BODY='{"event":"video.transcript","video":{"id":"test"}}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$TRANSCRIPTYT_WATCH_SECRET" | sed 's/^.* //')
curl -X POST "http://localhost:3000/hooks/youtube" \
  -H "Content-Type: application/json" \
  -H "X-TranscriptYT-Signature: sha256=$SIG" \
  --data "$BODY"

Fresh uploads without captions

The most common reason a homemade pipeline misses videos is timing: the push notification arrives minutes after upload, but automatic captions take longer, and live streams can take hours. A watch holds such videos and retries hourly for up to 48 hours. With ai set to true it stops waiting after 6 hours and transcribes the audio, at 1 credit per started minute for videos up to 2 hours long. Caption-only services cannot deliver these videos at all; see transcribing videos without captions for how the AI fallback works.

Keyword watches work the same way. Instead of a channel, pass {"query": "..."} and every hour the watch looks at videos uploaded in the last 24 hours that match the phrase. That is the basis of YouTube brand monitoring, which PubSubHubbub cannot do at all.

Common questions

Does YouTube have a webhook for new videos?

Only through PubSubHubbub (WebSub) push notifications. You subscribe a callback URL to a channel's feed and receive an Atom XML ping with the video ID and title when it uploads. It contains no transcript or captions.

How do I get a YouTube transcript in a webhook?

Create a TranscriptYT watch with webhook_url set to your HTTPS endpoint. Each new video is posted to it as JSON with the transcript text, timestamped segments, and video metadata.

How do I verify a TranscriptYT webhook signature?

Compute an HMAC-SHA256 of the raw request body using the watch's whsec_ secret, hex-encode it, and compare it in constant time with the value after sha256= in the X-TranscriptYT-Signature header.

What happens if my webhook endpoint is down?

The delivery is retried every hour for up to 48 hours with no extra charge. If every delivery keeps failing for 3 days, the watch pauses itself until you resume it.

Try the YouTube Transcript API

Get transcripts as JSON, text, SRT, or VTT. 100 free credits, no card required.

More guides