# Topic Event webhook broken- false topic\_created messages

**URL:** https://meta.discourse.org/t/topic-event-webhook-broken-false-topic-created-messages/213884
**Category:** Bug
**Created:** [January 5, 2022, 3:36am UTC](https://meta.discourse.org/t/topic-event-webhook-broken-false-topic-created-messages/213884 "2022-01-05T03:36:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mark\_Schmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mark_schmucker/32/124810_2.png) [@Mark\_Schmucker](https://meta.discourse.org/u/Mark_Schmucker)
#### Post date: [January 5, 2022, 3:36am UTC](https://meta.discourse.org/t/topic-event-webhook-broken-false-topic-created-messages/213884/1 "2022-01-05T03:36:44Z")

</div>

I want to take some action when there is a new topic. So I have a webhook enabled for Topic Events. I check the headers to see whether it’s a topic\_created event, and if so, I take action.

This worked for many months but now fails sometimes, possibly after upgrading last week. Now sometimes I get topic\_created in the headers, however the topic is actually old and someone simply replied to the topic.

My code:

```plaintext
    event_type = request.headers['X-Discourse-Event-Type']
    event = request.headers['X-Discourse-Event']
    if event_type == 'topic' and event == 'topic_created':
         take_action()

```

Example payload from a request that had event == ‘topic\_created’ in the headers. Note the alleged “new” topic actually was created in 2017 and has 306 replies.

> **payload**
>
> ```plaintext
> {
> 'bookmarked': False,
> 'word_count': 272108,
> 'visible': True,
> 'like_count': 567,
> 'highest_post_number': 758,
> 'has_deleted': True,
> 'tags_descriptions': {},
> 'deleted_at': None,
> 'archetype': 'regular',
> 'id': 1357,
> 'pinned_until': None,
> 'archived': False,
> 'user_id': 4,
> 'title': 'Tax Time! Discussions of Taxes and Accountants',
> 'last_posted_at': '2022-01-05T01:41:26.000Z',
> 'tags': [],
> 'created_by': {
> 'username': 'redacted',
> 'avatar_template': '/user_avatar/forum.redacted.com/redacted/{size}/45_2.png',
> 'id': 4,
> 'name': 'redacted'
> },
> 'pinned': False,
> 'queued_posts_count': 0,
> 'closed': False,
> 'unpinned': None,
> 'participant_count': 162,
> 'views': 19557,
> 'pinned_at': None,
> 'last_poster': {
> 'username': 'redacted',
> 'avatar_template': '/letter_avatar_proxy/v4/letter/j/45deac/{size}.png',
> 'id': 142,
> 'name': 'JohnJacobs'
> },
> 'pending_posts': [],
> 'posts_count': 744,
> 'slug': 'tax-time-discussions-of-taxes-and-accountants',
> 'thumbnails': None,
> 'created_at': '2017-01-21T00:25:01.000Z',
> 'deleted_by': None,
> 'featured_link': None,
> 'reply_count': 306,
> 'pinned_globally': False,
> 'category_id': 16,
> 'fancy_title': 'Tax Time! Discussions of Taxes and Accountants'
> }
> 
> ```

---

<div class="post-metadata">

### Author: ![Mark\_Schmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mark_schmucker/32/124810_2.png) [@Mark\_Schmucker](https://meta.discourse.org/u/Mark_Schmucker)
#### Post date: [January 6, 2022, 9:35am UTC](https://meta.discourse.org/t/topic-event-webhook-broken-false-topic-created-messages/213884/4 "2022-01-06T09:35:13Z")

</div>

There is some evidence the false topic\_created messages are triggered when someone replies by email.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [January 7, 2022, 4:40am UTC](https://meta.discourse.org/t/topic-event-webhook-broken-false-topic-created-messages/213884/5 "2022-01-07T04:40:30Z")

</div>

I added a fix here

[https://github.com/discourse/discourse/pull/15485](https://github.com/discourse/discourse/pull/15485)

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [January 11, 2022, 2:30am UTC](https://meta.discourse.org/t/topic-event-webhook-broken-false-topic-created-messages/213884/6 "2022-01-11T02:30:01Z")

</div>

This topic was automatically closed after 18 hours. New replies are no longer allowed.
