ScreenShared API
Build bots and integrations for ScreenShared guilds. The platform follows Discord's concepts, numbers and names wherever it can, so porting a bot is mostly a matter of changing URLs.
- Incoming webhooks: a secret URL per channel. Anything that speaks "Discord webhook" (Grafana, Uptime Kuma, GitHub Actions, n8n, Home Assistant, curl) works by swapping the URL.
- REST API (
https://apiscreen.screenshared.io/v1): read guilds, channels, members and messages; send, edit and delete messages with embeds. - Gateway (
wss://apiscreen.screenshared.io/v1/gateway/ws): real-time events with Discord-style opcodes and intents.
- Components and Components V2: buttons, select menus, containers, sections, text, thumbnails, galleries and separators, in Discord's format.
- Slash commands, interactions and modals: the same request/response model as Discord.
Quick start
- Open the developer portal and create an application. Creating applications requires an active account VIP; the bot only runs while its creator's VIP is active.
- Copy the bot token. It is shown once. Anyone holding it controls the bot.
- Pick the permissions the bot needs, copy the install link and open it to add the bot to a guild you manage.
- Call the REST API or connect to the gateway with the token.
curl -H "Authorization: Bot $TOKEN" https://apiscreen.screenshared.io/v1/users/@me
Authentication
Every REST request and the gateway IDENTIFY use the bot token:
Authorization: Bot ssb.<application id>.<secret>
- Only a hash of the token is stored. If you lose it, generate a new one in the portal; the old one stops working immediately and open gateway sessions close with
4021. - The API never reads cookies and has no CORS: call it from your server, not from a browser page.
- Bot accounts cannot log in to the website and cannot receive direct messages.
Incoming webhooks
Create a webhook in a text channel: Channel settings → Integrations → New webhook (requires Manage webhooks). The URL looks like:
https://apiscreen.screenshared.io/webhooks/<id>/<token>
Treat the URL as a password: whoever has it can post in the channel. "Generate new URL" invalidates the old one at once. A webhook posts in its channel regardless of channel permissions; only a frozen guild blocks it.
Execute
POST /webhooks/{id}/{token} Optional ?wait=true returns the created message (200); otherwise 204.
| Body | How it is read |
|---|---|
application/json | Discord format: {content, username, embeds}. avatar_url, tts and thread_id are ignored. flags: 4 (SUPPRESS_EMBEDS, no link previews) and 32768 (Components V2). Slack's {text} also works. |
text/plain | The whole body becomes the message. |
# JSON (Discord format) with an embed
curl -H "Content-Type: application/json" \
-d '{"username":"CI","content":"Deploy finished","embeds":[{"title":"main @ 3f2a1c","description":"**42** tests passed","color":4180863}]}' \
"https://apiscreen.screenshared.io/webhooks/ID/TOKEN?wait=true"
# Plain text
curl -d "backup ok" https://apiscreen.screenshared.io/webhooks/ID/TOKEN
# PowerShell
Invoke-RestMethod -Method Post -ContentType "application/json" `
-Uri "https://apiscreen.screenshared.io/webhooks/ID/TOKEN" `
-Body (@{ content = "Hello from PowerShell" } | ConvertTo-Json)
Rules
content: up to 2000 characters and 40 lines.username: up to 32 characters; names impersonating the platform or staff fall back to the webhook name.@everyoneand@herenever ping from a webhook. Only the first 5 user mentions ping.- Messages show a permanent WEBHOOK tag.
- Embed images go through ScreenShared's own proxy, so readers' IP addresses never reach the image host. Only well-known image hosts are accepted; an image from anywhere else becomes a link.
| Status | error | When |
|---|---|---|
| 204 / 200 | Posted (200 with ?wait=true) | |
| 400 | invalid_body | Bad JSON, nothing to post, embed limits exceeded |
| 403 | guild_frozen | The guild's plan expired |
| 404 | unknown_webhook | Wrong id or token (we don't say which) |
| 413 | too_large | Body over 64 KB |
| 429 | rate_limited | More than 30 messages per minute per webhook (120 per channel) |
| 503 | webhooks_paused | Paused by the platform administrators |
Outgoing webhooks
A guild can notify your own system (n8n, Zapier, a server) when something happens. Set it up in Guild settings → Integrations → Outgoing webhooks (requires Manage guild): an https:// URL and the events you want.
POST https://your-server.example/webhook
Content-Type: application/json
User-Agent: ScreenShared-Hooks/1.0
X-SS-Hook-Id: h3…
X-SS-Delivery: dlv_8f…
X-SS-Event: msg.create
X-SS-Timestamp: 1764090000
X-SS-Signature: v1=<hex HMAC-SHA256(secret, timestamp + "." + body)>
{ "id": "dlv_8f…", "type": "msg.create", "guild_id": "g1…", "at": 1764090000000,
"data": { "channel_id": "c8…", "user": { "id": "u3…", "name": "Bruna" }, "message": { …Message object… } } }
Events: msg.create, msg.edit, msg.delete, react.add, react.remove, member.join, member.leave, member.kick, member.ban, member.update, voice.join, voice.leave, voice.move, channel.create/update/delete, role.create/update/delete, ticket.open, ticket.close, and ping (the "Test" button).
- Verify every request: recompute the HMAC with the secret (copy it in the settings) and compare in constant time; reject timestamps older than 5 minutes.
- Respond with any 2xx within 5 seconds. Network errors, 5xx, 408 and 429 are retried after 10 s, 1 min and 5 min; redirects are not followed. After 20 consecutive failures the webhook is turned off (turn it back on in the settings).
- A webhook never sees more than the person who created it: events from channels they can't see are not sent, and if they lose Manage guild it turns off.
- Internal and private addresses (and ScreenShared itself) are refused.
// Node.js: verify the signature
import crypto from 'node:crypto';
function verify(req, rawBody, secret) {
const ts = req.headers['x-ss-timestamp'];
if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
const mac = crypto.createHmac('sha256', secret).update(ts + '.' + rawBody).digest('hex');
const got = String(req.headers['x-ss-signature'] || '').replace('v1=', '');
return got.length === mac.length && crypto.timingSafeEqual(Buffer.from(got), Buffer.from(mac));
}
REST conventions
- Base URL:
https://apiscreen.screenshared.io/v1 - Format: JSON (UTF-8), bodies up to 64 KB.
- IDs are strings, except message IDs, which are integers per channel. Message routes therefore always include the channel.
- Times are Unix milliseconds (
created_at,edited_at). Embedtimestampaccepts ISO 8601 or milliseconds. - New fields may appear at any time: ignore what you don't know.
Errors
{ "error": "missing_permission", "message": "Falta a permissão \"Mandar mensagens\" neste canal.", "need": ["send"] }
error is a stable machine code; message is a human-readable text (Portuguese).
| HTTP | error | Meaning |
|---|---|---|
| 400 | invalid_body, invalid_channel | Malformed request or wrong channel type |
| 400 | invalid_reference | message_reference points to a message that doesn't exist, can't be replied to, or is in another channel |
| 401 | invalid_token | Missing, malformed or rotated token |
| 403 | missing_permission | The bot lacks a permission in that channel or guild |
| 400 | cannot_edit | Forwarded messages and polls can't be edited |
| 400 | invalid_poll, poll_expired | A poll that breaks the rules below (message says which one); ending a poll that already ended |
| 400 | cannot_forward | That message can't be forwarded there (system message, AutoMod, file limits…); message says why |
| 400 | unknown_emoji, too_many_reactions | Emoji the bot can't use; 20 different emojis already on the message |
| 403 | missing_content | Forwarding needs to be able to read the original (MESSAGE_CONTENT) |
| 413 | too_large | File over the size limit |
| 403 | not_author | Editing a message the bot didn't send |
| 403 | guild_frozen | The guild's plan expired |
| 403 | app_disabled | The application was disabled by the administrators |
| 403 | owner_not_vip | The creator's account VIP is not active; the bot is paused until it is |
| 404 | unknown_guild, unknown_channel, unknown_message, unknown_member | Doesn't exist or the bot can't see it |
| 429 | rate_limited | See rate limits |
| 503 | bots_paused | The bot platform is paused by the administrators |
Rate limits
Buckets are per application (not per IP). Every response carries:
X-RateLimit-Bucket: msg:c8xYz
X-RateLimit-Limit: 10
X-RateLimit-Remaining: 7
X-RateLimit-Reset-After: 3.250
Retry-After: 4 (only on 429, whole seconds)
| Bucket | Limit |
|---|---|
global | 50 requests / second |
msg:<channel> | 10 messages / 10 s |
msg-guild:<guild> | 30 messages / 10 s |
edit-del:<channel> | 20 / 10 s |
read | 300 GET / minute |
| invalid tokens | 20 / minute per IP |
A 429 body: {"error":"rate_limited","retry_after":3.25,"bucket":"msg:c8xYz","global":false}
Endpoints
| Method | Route | Needs |
|---|---|---|
| GET | /users/@me | The bot user + application |
| GET | /users/@me/guilds | Guilds the bot is in |
| DELETE | /users/@me/guilds/{guild} | Leave a guild (uninstall) |
| GET | /guilds/{guild} | Bot in the guild |
| GET | /guilds/{guild}/channels | Only channels the bot can view |
| GET | /guilds/{guild}/members?after=&limit= | Sorted by user id, limit 1–1000 (default 100) |
| GET | /guilds/{guild}/members/{user} | |
| GET | /channels/{channel} | View channel |
| GET | /channels/{channel}/messages?before=&after=&limit= | View + Read history; ascending ids, limit 1–100 (default 50) |
| GET | /channels/{channel}/messages/{id} | View + Read history |
| POST | /channels/{channel}/messages | View + Send messages |
| PATCH | /channels/{channel}/messages/{id} | Author must be the bot |
| DELETE | /channels/{channel}/messages/{id} | Own message, or Manage messages |
| GET | /channels/{channel}/pins | View + Read history; pinned messages, most recently pinned first (/channels/{channel}/messages/pins answers {items: [{pinned_at, message}], has_more}) |
| PUT | /channels/{channel}/pins/{id} | Manage messages; 204. Up to 250 per channel; posts the "pinned a message" notice (type 6) |
| DELETE | /channels/{channel}/pins/{id} | Manage messages; 204 (also /messages/pins/{id}) |
| GET | /channels/{channel}/messages/{id}/reactions/{emoji} | View + Read history; the accounts that reacted |
| PUT DELETE | /channels/{channel}/messages/{id}/reactions/{emoji}/@me | Add (Add reactions) or remove the bot's reaction; 204 |
| DELETE | /channels/{channel}/messages/{id}/reactions/{emoji}/{user} | Manage messages; 204 |
| GET | /channels/{channel}/polls/{id}/answers/{answer_id}?after=&limit= | View + Read history; {"users": [User]}, the accounts that voted for that answer (25 by default, up to 100) |
| POST | /channels/{channel}/polls/{id}/expire | Ends the bot's own poll now; returns the message |
| GET | /guilds/{guild}/emojis, /guilds/{guild}/emojis/{emoji} | Bot in the guild |
| POST | /guilds/{guild}/emojis {"name", "image": "data:image/png;base64,…"} | Manage emojis; 201. Up to 50 static + 50 animated |
| PATCH DELETE | /guilds/{guild}/emojis/{emoji} {"name"} | Manage emojis |
| GET | /gateway | No auth: the gateway URL |
{emoji} is URL-encoded: a Unicode emoji (%F0%9F%91%8D) or name:id for a guild emoji.
Send a message
POST /v1/channels/{channel}/messages
{
"content": "Hello <@USER_ID>!",
"embeds": [{ "title": "Status", "description": "All systems **operational**", "color": 3066993,
"fields": [{ "name": "Uptime", "value": "99.98%", "inline": true }] }],
"allowed_mentions": { "parse": ["users"] },
"nonce": "my-correlation-id"
}
contentup to 2000 characters; up to 20 user mentions ping.- Threads are channels of type
threadwithparent_id,owner_id,message_countandthread_metadata. Create one withPOST /channels/{id}/threadsorPOST /channels/{id}/messages/{message}/threads(name,auto_archive_duration: 60, 1440, 4320 or 10080), then use the returned id in every message endpoint. Channels carryrate_limit_per_user; bots are not slowed down. - A role mention,
<@&ROLE_ID>, pings the role's members when the role ismentionableor the bot has Manage messages. Withallowed_mentionspresent,parsemust contain"roles". @everyone/@hereonly ping withallowed_mentions.parsecontaining"everyone"and the bot having Manage messages in the channel.nonce(up to 40 characters) comes back in the gatewayMESSAGE_CREATEso you can match your own sends.
Reply to a message
Same shape as Discord. Add message_reference with the id of a message in the same channel:
POST /v1/channels/{channel}/messages
{
"content": "pong 🏓",
"message_reference": { "message_id": 1532, "fail_if_not_exists": true },
"allowed_mentions": { "parse": ["users"], "replied_user": false }
}
message_idmay be a number or a string.channel_idandguild_idare optional; if sent, they must be this channel and guild.- The author of the original gets a mention ping (like a reply with @ ON on the website) when
allowed_mentionsis absent, or when it hasreplied_user: true. Withallowed_mentionsand noreplied_user, there is no ping. - If the original doesn't exist (or is a system message), the request fails with
400 invalid_reference; withfail_if_not_exists: falsethe message is sent as a normal message instead. - Webhooks can't reply, as in Discord.
Guild emojis
Same text format as Discord: <:name:id>, or <a:name:id> when animated. A bot can use the emojis of every guild it is in; any other one becomes :name: as plain text. Image: https://screenshared.io/ge/{id} (logged-in people only).
Send a file
multipart/form-data with payload_json (the JSON above) and files[0]. One file per message for now. Needs Attach files. Give it a description with "attachments": [{ "id": 0, "description": "…" }] in payload_json, and mark it as a spoiler by starting the file name with SPOILER_. Webhooks can't send files.
Send a poll
POST /v1/channels/{channel}/messages
{ "poll": {
"question": { "text": "Which track on Saturday?" },
"answers": [ { "poll_media": { "text": "Mountain", "emoji": { "name": "🏔️" } } },
{ "poll_media": { "text": "Harbour at night", "emoji": { "id": "1234567890123456789", "name": "anchor" } } } ],
"duration": 48, "allow_multiselect": false, "layout_type": 1 } }
Same shape as Discord. Needs Send messages and Create polls. Question up to 300 characters, 2 to 10 different answers of up to 55, duration in hours (24 by default, up to 768). A poll goes alone: no content, embeds, components or file in the same message. Up to 10 answers can have an emoji: Unicode, or one of a guild the bot is in. Polls can't be edited or forwarded, and bots can't vote.
The message comes with content: "" and a poll object (gated by MESSAGE_CONTENT, like the text):
"poll": {
"question": { "text" }, "answers": [ { "answer_id": 1, "poll_media": { "text", "emoji": { "id", "name" } } } ],
"expiry": 1764262800000, // ms, like every other date in this API
"allow_multiselect": false, "layout_type": 1,
"results": { "is_finalized": false, "answer_counts": [ { "id": 1, "count": 3, "me_voted": false } ] } }
When it ends (by itself, with /expire or by a moderator) the message arrives again as MESSAGE_UPDATE with is_finalized: true, and a type 46 message (POLL_RESULT) is posted with message_reference to the poll and one embed of type: "poll_result", with the fields poll_question_text, victor_answer_votes, total_votes, and, unless it was a tie or nobody voted, victor_answer_id, victor_answer_text and victor_answer_emoji_name.
Forward a message
POST /v1/channels/{destination}/messages
{ "message_reference": { "type": 1, "channel_id": "c8…", "message_id": 1532 } }
- The bot must see the original (View + Read history) and be able to read its content; files are copied, so it needs Attach files in the destination if there are any.
- No
content,embedsorcomponentsin the same request: send another message after it. Mentions inside a forward never ping. - A forwarded message has
message_reference.type = 1and the copy inmessage_snapshots; its owncontent,embedsandattachmentsare empty. The guild, channel and message ids only come when the bot can open the original.
Message content
Without the privileged Message Content setting (enabled in the portal and shown on the authorization screen), a bot receives content, embeds and attachments empty, except for messages that mention the bot (a reply to the bot with ping counts as a mention) or that the bot itself sent. This applies to the REST API and the gateway, and to each referenced_message on its own.
Moderation
Same rules as people on the website: the bot's managed role needs the permission, and the target (member or role) must be below the bot's highest role. The guild owner can never be targeted. Add an optional reason with the X-Audit-Log-Reason header (or reason in the body); it shows up in the guild's audit log.
| Method | Route | Needs |
|---|---|---|
| DELETE | /guilds/{guild}/members/{user} | Kick members |
| PUT | /guilds/{guild}/bans/{user} {"reason"} | Ban members |
| DELETE | /guilds/{guild}/bans/{user} | Ban members |
| PUT DELETE | /guilds/{guild}/members/{user}/roles/{role} | Manage roles; the role below the bot's highest role |
| PATCH | /guilds/{guild}/members/{user} {"nick", "communication_disabled_until"} | Nick: Manage guild · Timeout: Moderate members (ISO 8601 up to 28 days; null removes it) |
All return 204. Errors: missing_permission, role_hierarchy, unknown_member, unknown_role. Bucket mod:<guild>: 30 per minute.
Objects
// Message
{
"id": 1532, "type": 0, "channel_id": "c8…", "guild_id": "g1…",
"author": { "id": "u3…", "name": "Bruna", "bot": false, "avatar": "/av/…" },
"webhook_id": "w9…", // only on webhook messages
"content": "hi <@u9…>", "embeds": [ … ], "attachments": [ { "id", "name", "size", "type", "url", "expires_at", "spoiler", "description" } ], // spoiler: the name comes with SPOILER_
"flags": 0, // 4 = someone removed the link previews (or they were suppressed)
"gif": { "provider": "klipy", "slug", "title", "url", "fallback_url", "preview_url", "width", "height" }, // only on messages sent from the GIF picker
"mentions": ["u9…"], "mention_roles": [], "mention_everyone": false, // a reply with ping lists the replied author here too
"reactions": [ { "emoji": "👍", "count": 2, "users": ["u3…", "u7…"] } ], // a guild emoji is an object: { "id", "name", "animated" }
"created_at": 1764090000000, "edited_at": null, "pinned": false
}
// Reply: "type": 19 plus
// "message_reference": { "message_id": 1530, "channel_id": "c8…", "guild_id": "g1…" },
// "referenced_message": { …Message object, as it is now… } | null // null = the original was deleted
// Forward: "message_reference": { "type": 1, … }, "message_snapshots": [ { "message": { type, content, embeds, attachments, created_at, mentions, flags } } ]
// Poll: "content": "" and "poll": { … } (see "Send a poll"). Poll result notice: "type": 46 plus "message_reference": { "message_id": , … }
// "Pinned a message" notice: "type": 6 plus "message_reference": { "message_id": , … }
// Guild { id, name, description, icon, owner_id, active, member_count, roles: [Role], channels: [Channel], me: { permissions } }
// Channel { id, guild_id, type: "text" | "voice" | "category" | "app", name, topic, parent_id, position, permissions }
// Role { id, name, color, permissions, position, hoist, managed } // managed = application id of a bot role
// Member { user: { id, name, bot, avatar }, nick, roles: [ids], joined_at }
Image paths such as /av/… are relative to https://screenshared.io.
Link previews are built after the message is delivered. When they arrive (or are removed) the message comes again as MESSAGE_UPDATE with them at the end of embeds, like on Discord: type link, image or video, url, title, description, provider.name, author.name, thumbnail: { url, proxy_url, width, height }. edited_at does not change. Send flags: 4 (or write the link as <https://…>) to skip them.
GIFs from the picker (KLIPY) have no text: content is the media URL, gif has the details, and embeds gets one type: "gifv" entry. Do not download or re-host that media: link to it. A favourite GIF that was an uploaded file arrives as a normal attachment.
Gateway
Get the URL from GET /v1/gateway (no auth) or use wss://apiscreen.screenshared.io/v1/gateway/ws. Authentication happens in IDENTIFY, not in the upgrade, so the built-in WebSocket of Node.js 22+ and browsers works.
Every frame uses Discord's envelope: {"op": 0, "t": "MESSAGE_CREATE", "s": 42, "d": {…}}
| op | Name | Direction | Payload |
|---|---|---|---|
| 0 | DISPATCH | server → bot | event t, sequence s |
| 1 | HEARTBEAT | bot → server | d = last s received |
| 2 | IDENTIFY | bot → server | {"token": "...", "intents": 33281, "presence": {…}} (presence optional, see Presence) |
| 3 | PRESENCE_UPDATE | bot → server | {"since": null, "activities": [{"name": "/help", "type": 0}], "status": "online", "afk": false} |
| 10 | HELLO | server → bot | {"heartbeat_interval": 30000} |
| 11 | HEARTBEAT_ACK | server → bot |
- Connect. The server sends HELLO. You have 10 s to send IDENTIFY.
- You get READY
{session_id, user, guilds: [{id}]}, then one GUILD_CREATE per guild (members included with theGUILD_MEMBERSintent). - Send HEARTBEAT every
heartbeat_interval; after 75 s of silence the session closes with4009. - If the connection drops, connect and identify again, then fetch what you missed with the REST API (resume arrives in a later release).
Up to 2 sessions per application (a third closes the oldest) and 10 IDENTIFY per 5 minutes.
Presence (status and activity)
Same shape as Discord: send it inside IDENTIFY as presence, or any time later with op 3 PRESENCE_UPDATE. Members see it like a person's: the bot's row in the member list shows the custom status, or "Jogando name", and the profile card shows the activity.
{"op": 3, "d": {
"since": null, "afk": false,
"status": "dnd", // online | idle | dnd | invisible ("offline" = invisible)
"activities": [
{"name": "Custom Status", "type": 4, "state": "Watching the server", "emoji": {"name": "🛡️"}},
{"name": "/help", "type": 0}
]
}}
| type | Shown as | Fields used |
|---|---|---|
| 0 | Jogando name (Playing) | name, state, details |
| 1 | Transmitindo name (Streaming), with a "watch" button | name, url (https) |
| 2 | Ouvindo name (Listening) | name, state, details |
| 3 | Assistindo name (Watching) | name, state, details |
| 4 | Custom status: the state is the text | state, emoji.name (Unicode emoji only) |
| 5 | Competindo em name (Competing) | name, state, details |
status:idleanddndcolor the bot's dot yellow and red;invisibleshows the bot offline (it keeps receiving events).- Up to 5 activities; texts are cut at 128 characters.
sinceandafkare accepted and ignored. - At most 5
PRESENCE_UPDATEper 10 s per session; extra ones are ignored. Invalid JSON closes the session with4002. - The presence is cleared when the bot's last session disconnects.
Intents
| Bit | Name | Events |
|---|---|---|
1 << 0 = 1 | GUILDS | GUILD_UPDATE, CHANNEL_CREATE/UPDATE/DELETE, CHANNEL_PINS_UPDATE |
1 << 1 = 2 | GUILD_MEMBERS | GUILD_MEMBER_ADD/UPDATE/REMOVE, members in GUILD_CREATE |
1 << 2 = 4 | GUILD_MODERATION | GUILD_BAN_ADD/REMOVE |
1 << 3 = 8 | GUILD_EMOJIS_AND_STICKERS | GUILD_EMOJIS_UPDATE |
1 << 7 = 128 | GUILD_VOICE_STATES | VOICE_STATE_UPDATE |
1 << 9 = 512 | GUILD_MESSAGES | MESSAGE_CREATE/UPDATE/DELETE, MESSAGE_DELETE_BULK |
1 << 10 = 1024 | GUILD_MESSAGE_REACTIONS | MESSAGE_REACTION_ADD/REMOVE |
1 << 15 = 32768 | MESSAGE_CONTENT (privileged) | Message text in events; must be enabled in the portal first (otherwise close 4014) |
1 << 24 = 16777216 | GUILD_MESSAGE_POLLS | MESSAGE_POLL_VOTE_ADD/REMOVE (bots have no direct messages here, so 1 << 25 is refused) |
GUILD_CREATE and GUILD_DELETE for the bot's own guilds always arrive.
Events
| Event | d |
|---|---|
READY | {v, session_id, user, guilds: [{id}], application: {id}} |
GUILD_CREATE | Guild object (when connecting or when added to a guild) |
GUILD_DELETE | {id} (removed from the guild) |
GUILD_UPDATE | {id, name, roles} |
GUILD_EMOJIS_UPDATE | {guild_id, emojis: [Emoji]} (the whole list, after any change) |
CHANNEL_CREATE/UPDATE/DELETE | Channel object |
CHANNEL_PINS_UPDATE | {guild_id, channel_id, last_pin_timestamp} (ms of the most recent pin, or null) |
MESSAGE_CREATE/UPDATE | Message object (content gated by MESSAGE_CONTENT) |
MESSAGE_DELETE | {id, channel_id, guild_id} |
MESSAGE_DELETE_BULK | {channel_id, guild_id, count} (a moderator used /limpar) |
MESSAGE_REACTION_ADD/REMOVE | {message_id, channel_id, guild_id, user_id, emoji} |
MESSAGE_POLL_VOTE_ADD/REMOVE | {user_id, channel_id, message_id, guild_id, answer_id}, one per answer (changing a vote sends a REMOVE and an ADD) |
GUILD_MEMBER_ADD/UPDATE | Member object + guild_id |
GUILD_MEMBER_REMOVE | {guild_id, user, reason: "leave" | "kick" | "ban"} |
GUILD_BAN_ADD/REMOVE | {guild_id, user} |
VOICE_STATE_UPDATE | {guild_id, user_id, channel_id | null} |
Close codes
| Code | Meaning | Reconnect? |
|---|---|---|
| 4000 | Unknown error, or replaced by a newer session | yes |
| 4001 | Unknown opcode | yes |
| 4002 | Invalid JSON | yes |
| 4003 | Not identified in time | yes |
| 4004 | Invalid token | no |
| 4005 | Already identified | yes |
| 4008 | Too many IDENTIFY | yes, after waiting |
| 4009 | Session timed out (no heartbeat) | yes |
| 4013 | Invalid intents | no |
| 4014 | Privileged intent not enabled | no |
| 4020 | Application disabled, platform paused or creator's VIP inactive | no |
| 4021 | Token rotated | no |
Components and Components V2
Send components with a message (REST, interaction responses and webhooks). Two modes, exactly as in Discord:
- Classic: up to 5 action rows (
type 1) belowcontent/embeds. - Components V2: set
flags: 32768(1 << 15,IS_COMPONENTS_V2). The whole message is built from layout components;contentandembedsmust be empty.
| type | Component | Notes |
|---|---|---|
| 1 | Action Row | Up to 5 buttons, or 1 select menu |
| 2 | Button | style 1 primary · 2 secondary · 3 success · 4 danger · 5 link (url, no custom_id); label ≤ 80, emoji: {name}, disabled |
| 3 | String Select | options (≤ 25: label, value, description, emoji), placeholder, min_values, max_values |
| 5 · 6 · 7 · 8 | User · Role · Mentionable · Channel Select | Filled from the guild by the client |
| 9 | Section | 1–3 Text Displays + an accessory (Button or Thumbnail) |
| 10 | Text Display | content: markdown, mentions |
| 11 | Thumbnail | media: {url}, description, spoiler |
| 12 | Media Gallery | items (≤ 10): {media: {url}, description, spoiler} |
| 13 | File | file: {url}: a file already uploaded to ScreenShared (/f/…) |
| 14 | Separator | divider (default true), spacing 1 small · 2 large |
| 17 | Container | accent_color, spoiler, children of any type except another container |
Limits: 40 components per message, 4000 characters of text across Text Displays, custom_id 1–100 characters and unique in the message. Images from outside ScreenShared go through its proxy (media.proxy_url in the stored message) when they come from a well-known image host, otherwise they are shown as a link. Webhook messages can use every layout component and link buttons, but not interactive buttons or menus (they need a bot to answer).
POST /v1/channels/{channel}/messages
{
"flags": 32768,
"components": [
{ "type": 17, "accent_color": 5793266, "components": [
{ "type": 10, "content": "## Server status\nAll systems **operational**" },
{ "type": 14 },
{ "type": 9, "components": [ { "type": 10, "content": "Region **São Paulo**\nLatency 12 ms" } ],
"accessory": { "type": 2, "style": 2, "label": "Refresh", "custom_id": "refresh" } },
{ "type": 1, "components": [
{ "type": 3, "custom_id": "region", "placeholder": "Pick a region",
"options": [ { "label": "São Paulo", "value": "gru" }, { "label": "Miami", "value": "mia" } ] } ] }
] }
]
}
Slash commands
Register commands and they show up in the / menu of every guild where the bot is installed (for members with Use applications in the channel).
| Method | Route | |
|---|---|---|
| GET PUT | /applications/{app}/commands | Global commands (PUT replaces the whole list, max 50) |
| GET PUT | /applications/{app}/guilds/{guild}/commands | Commands for one guild only |
PUT /v1/applications/{app}/commands
[
{ "name": "dice", "description": "Roll a die",
"options": [ { "type": 4, "name": "sides", "description": "How many sides", "required": false } ] },
{ "name": "hug", "description": "Hug someone",
"options": [ { "type": 6, "name": "who", "description": "The person", "required": true } ] }
]
Option types: 3 string · 4 integer · 5 boolean · 6 user · 7 channel · 8 role · 10 number; choices (≤ 25) restrict the value. Names: 1–32 lowercase letters, numbers, _ or -. In the chat, users type /dice 20 or /hug @Bruna; name:value also works.
Interactions
When someone uses a command, clicks a button, picks from a menu or submits a modal, the bot receives INTERACTION_CREATE on the gateway (sent to the newest session; no intent needed):
{ "id": "…", "application_id": "…", "token": "…", "type": 2, "guild_id": "…", "channel_id": "…",
"member": { "user": { "id", "name" }, "nick", "roles", "permissions" },
"data": { "id": "…", "name": "dice", "options": [ { "name": "sides", "type": 4, "value": 20 } ] } }
| type | When | data |
|---|---|---|
| 2 | Slash command | {id, name, options, resolved: {users}} |
| 3 | Button or select | {custom_id, component_type, values?} + message |
| 5 | Modal submitted | {custom_id, components: [{type: 1, components: [{type: 4, custom_id, value}]}]} |
Answer within 30 seconds (the user sees "the application didn't respond" after 5 s) with:
POST /v1/interactions/{id}/{token}/callback (no Authorization header needed: the token is enough)
{ "type": 4, "data": { "content": "🎲 You rolled **17**", "flags": 64 } }
| type | Response |
|---|---|
| 4 | Reply with a message (content, embeds, components, flags). flags: 64 = ephemeral (only the user sees it) |
| 5 | Deferred: shows "thinking…"; edit it later with PATCH …/messages/@original |
| 6 | Deferred update (components): just acknowledge the click |
| 7 | Update the message the button belongs to |
| 9 | Open a modal |
Follow-ups (the interaction token lives 15 minutes):
| PATCH | /v1/interactions/{id}/{token}/messages/@original (alias: /v1/webhooks/{app}/{token}/messages/@original) |
| DELETE | /v1/interactions/{id}/{token}/messages/@original |
| POST | /v1/interactions/{id}/{token}/followup (alias: /v1/webhooks/{app}/{token}) — a new message |
A second callback returns 409 already_responded. Components on ephemeral messages are shown but not clickable yet.
Modals (forms)
Respond with type 9 to open a form for the user (from a command or a component; not from another modal):
{ "type": 9, "data": { "custom_id": "feedback", "title": "Feedback",
"components": [ { "type": 1, "components": [
{ "type": 4, "custom_id": "text", "label": "What do you think?", "style": 2, "max_length": 1000, "required": true } ] } ] } }
Up to 5 text inputs (type 4, style 1 short · 2 paragraph). On submit you get an INTERACTION_CREATE of type 5 with the values, and you answer it like any other interaction.
Embeds
Discord's embed format, rendered natively in the chat:
{ "title": "…", "description": "markdown", "url": "https://…", "color": 3066993,
"timestamp": "2026-11-25T20:00:00Z", "author": { "name": "…", "icon_url": "https://…" }, "footer": { "text": "…", "icon_url": "https://…" },
"image": { "url": "https://…" }, "thumbnail": { "url": "https://…" },
"fields": [ { "name": "…", "value": "markdown", "inline": true } ] }
| Field | Limit |
|---|---|
| embeds per message | 10, with 6000 characters across all of them |
| title / author.name | 256 |
| description | 4096 |
| fields | 25 (name 256, value 1024) |
| footer.text | 2048 |
| url | http/https only, 2048 |
| image / thumbnail | https (http is upgraded), up to 10 MB; PNG, JPEG, GIF or WebP; shown up to 1280 px |
| author.icon_url / footer.icon_url | same rules, shown as a small icon; dropped if not accepted |
Embed images
Images are fetched by ScreenShared, decoded, re-encoded and served from /lp/…. Accepted hosts include i.imgur.com, cdn.discordapp.com, media.discordapp.net, raw.githubusercontent.com, avatars.githubusercontent.com, opengraph.githubassets.com, i.ytimg.com, static-cdn.jtvnw.net, *.steamstatic.com, i.scdn.co, pbs.twimg.com, i.redd.it and upload.wikimedia.org. An image or thumbnail from another host becomes a link in the description. Animated GIFs keep moving when they are small enough; animated WebP shows its first frame. Reading the message back returns your url plus proxy_url. attachment:// is not supported.
Permissions
When a bot is added, it gets a managed role with the permissions granted by the installer (who can only grant what they have; only the guild owner grants Administrator). Guild admins can edit that role's permissions and position like any role, but can't give it to anyone else or delete it (remove the bot instead).
| Bit | Value | Name |
|---|---|---|
| 1 << 0 | 1 | View channels |
| 1 << 1 | 2 | Manage channels |
| 1 << 2 | 4 | Manage roles |
| 1 << 3 | 8 | Manage guild |
| 1 << 4 | 16 | Create invites |
| 1 << 5 | 32 | Kick members |
| 1 << 6 | 64 | Ban members |
| 1 << 7 | 128 | Send messages |
| 1 << 8 | 256 | Attach files |
| 1 << 9 | 512 | Manage messages |
| 1 << 10 | 1024 | Read message history |
| 1 << 11 | 2048 | Connect (voice) |
| 1 << 12 | 4096 | Speak |
| 1 << 13 | 8192 | Video |
| 1 << 14 | 16384 | Stream (screen share) |
| 1 << 15 | 32768 | Mute members (voice) |
| 1 << 16 | 65536 | Move members (voice) |
| 1 << 17 | 131072 | Administrator |
| 1 << 18 | 262144 | Moderate members (timeout, warnings) |
| 1 << 19 | 524288 | Handle tickets |
| 1 << 20 | 1048576 | Manage webhooks |
| 1 << 21 | 2097152 | Use applications |
| 1 << 22 | 4194304 | Manage emojis |
| 1 << 23 | 8388608 | Create polls |
Note: the values differ from Discord's; the names and the model are the same.
Example bot (Node.js 22+)
Replies pong to !ping and answers a /dice command with a button. No dependencies: Node 22+ ships fetch and WebSocket. !ping requires the Message Content setting (or mention the bot); slash commands don't.
const TOKEN = process.env.SS_TOKEN;
const API = 'https://apiscreen.screenshared.io/v1';
const INTENTS = 1 | 512 | 32768; // GUILDS | GUILD_MESSAGES | MESSAGE_CONTENT
async function rest(method, path, body) {
const r = await fetch(API + path, {
method, headers: { Authorization: 'Bot ' + TOKEN, 'Content-Type': 'application/json' },
body: body ? JSON.stringify(body) : undefined,
});
if (r.status === 429) { const e = await r.json(); await new Promise((ok) => setTimeout(ok, e.retry_after * 1000)); return rest(method, path, body); }
return r.status === 204 ? null : r.json();
}
function connect() {
const ws = new WebSocket(API.replace('https', 'wss') + '/gateway/ws');
let seq = null, beat;
ws.onmessage = async (ev) => {
const { op, t, s, d } = JSON.parse(ev.data);
if (s) seq = s;
if (op === 10) {
beat = setInterval(() => ws.send(JSON.stringify({ op: 1, d: seq })), d.heartbeat_interval);
ws.send(JSON.stringify({ op: 2, d: { token: TOKEN, intents: INTENTS } }));
}
if (t === 'READY') {
console.log('online as', d.user.name);
await rest('PUT', `/applications/${d.application.id}/commands`, [{ name: 'dice', description: 'Roll a die' }]);
}
if (t === 'INTERACTION_CREATE') {
const roll = 1 + Math.floor(Math.random() * 6);
const reply = { content: `🎲 **${roll}**`, components: [{ type: 1, components: [{ type: 2, style: 1, label: 'Again', custom_id: 'again' }] }] };
await fetch(`${API}/interactions/${d.id}/${d.token}/callback`, { method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ type: d.type === 3 ? 7 : 4, data: reply }) });
}
if (t === 'MESSAGE_CREATE' && d.content === '!ping' && !d.author.bot) {
await rest('POST', `/channels/${d.channel_id}/messages`, { content: 'pong 🏓' });
}
};
ws.onclose = (ev) => {
clearInterval(beat);
if ([4004, 4013, 4014, 4020, 4021].includes(ev.code)) { console.error('closed:', ev.code, ev.reason); return; }
setTimeout(connect, 3000);
};
}
connect();
Limits
| Item | Limit |
|---|---|
| Applications per account | 5 (account VIP required) |
| Bots per guild | 10 |
| Webhooks | 10 per channel, 50 per guild |
| Gateway sessions | 2 per application; 10 IDENTIFY per 5 minutes |
| Gateway frame (bot → server) | 16 KB |
| Request body | 64 KB |
Changelog
- 2026-12-02 — polls:
pollwhen sending a message and in the message object,/channels/{channel}/polls/{id}/answers/{answer_id}and/expire, theMESSAGE_POLL_VOTE_ADD/REMOVEevents (intent1 << 24), thetype46 result message and the Create polls permission (1 << 23). Accounts can now be Invisible: nothing in this API tells whether a person is online. - 2026-12-02 — guild emojis, files and forwards:
/guilds/{guild}/emojis, theGUILD_EMOJIS_UPDATEevent (intent1 << 3) and the Manage emojis permission (1 << 22); reaction endpoints; a guild emoji inreactionsand in the reaction events is an object{id, name, animated}(Unicode ones stay strings); one file per message withmultipart/form-data, spoilers and descriptions; forwards withmessage_reference.type = 1andmessage_snapshots. - 2026-12-02 — link previews, embed images and GIFs: link previews in
embeds(with aMESSAGE_UPDATEwhen they arrive),image,thumbnail,author.icon_urlandfooter.icon_urlshown through our proxy, Components V2 media withproxy_url,SUPPRESS_EMBEDS, and thegiffield. - 2026-12-01 — pins:
GET/PUT/DELETE /channels/{channel}/pins(and the newer/messages/pinsform),pinnedon every message, thetype6 notice and theCHANNEL_PINS_UPDATEevent. - 2026-11-28 — presence: op 3
PRESENCE_UPDATEandIDENTIFY.presence(status online/idle/dnd/invisible, activities of types 0–5, type 4 custom status). Shown in member lists and profile cards like people's activity. - 2026-11-28 — replies:
message_referenceon create (withallowed_mentions.replied_userandfail_if_not_exists); messages carrytype(0, or 19 for replies),message_referenceandreferenced_messageover REST, gateway and outgoing webhooks. - 2026-11-25 — moderation and outgoing webhooks: kick, ban, unban, roles, nick and timeout over REST; signed outgoing webhooks with retries.
- 2026-11-25 — components and interactions: classic components and Components V2 (containers, sections, text, thumbnails, galleries, separators, buttons, all select menus), slash commands (global and per guild), interactions over the gateway with response types 4/5/6/7/9, follow-ups, modals. Webhooks accept components too.
- 2026-11-25 — v1 (first release): incoming webhooks (Discord JSON and plain text), applications and bot tokens, install flow with managed roles, REST messages with embeds, basic gateway with intents.
- Next: gateway resume, several files per message, interactions over signed HTTP (ed25519), channel and role management over REST, voice bots.