HTTP API
Raven runs a small HTTP API next to the bot, on port 3001. The dashboard uses it to read and change server settings. It isn’t meant to be called from a browser.
Authentication
Section titled “Authentication”Every route except GET / needs the Authorization header set to the bot’s API_SECRET. Without it, the API answers 401.
The /servers/{guildID} routes act on behalf of a Discord user, passed in the X-User-Id header. The API only allows the owner of the server. The caller (the dashboard) is responsible for checking who the user is, with Discord OAuth2.
Server management
Section titled “Server management”GET /servers
Section titled “GET /servers”Every server Raven is in, with its owner’s ID. The dashboard uses this in its development mode, where it skips login and acts as each server’s owner.
{ "servers": [{ "id": "222222222222222222", "name": "My server", "icon": null, "ownerId": "111111111111111111" }] }GET /servers/owned/{userID}
Section titled “GET /servers/owned/{userID}”The servers Raven is in that the user owns.
{ "servers": [{ "id": "222222222222222222", "name": "My server", "icon": "https://cdn.discordapp.com/icons/…" }] }GET /servers/{guildID}
Section titled “GET /servers/{guildID}”Needs X-User-Id. The server’s settings, plus the text channels and roles to choose from.
{ "server": { "id": "222222222222222222", "name": "My server", "icon": null }, "settings": { "welcomeMessage": "Welcome!", "joinChannel": "333333333333333333", "modlogChannel": null, "birthdayChannel": null, "staffChannel": null, "streamerChannel": null, "autorole": "444444444444444444", "streamerRole": null, "streamerRoleLive": null }, "channels": [{ "id": "333333333333333333", "name": "welcome" }], "roles": [{ "id": "444444444444444444", "name": "Member", "color": "#99aab5", "assignable": true }]}assignable is false for roles at or above Raven’s highest role. Managed roles (bot and booster roles) and @everyone are left out.
PATCH /servers/{guildID}/settings
Section titled “PATCH /servers/{guildID}/settings”Needs X-User-Id. Send only the settings to change. null removes a setting.
{ "joinChannel": "333333333333333333", "autorole": null }| Setting | Value |
|---|---|
welcomeMessage |
Text, at most 2000 characters |
joinChannel, modlogChannel, birthdayChannel, staffChannel, streamerChannel |
ID of a text or announcement channel in the server |
autorole, streamerRole, streamerRoleLive |
ID of an assignable role in the server |
The answer is 200 with the new settings. If any value is invalid, nothing is saved and the answer is 400, with a message per field:
{ "error": true, "errors": { "autorole": "Raven can't assign this role; move Raven's role above it" } }Errors
Section titled “Errors”| Status | Meaning |
|---|---|
400 |
Invalid ID or setting value |
401 |
Missing or wrong Authorization |
403 |
The X-User-Id user doesn’t own the server |
404 |
Raven isn’t in the server |
Other routes
Section titled “Other routes”| Route | What it returns |
|---|---|
GET / |
The API’s name; no authentication |
GET /guilds |
IDs of all servers Raven is in |
GET /guilds/id/{guildID} |
One server |
GET /guilds/user/{userID} |
Servers where the user is an administrator |
GET /shards |
Shard status |
PUT /shards/presence |
Change Raven’s status message |
GET /breaks |
Logged breaks |