Developer docs
Getting started
Create an application in the developer portal, get a bot token, choose scopes and add your bot to a hub.
1. Create an application
- Sign in and open the developer portal. You can also reach it from your account menu.
- Choose Create an application (or New) and give it a name (up to 32 characters). Each application gets its own bot account with a handle, a picture and a Bot badge that can never be hidden or faked.
- Add a description (up to 400 characters) and a picture. You can own up to 25 applications, and share each with a team of up to 25 people as admins, developers or read only members.
2. Get the bot token
Open the Token tab and choose Create token (later, Reset token). Hubs asks for your password, and your second factor if you use one, then shows the token once. Copy it into your secret store right away; Hubs keeps only a hash.
Tokens start with hbot_ and match hbot_[0-9A-Za-z]{46}, so secret scanners can find them. Every message and file posted in Hubs is checked for tokens: a live token found anywhere is revoked at once and you get a notice in the portal. Resetting retires the old token immediately.
Never put a bot token in a web page, a hosted app bundle or a public repository. Send it only from your own server.
3. Choose scopes
Scopes are the parts of the API your application uses. List them in the portal; the install link asks for some of them; a hub admin approves them. Most scopes also need a permission inside the hub, which rides on the bot's own role there.
| Scope | Opens | Needs permission |
|---|---|---|
bot | Adds the bot to the hub as a member with a Bot badge. | None |
channels:read | See the names of the channels it can open. | view_channels |
messages:read | Read messages in the channels it can open. | read_history |
messages:write | Post messages as the bot where its role may post. | send_messages |
reactions:write | Add and remove its own reactions. | add_reactions |
members:read | See who is in the hub: names, handles and hub roles. | view_members |
gateway | Hear about new messages, reactions, members and channels as they happen, only for what its other scopes already allow. | None |
commands | Offer slash commands, buttons, menus and forms that people choose to use in chat. | None |
| Permission | In plain words |
|---|---|
view_channels | See channels. Only channels its role can already open. |
read_history | Read message history. Earlier messages in those channels. |
send_messages | Send messages. Where its role may post. Never announcements. |
add_reactions | Add reactions. Its own reactions on messages it can read. |
view_members | See the member list. Names, handles and hub roles of members. |
Every call needs its scope, its permission and the hub's own channel rules for the bot's role. Narrowing your application's scope list narrows every install at once; widening it never widens an install that a hub already approved.
4. Add the bot to a hub
The portal shows your install link. Share it with an owner or admin of the hub. It looks like this:
https://hubs.example.com/oauth2/authorize?client_id=<application id>&scope=bot+messages:read+messages:write&permissions=read_history,send_messagesscopelists scopes separated by spaces, plus signs or commas. It must includebot.permissionslists permissions separated by commas. Leave it out to ask for what the scopes need.hub(optional) preselects one of the admin's hubs.
The install screen says what the bot can do and what it can never do before the admin approves. The bot then joins with its own role, and the hub's audit trail records the install.
5. Make your first call
Send the token in the Authorization header as Bot <token>. Every call is HTTPS and JSON.
curl https://hubs.example.com/api/developer/v1/users/@me \
-H "Authorization: Bot $HUBS_BOT_TOKEN"{
"id": "0b1c2d3e-4f5a-4b6c-8d7e-9f0a1b2c3d4e",
"handle": "dice_bot",
"displayName": "Dice",
"bot": true,
"application": {
"id": "c4d5e6f7-a8b9-4c0d-8e1f-2a3b4c5d6e7f",
"name": "Dice"
}
}Hub API keys
Hub owners who want a quick script, not a bot, can make a hub API key in Manage, Developer tools. A key works for 1 to 20 chosen channels of one hub, for 1 to 90 days, with any of channels:read, messages:read and messages:write. Send it as Authorization: Bearer hubs_.... Posts made with a key are labeled as an integration and act for the owner who made it, so the key stops working if that person stops being the owner.
Next
- Browse the API reference.
- Connect to the bot gateway to hear events live.
- Add slash commands and buttons.