Push Webhook

Using the Push webhook, you can receive payloads of all events from your application. When configured, every event in the Chat application will propagate to your webhook endpoint. The complete list of supported events can be found on Events page.

Use-cases

Push webhooks are useful when you want your server application to be in sync with the chat. Here are some examples:

  • Implementing a complex notification system (e.g. involving SMS and/or e-mail)

  • Migration from a different chat provider to Stream Chat without disruption

  • User activity monitoring

Request format

Your endpoint will receive a POST request with a JSON encoded body containing the event and all corresponding fields:

{
  "type": "message.new",
  "cid": "messaging:fun-d5f396e3-fbaf-469c-9b45-8837b4f75baa",
  "message": {
    "id": "8bffc454-e1da-4d91-8b88-a87853dfb41c",
    "text": "67d61fa4-74b6-4e1a-bfe7-589d84b8215b",
    "html": "<p>67d61fa4-74b6-4e1a-bfe7-589d84b8215b</p>\n",
    "type": "regular",
    "user": {
      "id": "tommaso-52ec3a5f-e916-469f-bf54-b53b5247a4b0",
      "role": "user",
      "created_at": "2020-03-30T07:54:46.207332Z",
      "updated_at": "2020-03-30T07:54:46.207719Z",
      "banned": false,
      "online": false
    },
    "attachments": [],
    "latest_reactions": [],
    "own_reactions": [],
    "reaction_counts": null,
    "reaction_scores": {},
    "reply_count": 0,
    "created_at": "2020-03-30T07:54:46.277381Z",
    "updated_at": "2020-03-30T07:54:46.277382Z",
    "mentioned_users": []
  },
  "user": {
    "id": "tommaso-52ec3a5f-e916-469f-bf54-b53b5247a4b0",
    "role": "user",
    "created_at": "2020-03-30T07:54:46.207332Z",
    "updated_at": "2020-03-30T07:54:46.207719Z",
    "banned": false,
    "online": false,
    "channel_unread_count": 0,
    "channel_last_read_at": "2020-03-30T07:54:46.270208768Z",
    "total_unread_count": 0,
    "unread_channels": 0,
    "unread_count": 0
  },
  "created_at": "2020-03-30T07:54:46.295138Z",
  "members": [
    {
      "user_id": "thierry-735d0d44-8bf1-40df-81db-fa83363ac790",
      "user": ["Object"],
      "created_at": "2020-03-30T07:54:46.255628Z",
      "updated_at": "2020-03-30T07:54:46.255628Z"
    },
    {
      "user_id": "tommaso-52ec3a5f-e916-469f-bf54-b53b5247a4b0",
      "user": ["Object"],
      "created_at": "2020-03-30T07:54:46.256118Z",
      "updated_at": "2020-03-30T07:54:46.256118Z",
      "notifications_muted": true // user muted this channel
    }
  ],
  "channel_type": "messaging",
  "channel_id": "fun-d5f396e3-fbaf-469c-9b45-8837b4f75baa"
}

See more payload examples on Events page.

Performance and Error Handling

In case of the request failure Stream Chat attempts to retry a request. The amount of maximum attempts depends on the kind of the error it receives:

  • Response code is 408, 429 or >=500: 3 attempts

  • Network error: 2 attempts

  • Request timeout: 3 attempts

The timeout of one request is 6 seconds, and the request with all retries cannot exceed the duration of 15 seconds.

© Getstream.io, Inc. All Rights Reserved.