Webhooks Subscription Verify Response

Hello dev Twitch community,

I’m new w/ Twitch API & NodeJS.
I tried to suscribe to streams webhooks but I didn’t receive any data.
I had the 202 Accepted response and I got the challenge. I display the challenge on page,
but I don’t receive any data. I have wait for more than 5 minutes and nothing appear.
My process should be wrong. Someone to help me to understand where I’m wrong & where I had to handle data ?

Thanks :smiley:

// Modules declaration
    const express = require('express')
    const app = express()
    const request = require('request')

    // Send Twitch webhooks subscription

    // Twitch client id
    var clientID = 'clientidvalue'
    // Content type of data to send
    var contentType = 'application/json'
    // Twitch URI to contact
    var postURI = 'https://api.twitch.tv/helix/webhooks/hub'
    // Secret phrase to authenticate response
    var secret = 'secretvalue'
    // Multiple params to send to Twitch
    var options = {
        // Array w/ all headers params
        headers: {
            // Twitch client id
            'Client-ID': clientID,
            // Content type of data to send
            'Content-Type': contentType
        // Twitch URI to contact
        uri: postURI,
        // Method use to send our request
        method: 'POST',
        json: {
            "hub.mode": "subscribe",
            "hub.topic": "https://api.twitch.tv/helix/streams?user_id=64989126",
            "hub.callback": "https://api.gius.tv/twitch/streams",
            "hub.lease_seconds": 864000,
            "hub.secret": secret

    request(options, function (error, response, body) {
        console.log('Request status code : ' + response.statusCode)
        if (response.statusCode === 202) {
            console.log(response.statusCode + ' ' + response.statusMessage)
        } else {
            console.log(response.statusCode + ' ' + response.statusMessage)

    // Routes

    // Homepage route
    app.get('/', function(req, res) {
        res.send('Site en maintenance. #Scusate :D')

    // Callbacks handlers

    // Streams Up/Down
    app.get('/twitch/streams', function (req, res) {
        /*var incoming = req.headers['x-hub-signature'].split('=');
        var hash = crypto.createHmac(incoming[0], secret)
        if (incoming[1] != hash) {
        } else {
            console.log('Payload OK')// do other stuff

You don’t have anything handling POST requests. The challenge that you have to respond with to verify you service is reachable and working is a GET request, but the notifications are POST requests so you need to use a app.post(YOUR_ROUTE, YOUR_HANDLER)

Oh, ok,
I did not notice that I did not have a route that accepts the POST request.

Tired, thank you.
I can’t test now, but when I could I would make a feedback.

Thanks again @Dist

It’s work, Thanks :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.