Linkup Bot API reference ======================== Linkup is a Discord-style chat app. Bots are apps created in the Developer Portal (/developers in the app). Base URL: the Linkup site you use (for local testing: http://localhost:3210). All bodies are JSON. AUTHENTICATION Every request: header Authorization: Bot The token is shown once when you create the app, or when you reset it on the Bot tab. Keep it secret. Errors come back as {"error": "message"} with a 4xx/5xx status. WHO AM I GET /api/bot/me -> { app: {id, name, description, verified, intents, commands}, user: {id, username, displayName, ...}, servers: [{id, name, channels: [{id, name, type}]}] } LIVE EVENTS (the "gateway") GET /api/stream (same Authorization header; Server-Sent Events, keep the connection open) The bot shows as online while this connection is open. Reconnect if it drops. Each event looks like: event: data: (blank line) Events your bot gets: ready {sid} message_create a message object (see MESSAGE) message_update a message object message_delete {id, channelId} interaction_create {id, command, options: {name: value}, text, channelId, serverId, user} server_join a server the bot was added to server_update a server changed (channels, roles...) member_join {serverId, userId, user} needs Server Members intent member_leave {serverId, userId} needs Server Members intent presence {userId, status} needs Presence intent typing, reaction and other events may also arrive; ignore what you don't use. PRIVILEGED INTENTS (toggle on the Bot tab) Presence -> presence events Server Members -> member_join / member_leave Message Content-> message text. Without it, message_create and GET messages return content "" and no attachments, EXCEPT in DMs, the bot's own messages, and messages that @mention the bot (mention = "@"). Unverified bots can be in up to 100 servers. Request verification on the Verification tab to go past that. MESSAGE {id, channelId, authorId, content, createdAt, editedAt, reactions: {emoji: [userIds]}, replyTo, attachments, pinned, interaction?: {name, userId}} Formatting: **bold**, *italic*, __underline__, ~~strike~~, ||spoiler||, `code`, ```code block```, > quote, @username mentions, #channel-name links, :emoji_name:. SENDING AND READING POST /api/channels/{channelId}/messages {content, replyTo?} -> message GET /api/channels/{channelId}/messages?limit=50&before={messageId} -> {messages, hasMore} PATCH /api/messages/{messageId} {content} (own messages) DELETE /api/messages/{messageId} (own, or with Manage Messages) PUT /api/messages/{messageId}/reactions {emoji} (toggles the bot's reaction) PUT /api/messages/{messageId}/pin {pinned: true|false} (needs Pin Messages) POST /api/channels/{channelId}/typing (shows "Bot is typing…") Limits: about 8 messages per 5 seconds per bot. Messages up to 4000 characters. SLASH COMMANDS PUT /api/apps/{appId}/commands {commands: [{name, description, options: [{name, description, required}]}]} (max 25, replaces all) name: lowercase letters, numbers, - and _. The last option receives the rest of the text. When a member runs /name in a server with the bot, the bot receives interaction_create. Reply within 15 minutes: POST /api/interactions/{interactionId}/reply {content, ephemeral?: true} ephemeral replies are shown only to the person who ran the command and are not saved. If the bot is offline (no open /api/stream), members see " isn't responding right now." PERMISSIONS Bots follow the same server and channel permissions as members. The invite link gives the bot its own role with the permissions picked on the Installation tab; server admins can change it like any role. Permission names: VIEW_CHANNEL, SEND_MESSAGES, READ_MESSAGE_HISTORY, EMBED_LINKS, ATTACH_FILES, ADD_REACTIONS, USE_EXTERNAL_EMOJI, MENTION_EVERYONE, MANAGE_MESSAGES, PIN_MESSAGES, CREATE_POLLS, MANAGE_CHANNELS, MANAGE_ROLES, KICK_MEMBERS, BAN_MEMBERS, TIMEOUT_MEMBERS, MANAGE_NICKNAMES, CONNECT, SPEAK, ADMINISTRATOR. INVITE LINK {base}/app/install/{appId}?perms=SEND_MESSAGES,ADD_REACTIONS Opens an "Add to server" screen for people with Manage Server. Private bots: only the owner can use it. STARTER BOT {base}/docs/starter-bot.js (Node.js 18+, no packages). Shows auth, the event stream, a message handler and /ping, /echo, /roll commands. Run: LINKUP_TOKEN=... node starter-bot.js