Zrzur Developers

Webhooks

A webhook posts messages into one channel. It needs no bot, no gateway connection and no library: one HTTP request with its address is enough, so it suits a CI job, a monitoring script, a form or a news feed. A bot can make webhooks too, and only webhooks a bot made can carry buttons and menus.

A webhook posts into one channel without a gateway connection. Create one with a bot token or in server settings (needs Manage Webhooks). The answer has token and url. They are shown once: the server keeps only a hash, so save them now. A lost token can only be replaced.

curl -X POST "https://api.zrzur.com/webhooks/$WEBHOOK_ID/$WEBHOOK_TOKEN?wait=true" \
  -H "content-type: application/json" \
  -d '{"content": "Build finished", "username": "CI"}'

Anyone with the address can post, so treat it like a password. Tokens start with zrzur_wh_, so secret scanners can find a leaked one. POST /webhooks/{webhook_id}/token makes a new token; the old one stops at once.

Sending

POST /webhooks/{webhook_id}/{token} answers 204. With ?wait=true it returns the message.

FieldMeaning
contentUp to 2000 characters. A message needs at least one of content, embeds, attachments, components
usernameName on this message, 1 to 80 characters. The webhook mark stays
avatar_urlAvatar on this message, a public web address. Clients load it through the media proxy, which checks it
embedsUp to 10, 6000 characters in total. type is ignored: embeds are always rich
allowed_mentionsWhich mentions may notify anyone. { "parse": [] } turns them all off
flags4 hides link previews, 4096 sends without a notification
thread_idQuery parameter: post into this thread of the webhook's channel
thread_nameForum: start a thread with this name. applied_tags sets its tags. A forum without either answers ForumThreadRequired

Embeds take title (256), description (4096), url, color (a number) or colour (CSS text), timestamp, author (name 256), footer (text 2048), up to 25 fields (name 256, value 1024), image.url, thumbnail.url.

To send files, use multipart/form-data with files[0], files[1], ... and the JSON body in payload_json. Each file passes the same checks as a member's upload. Up to 5 files of 20 MB; refer to one from an embed with attachment://name.png. A webhook without Upload Files gets 403, never a message without its files.

@everyone, @online and role mentions notify people only if the webhook has the matching permission and allowed_mentions allows them. New webhooks have neither permission, and the text is still posted. Edits never notify anyone.

Interactive components work only on webhooks a bot created, and clicks go to that bot. Other webhooks can post links, text and media.

Editing a webhook

PATCH /webhooks/{webhook_id} with Manage Webhooks changes the name, avatar, permissions and channel, and takes X-Audit-Log-Reason. With the token, PATCH /webhooks/{webhook_id}/{token} changes only the name and avatar; permissions or channel_id there answer 403. GET with the token leaves out who made it. Names have 1 to 80 characters and cannot contain hidden characters or pass for Zrzur, its staff or a verified bot.

Its own messages

GET, PATCH and DELETE /webhooks/{webhook_id}/{token}/messages/{message_id} work on messages this webhook sent, and no others.

In a thread a webhook needs SendMessageInThreads, and CreateForumPosts to start a forum post. What the roles of its creator deny is denied to it too. Where threads or forums are switched off it can't send or edit, but it can delete its own messages.

Limits

Each channel has up to 15 webhooks (TooManyChannelWebhooks) and each server up to 1000 (TooManyServerWebhooks).

One webhook sends 5 messages in 2 seconds, and all webhooks of a channel 30 a minute. Over that, the answer is 429 with { "type": "RateLimited", "retry_after": 1200, "global": false } (milliseconds) and the X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset-After and Retry-After headers. After 20 wrong tokens in a minute an address waits, even with a right token.

AutoMod reads webhook messages and their embeds, on edits too. Moderators can delete and report them like any message.

Other formats

Nothing from these two formats notifies anyone.

Making and managing webhooks

All of these need Manage Webhooks in the channel, and work with a bot token or a person's session.

RequestWhat it does
POST /channels/{channel_id}/webhooksMake a webhook: { "name": "CI", "avatar": "<file id>" }. The answer has token and url, shown this once
GET /channels/{channel_id}/webhooksThe webhooks of one channel, without tokens
GET /servers/{target}/webhooksThe webhooks of every channel of the server where you have Manage Webhooks, newest first, without tokens
GET /webhooks/{webhook_id}One webhook, with who made it
PATCH /webhooks/{webhook_id}Name, avatar, permissions, or move it to another channel of the server
POST /webhooks/{webhook_id}/tokenA new token: the old one stops at once. Keep the token of the answer
POST /webhooks/{webhook_id}/testPost a test message without the token: { "content": "Test" }, 1 to 200 characters. It sends no notification and mentions nobody, and returns the message
DELETE /webhooks/{webhook_id}Remove it. Its messages stay

With the token instead (no login): GET, PATCH (name and avatar only) and DELETE /webhooks/{webhook_id}/{token}.

A new token and a test message count in a small bucket of their own, webhook_manage: 5 per 10 seconds for each webhook. They do not use up the room of the messages sent through it.

