This section defines the messages that the EventSub WebSocket server sends your client.
All timestamps are in RFC3339 format and use nanoseconds instead of milliseconds.
Welcome message
Defines the first message that the EventSub WebSocket server sends after your client connects to the server. Read More
Message Type
- Type
session_welcome
Message Fields
metadataObjectAn object that identifies the message.Hide child attributesShow child attributes
metadata.message_idStringAn ID that uniquely identifies the message. Twitch sends messages at least once, but if Twitch is unsure of whether you received a notification, it’ll resend the message. This means you may receive a notification twice. If Twitch resends the message, the message ID will be the same.metadata.message_typeStringThe type of message, which is set to session_welcome.metadata.message_timestampStringThe UTC date and time that the message was sent.
payloadObjectAn object that contains the message.Hide child attributesShow child attributes
payload.sessionObjectAn object that contains information about the connection.Hide child attributesShow child attributes
payload.session.idStringAn ID that uniquely identifies this WebSocket connection. Use this ID to set the session_id field in all subscription requests.payload.session.statusStringThe connection's status, which is set to connected.payload.session.keepalive_timeout_secondsIntegerThe maximum number of seconds that you should expect silence before receiving a keepalive message. For a welcome message, this is the number of seconds that you have to subscribe to an event after receiving the welcome message. If you don't subscribe to an event within this window, the socket is disconnected.payload.session.reconnect_urlStringNullableThe URL to reconnect to if you get a Reconnect message. Is set to null.payload.session.connected_atStringThe UTC date and time that the connection was created.
{
"metadata": {
"message_id": "96a3f3b5-5dec-4eed-908e-e11ee657416c",
"message_type": "session_welcome",
"message_timestamp": "2023-07-19T14:56:51.634234626Z"
},
"payload": {
"session": {
"id": "AQoQILE98gtqShGmLD7AM6yJThAB",
"status": "connected",
"connected_at": "2023-07-19T14:56:51.616329898Z",
"keepalive_timeout_seconds": 10,
"reconnect_url": null
}
}
}Keepalive message
Defines the message that the EventSub WebSocket server sends your client to indicate that the WebSocket connection is healthy. Read More
Message Type
- Type
session_keepalive
Message Fields
metadataObjectAn object that identifies the message.Hide child attributesShow child attributes
metadata.message_idStringAn ID that uniquely identifies the message. Twitch sends messages at least once, but if Twitch is unsure of whether you received a notification, it’ll resend the message. This means you may receive a notification twice. If Twitch resends the message, the message ID is the same.metadata.message_typeStringThe type of message, which is set to session_keepalive.metadata.message_timestampStringThe UTC date and time that the message was sent.
payloadObjectAn empty object.
{
"metadata": {
"message_id": "84c1e79a-2a4b-4c13-ba0b-4312293e9308",
"message_type": "session_keepalive",
"message_timestamp": "2023-07-19T10:11:12.634234626Z"
},
"payload": {}
}Notification message
Defines a message that the EventSub WebSocket server sends your client when an event that you subscribe to occurs. Read More
Message Type
- Type
notification
Message Fields
metadataObjectAn object that identifies the message.Hide child attributesShow child attributes
metadata.message_idStringAn ID that uniquely identifies the message. Twitch sends messages at least once, but if Twitch is unsure of whether you received a notification, it’ll resend the message. This means you may receive a notification twice. If Twitch resends the message, the message ID will be the same.metadata.message_typeStringThe type of message, which is set to notification.metadata.message_timestampStringThe UTC date and time that the message was sent.metadata.subscription_typeStringThe type of event sent in the message.metadata.subscription_versionStringThe version number of the subscription type's definition. This is the same value specified in the subscription request.
payloadObjectAn object that contains the message.Hide child attributesShow child attributes
payload.subscriptionObjectAn object that contains information about your subscription.Hide child attributesShow child attributes
payload.subscription.idStringAn ID that uniquely identifies this subscription.payload.subscription.statusStringThe subscription's status, which is set to enabled.payload.subscription.typeStringThe type of event sent in the message. See theeventfield.payload.subscription.versionStringThe version number of the subscription type's definition.payload.subscription.costIntegerThe event's cost. See Subscription limits.payload.subscription.conditionObjectThe conditions under which the event fires. For example, if you requested notifications when a broadcaster gets a new follower, this object contains the broadcaster’s ID. For information about the condition's data, see the subscription type's description in Subscription types.payload.subscription.transportObjectAn object that contains information about the transport used for notifications.Hide child attributesShow child attributes
payload.subscription.transport.methodStringThe transport method, which is set to websocket.payload.subscription.transport.session_idStringAn ID that uniquely identifies the WebSocket connection.
payload.subscription.created_atStringThe UTC date and time that the subscription was created.
payload.eventObjectThe event's data. For information about the event's data, see the subscription type's description in Subscription Types.
{
"metadata": {
"message_id": "befa7b53-d79d-478f-86b9-120f112b044e",
"message_type": "notification",
"message_timestamp": "2022-11-16T10:11:12.464757833Z",
"subscription_type": "channel.follow",
"subscription_version": "1"
},
"payload": {
"subscription": {
"id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
"status": "enabled",
"type": "channel.follow",
"version": "2",
"cost": 0,
"condition": {
"broadcaster_user_id": "12826",
"moderator_user_id": "12826"
},
"transport": {
"method": "websocket",
"session_id": "AQoQexAWVYKSTIu4ec_2VAxyuhAB"
},
"created_at": "2022-11-16T10:11:12.464757833Z"
},
"event": {
"user_id": "1337",
"user_login": "awesome_user",
"user_name": "Awesome_User",
"broadcaster_user_id": "12826",
"broadcaster_user_login": "twitch",
"broadcaster_user_name": "Twitch",
"followed_at": "2023-07-15T18:16:11.17106713Z"
}
}
}Reconnect message
Defines the message that the EventSub WebSocket server sends if the server must drop the connection. Read More
Message Type
- Type
session_reconnect
Message Fields
metadataObjectAn object that identifies the message.Hide child attributesShow child attributes
metadata.message_idStringAn ID that uniquely identifies the message. Twitch sends messages at least once, but if Twitch is unsure of whether you received a notification, it’ll resend the message. This means you may receive a notification twice. If Twitch resends the message, the message ID will be the same.metadata.message_typeStringThe type of message, which is set to session_reconnect.metadata.message_timestampStringThe UTC date and time that the message was sent.
payloadObjectAn object that contains the message.Hide child attributesShow child attributes
payload.sessionObjectAn object that contains information about the connection.Hide child attributesShow child attributes
payload.session.idStringAn ID that uniquely identifies this WebSocket connection.payload.session.statusStringThe connection's status, which is set to reconnecting.payload.session.keepalive_timeout_secondsIntegerNullableIs set to null.payload.session.reconnect_urlStringThe URL to reconnect to. Use this URL as is; do not modify it. The connection automatically includes the subscriptions from the old connection.payload.session.connected_atStringThe UTC date and time when the connection was created.
{
"metadata": {
"message_id": "84c1e79a-2a4b-4c13-ba0b-4312293e9308",
"message_type": "session_reconnect",
"message_timestamp": "2022-11-18T09:10:11.634234626Z"
},
"payload": {
"session": {
"id": "AQoQexAWVYKSTIu4ec_2VAxyuhAB",
"status": "reconnecting",
"keepalive_timeout_seconds": null,
"reconnect_url": "wss://eventsub.wss.twitch.tv?...",
"connected_at": "2022-11-16T10:11:12.634234626Z"
}
}
}Revocation message
Defines the message that the EventSub WebSocket server sends if the user no longer exists or they revoked the authorization token that the subscription relied on. Read More
Message Type
- Type
revocation
Message Fields
metadataObjectAn object that identifies the message.Hide child attributesShow child attributes
metadata.message_idStringAn ID that uniquely identifies the message. Twitch sends messages at least once, but if Twitch is unsure of whether you received a notification, it’ll resend the message. This means you may receive a notification twice. If Twitch resends the message, the message ID will be the same.metadata.message_typeStringThe type of message, which is set to revocation.metadata.message_timestampStringThe UTC date and time that the message was sent.metadata.subscription_typeStringThe type of event sent in the message.metadata.subscription_versionStringThe version number of the subscription type's definition. This is the same value specified in the subscription request.
payloadObjectAn object that contains the message.Hide child attributesShow child attributes
payload.subscriptionObjectAn object that contains information about your subscription.Hide child attributesShow child attributes
payload.subscription.idStringAn ID that uniquely identifies this subscription.payload.subscription.statusStringThe subscription's status.Possible values
authorization_revokedThe user in the condition object revoked the authorization that let you get events on their behalf.user_removedThe user in the condition object is no longer a Twitch user.version_removedThe subscribed to subscription type and version is no longer supported.
payload.subscription.typeStringThe type of event sent in the message.payload.subscription.versionStringThe version number of the subscription type's definition.payload.subscription.costIntegerThe event's cost. See Subscription limits.payload.subscription.conditionObjectThe conditions under which the event fires. For example, if you requested notifications when a broadcaster gets a new follower, this object contains the broadcaster’s ID. For information about the condition's data, see the subscription type's description in Subscription Types.payload.subscription.transportObjectAn object that contains information about the transport used for notifications.Hide child attributesShow child attributes
payload.subscription.transport.methodStringThe transport method, which is set to websocket.payload.subscription.transport.session_idStringAn ID that uniquely identifies the WebSocket connection.
payload.subscription.created_atStringThe UTC date and time that the subscription was created.
{
"metadata": {
"message_id": "84c1e79a-2a4b-4c13-ba0b-4312293e9308",
"message_type": "revocation",
"message_timestamp": "2022-11-16T10:11:12.464757833Z",
"subscription_type": "channel.follow",
"subscription_version": "1"
},
"payload": {
"subscription": {
"id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
"status": "authorization_revoked",
"type": "channel.follow",
"version": "2",
"cost": 0,
"condition": {
"broadcaster_user_id": "12826",
"moderator_user_id": "12826"
},
"transport": {
"method": "websocket",
"session_id": "AQoQexAWVYKSTIu4ec_2VAxyuhAB"
},
"created_at": "2022-11-16T10:11:12.464757833Z"
}
}
}Close message
A standard WebSocket Close frame. Read More
The following table lists the reasons for closing the connection.
Close Codes
- 4000Internal server error
- Indicates a problem with the server (similar to an HTTP 500 status code).
- 4001Client sent inbound traffic
- Sending outgoing messages to the server is prohibited with the exception of pong messages.
- 4002Client failed ping-pong
- You must respond to ping messages with a pong message. See Ping message.
- 4003Connection unused
- When you connect to the server, you must create a subscription within 10 seconds or the connection is closed. The time limit is subject to change.
- 4004Reconnect grace time expired
- When you receive a session_reconnect message, you have 30 seconds to reconnect to the server and close the old connection. See Reconnect message.
- 4005Network timeout
- Transient network timeout.
- 4006Network error
- Transient network error.
- 4007Invalid reconnect
- The reconnect URL is invalid.