# Help with Webhooks

**URL:** <https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618>\
**Category:** API\
**Created:** [October 27, 2017, 8:16pm UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618 "2017-10-27T20:16:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dscalzi](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/dscalzi/32/3555_2.png) [@dscalzi](https://staging-discuss.dev.twitch.com/u/dscalzi)\
**Post date:** [October 27, 2017, 8:16pm UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618/1 "2017-10-27T20:16:24Z")

</div>

Hey, I’m currently working on a service to forward Twitch webhooks to discord. I am encountering several issues though.

The main issue is with webhook creation. The documentation page is not entirely clear on how to setup the callback url, so I’ll explain what I have tried. I have sent the request to twitch’s servers with the correct topic, mode, and callback. On the callback server I have it setup where if it recieves a GET request from twitch, it will respond with the hub.challenge sent in the url query string along with a 202 accepted status code. Here is the core code I’m using for that. Language is Node.js using Express.

```
if(request.query['hub.challenge'] != null){
    response.status(202).send(request.query['hub.challenge']);
}

```

From there I get nothing else from Twitch, not sure if I am supposed to. I then test the event which triggers the webhook, gaining a follower in this case. I gain a follower and nothing is sent to the callback server. No post request, nothing. Have I done something wrong?

Thanks for the help in advance.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 27, 2017, 8:51pm UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618/2 "2017-10-27T20:51:00Z")

</div>

You don’t send a 202 you send a 200, with the bodt as the hub\_challenge GET argument (which I’ve been receiving as hub\_challenge rather than hub.challenge. So cross check what you are receiving

The response to the (cURL) subscribe request is a 202 Created.

You must only send 200’s to Twitch.

So:

```
if(request.query['hub.challenge'] != null){
    response.send(request.query['hub.challenge']);
}
```

---

<div class="post-metadata">

**Author:** ![dscalzi](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/dscalzi/32/3555_2.png) [@dscalzi](https://staging-discuss.dev.twitch.com/u/dscalzi)\
**Post date:** [October 27, 2017, 10:33pm UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618/3 "2017-10-27T22:33:16Z")

</div>

Even with the 200 request the webhook isn’t functioning. Does twitch send a confirmation showing that the webhook was created? If so where does this get sent.

---

<div class="post-metadata">

**Author:** ![3ventic](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/3ventic/32/298_2.png) [@3ventic](https://staging-discuss.dev.twitch.com/u/3ventic)\
**Post date:** [October 27, 2017, 10:52pm UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618/4 "2017-10-27T22:52:42Z")

</div>

It’s `challenge`, not `hub.challenge`. Where did you get `hub.challenge` from?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 27, 2017, 11:18pm UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618/5 "2017-10-27T23:18:29Z")

</div>

Docs are wrong.

Hub.challenge is what twitch is sending

 ![87ACAF1E-6BA2-41F0-9BFB-5767984E718F](https://d1d6mrmdu7ztse.cloudfront.net/uploads/default/original/2X/7/7ac1d3707d81bac756c16a93231c5880ef224845.jpg)

If you replied with the challenge correctly. Then all should be good

Looks like you are using node. So make sure you bound a POST route on express of that is what you are using. I can post my sample code when I’m back at a pc.

---

<div class="post-metadata">

**Author:** ![george](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/george/32/120_2.png) [@george](https://staging-discuss.dev.twitch.com/u/george)\
**Post date:** [October 27, 2017, 11:27pm UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618/6 "2017-10-27T23:27:49Z")

</div>

Looks like they changed it since release. The mock up I made to test webhooks on Tuesday used only `challenge` and no longer works but did at the time.

---

<div class="post-metadata">

**Author:** ![dscalzi](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/dscalzi/32/3555_2.png) [@dscalzi](https://staging-discuss.dev.twitch.com/u/dscalzi)\
**Post date:** [October 27, 2017, 11:30pm UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618/7 "2017-10-27T23:30:19Z")

</div>

Well the literal parameters sent to the server are:

```
{ 'hub.challenge': 'redacted',
  'hub.lease_seconds': '0',
  'hub.mode': 'subscribe',
  'hub.topic': 'topic_url' }
```

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 27, 2017, 11:45pm UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618/8 "2017-10-27T23:45:54Z")

</div>

Oh!

> [@dscalzi](#):
>
> ‘hub.lease\_seconds’: ‘0’,

Your Webhook expired the moment it was created.

Set it to a non zero positive to make the webhook last for a period of time (the max is 10 days 864000)

---

<div class="post-metadata">

**Author:** ![dscalzi](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/dscalzi/32/3555_2.png) [@dscalzi](https://staging-discuss.dev.twitch.com/u/dscalzi)\
**Post date:** [October 28, 2017, 12:46am UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618/9 "2017-10-28T00:46:48Z")

</div>

Thanks so much! Did not know I this was a thing. Worked now 😀

---

<div class="post-metadata">

**Author:** ![system](https://d2spem0quai2ol.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://staging-discuss.dev.twitch.com/u/system)\
**Post date:** [November 27, 2017, 12:46am UTC](https://staging-discuss.dev.twitch.com/t/help-with-webhooks/12618/10 "2017-11-27T00:46:52Z")

</div>

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