# Two webhook events sent for some new topics

**URL:** https://meta.discourse.org/t/two-webhook-events-sent-for-some-new-topics/50951
**Category:** Bug
**Created:** [October 1, 2016, 2:18pm UTC](https://meta.discourse.org/t/two-webhook-events-sent-for-some-new-topics/50951 "2016-10-01T14:18:54Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![DanielMarquard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danielmarquard/32/74010_2.png) [@DanielMarquard](https://meta.discourse.org/u/DanielMarquard)
#### Post date: [October 1, 2016, 2:18pm UTC](https://meta.discourse.org/t/two-webhook-events-sent-for-some-new-topics/50951/1 "2016-10-01T14:18:54Z")

</div>

I have a webhook configured to trigger for `topic_created` and `post_created` events. I’ve noticed that some new topics will trigger both, though. This is not true for all topics, but I have noticed it for topics containing uploaded images in their original posts.

In comparing their payloads, the only difference is that the `post_created` JSON contains a `post` array (for `post_number` 1).

[This topic](https://critcola.com/community/t/crit-cola-presents-roll-for-crit/263) from this morning, for example, triggered both events. Here’s the [`topic_created` payload](http://pastebin.com/MDJ1h3yw), and the [`post_created` payload](http://pastebin.com/1hJPrtGD).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 1, 2016, 2:54pm UTC](https://meta.discourse.org/t/two-webhook-events-sent-for-some-new-topics/50951/2 "2016-10-01T14:54:18Z")

</div>

Hmm anything we can look at here to fix @tgxworld?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 5, 2016, 7:17am UTC](https://meta.discourse.org/t/two-webhook-events-sent-for-some-new-topics/50951/3 "2016-10-05T07:17:26Z")

</div>

also… ping @fantasticfears 🙂

---

<div class="post-metadata">

### Author: ![fantasticfears](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantasticfears/32/119608_2.png) [@fantasticfears](https://meta.discourse.org/u/fantasticfears)
#### Post date: [October 11, 2016, 2:35am UTC](https://meta.discourse.org/t/two-webhook-events-sent-for-some-new-topics/50951/4 "2016-10-11T02:35:08Z")

</div>

Sorry for the late reply. I was away from home. Did you check `topic` and `post` event type? If so, `topic_created` comes from topic event type and `post_created` comes from post event type. `X-Discourse-Event-Type` can help to differentiate them. In other words, it’s intended.

> [@DanielMarquard](#):
>
> This is not true for all topics, but I have noticed it for topics containing uploaded images in their original posts.

But it looks like you are describing another thing. Can you elaborate your configuration?

---

<div class="post-metadata">

### Author: ![DanielMarquard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danielmarquard/32/74010_2.png) [@DanielMarquard](https://meta.discourse.org/u/DanielMarquard)
#### Post date: [October 11, 2016, 2:59am UTC](https://meta.discourse.org/t/two-webhook-events-sent-for-some-new-topics/50951/5 "2016-10-11T02:59:57Z")

</div>

> [@fantasticfears](#):
>
> Did you check topic and post event type? If so, topic\_created comes from topic event type and post\_created comes from post event type. X-Discourse-Event-Type can help to differentiate them. In other words, it’s intended.

Both are checked for the same webhook. As I mentioned, [this topic](https://critcola.com/community/t/roll-for-crit-a-dnd-event-for-new-players/263) triggered both event types when created, one `topic_created` and one `post_created`. You can see from the payloads I linked that there was only one post in the topic at the time. As I’ve already worked around the bug, I can’t be sure which other topics have also triggered both upon creation, but this one wasn’t the first.

Let me know if I can do anything to help narrow it down.

---

<div class="post-metadata">

### Author: ![fantasticfears](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantasticfears/32/119608_2.png) [@fantasticfears](https://meta.discourse.org/u/fantasticfears)
#### Post date: [October 11, 2016, 3:17am UTC](https://meta.discourse.org/t/two-webhook-events-sent-for-some-new-topics/50951/6 "2016-10-11T03:17:16Z")

</div>

If you checked the two event types, all new topics should trigger them twice. As `topic` event type will trigger `topic_created` and `post` event type will trigger `post_created`.

If the problem is redundant post information, I would note it along with other feedback. Those fields should be either truncated or customized as you mentioned [here](https://meta.discourse.org/t/webhooks-feedback/49046/23). 🙂

---

<div class="post-metadata">

### Author: ![DanielMarquard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danielmarquard/32/74010_2.png) [@DanielMarquard](https://meta.discourse.org/u/DanielMarquard)
#### Post date: [October 11, 2016, 3:27am UTC](https://meta.discourse.org/t/two-webhook-events-sent-for-some-new-topics/50951/7 "2016-10-11T03:27:21Z")

</div>

> [@fantasticfears](#):
>
> If you checked the two event types, all new topics should trigger them twice. As topic event type will trigger topic\_created and post event type will trigger post\_created.

Strange, I swear I hadn’t noticed two events for most new topics before, but I just created one and both events were triggered. If this is the intended behavior, then it seems to be working. I made accommodations in my script, so all is well either way. 🙂

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 21, 2016, 5:19am UTC](https://meta.discourse.org/t/two-webhook-events-sent-for-some-new-topics/50951/8 "2016-10-21T05:19:16Z")

</div>