Events

The gateway sends WebhookCreate, WebhookUpdate and WebhookDelete only to those who may manage the channel's webhooks, and to bots only with the SERVERS intent. Messages sent through a webhook arrive as ordinary Message events, with webhook: { name, avatar } on the message. See the Event reference.

Common errors

ErrorCauseFix
401 NotAuthenticated or 404 NotFoundThe token is wrong or was replacedUse the latest token; make a new one if it is lost
403 MissingPermissionNo Manage Webhooks (managing), or the webhook lacks Upload Files (files)Give the permission in the channel
400 TooManyChannelWebhooks15 webhooks in this channel alreadyRemove one you no longer use
429 RateLimitedMore than 5 messages in 2 seconds, or 30 a minute in the channelWait retry_after milliseconds
400 FeatureDisabledWebhooks are switched off on this server installationAsk its operator

Reference

GET /channels/{channel_id}/webhooks

Gets all webhooks. Gets all webhooks inside the channel. Their tokens are not included.

Permissions: Channel:ManageWebhooks · Rate limit: channels, 15 / 10 s

POST /channels/{channel_id}/webhooks

Creates a webhook. Creates a webhook which 3rd party platforms can use to send messages

Permissions: Channel:ManageWebhooks · Rate limit: channels, 15 / 10 s

GET /servers/{target}/webhooks

Gets a server's webhooks. Webhooks of every channel of the server where you have Manage Webhooks, newest first. Their tokens are not included.

Permissions: Channel:ManageWebhooks · Rate limit: servers, 5 / 10 s

DELETE /webhooks/{webhook_id}

Deletes a webhook. Deletes a webhook

Permissions: Channel:ManageWebhooks · Rate limit: any_dlta, 20 / 10 s

GET /webhooks/{webhook_id}

Gets a webhook. Gets a webhook, for those who may manage it. Its token is never included.

Permissions: Channel:ManageWebhooks · Rate limit: any_dlta, 20 / 10 s

PATCH /webhooks/{webhook_id}

Edits a webhook. Edits a webhook: name, avatar, permissions, channel. Moving it needs Manage Webhooks in both channels, within the same server.

Permissions: Channel:ManageWebhooks · Rate limit: any_dlta, 20 / 10 s

DELETE /webhooks/{webhook_id}/{token}

Deletes a webhook. Deletes a webhook with a token

Rate limit: any_dlta, 20 / 10 s

GET /webhooks/{webhook_id}/{token}

Gets a webhook. Gets a webhook with its token. Who made it is not included.

Rate limit: any_dlta, 20 / 10 s

PATCH /webhooks/{webhook_id}/{token}

Edits a webhook. Edits a webhook's name and avatar with its token. Its permissions and channel can only be changed by a manager.

Rate limit: any_dlta, 20 / 10 s

POST /webhooks/{webhook_id}/{token}

Executes a webhook. Sends a message. Answers 204 unless wait=true, which returns the message. thread_id posts into a thread of the webhook's channel.

Rate limit: any_dlta, 20 / 10 s

DELETE /webhooks/{webhook_id}/{token}/{message_id}

Deletes a webhook message (short path). As /messages/{message_id}

Rate limit: any_dlta, 20 / 10 s

PATCH /webhooks/{webhook_id}/{token}/{message_id}

Edits a webhook message (short path). As /messages/{message_id}

Rate limit: any_dlta, 20 / 10 s

POST /webhooks/{webhook_id}/{token}/github

Executes a webhook specific to github. Takes a GitHub webhook delivery and posts what happened. Events and actions that show nothing answer 204 too, so GitHub keeps the hook healthy.

Rate limit: any_dlta, 20 / 10 s

DELETE /webhooks/{webhook_id}/{token}/messages/{message_id}

Deletes a webhook message. Deletes a message this webhook sent

Rate limit: any_dlta, 20 / 10 s

GET /webhooks/{webhook_id}/{token}/messages/{message_id}

Fetches a webhook message. Fetches a message this webhook sent

Rate limit: any_dlta, 20 / 10 s

PATCH /webhooks/{webhook_id}/{token}/messages/{message_id}

Edits a webhook message. Edits a message this webhook sent

Rate limit: any_dlta, 20 / 10 s

POST /webhooks/{webhook_id}/{token}/slack

Executes a webhook in Slack's format. Takes what a Slack incoming webhook takes (text, attachments, blocks, username, icon_url), as JSON or as payload=<json>. Returns the message unless wait=false, which answers 204.

Rate limit: any_dlta, 20 / 10 s

POST /webhooks/{webhook_id}/test

Sends a test message. Posts a short message through a webhook, for those who manage it: they have no token to do it with, since it is only shown when made.

Permissions: Channel:ManageWebhooks · Rate limit: any_dlta, 20 / 10 s

POST /webhooks/{webhook_id}/token

Regenerates a webhook's token. Makes a new token. The old one stops working at once. The answer is the only time the new token is shown.

Permissions: Channel:ManageWebhooks · Rate limit: any_dlta, 20 / 10 s