Access Tokens and API
Create a personal access tokenA key that lets your scripts call the panel's API as you for each script or app, then call the control panel's API with it to read settings and logs, change features, or start and stop the bot.
Why Use Access Tokens?
- Lets scripts, dashboards, and shortcuts use the API without your password or a browser sign-in.
- Gives each client only the scopesWhat an access token is allowed to do it needs, so a leaked token can't do everything you can.
- Lets you revoke one client without affecting the others.
- Ends temporary access on its own when you set an expiry.
How Tokens Work
- Acts as you — A token uses your panel roleAn account's level: Owner, Administrator, Operator, or Viewer and your server accessWhich Discord servers an account is allowed to open, limited to its scopesWhat an access token is allowed to do, so it can never do more than you can.
- Yours only — Each user creates their own tokens on Access tokens, under Settings, and sees only their own.
- Tied to your account — Suspending or deleting your account stops your tokens right away, while a password reset doesn't.
- Stored as a hash — The panel keeps only a SHA-256 hash of each token, so a lost token can't be shown again.
- Shape — A token is
dsb_followed by 43 letters, digits, dashes, or underscores.
Scopes
| Scope | What it allows |
|---|---|
features:read | See your servers with their channels and roles, feature settings, and the invite pageA public page that hands out short-lived Discord invites |
features:write | Change feature settings, turn features on or off, and edit the invite pageA public page that hands out short-lived Discord invites |
bot:control | See the bot's status, and start, stop, or restart it |
logs:read | Read the bot, web, and workerBackground service that runs schedules and deliveries logs |
- Exact — ScopesWhat an access token is allowed to do never include each other, so a token that saves features with
features:writealso needsfeatures:readto read them first. - Limited by role — A ViewerRead-only role: sees everything, changes nothing can give only
features:readandlogs:read, and the dialog marks the others "Your role can't grant this scope." - Checked twice — A write request needs both the scopeWhat an access token is allowed to do and your role's permission, so your role still has to be allowed to make the change.
Create a Token
- Open Access tokens and select Create token.
- Enter a Name you'll recognize, like the app that uses it, up to 80 characters. Each of your tokens needs its own name, and names that differ only in letter case count as the same.
- Under Scopes, tick what the client can do.
- Under Expires, choose Never, In 30 days, In 90 days, or In 1 year.
- Select Create token.

Copy the Token Once
The dialog then shows the new token once, under Token for and its name, with "Copy it now. It won't be shown again." and a copy button. Copy it before you select Done.
- Select the copy button next to the token, and save the token in the client's secret store.
- Select Done.

A lost token can't be shown again, so create a new one and revoke the old one.
Edit or Revoke a Token
Each row on Access tokens shows the token's name and scopesWhat an access token is allowed to do, when it was created and last used, and when it expires.
- Edit — Changes the name, the scopesWhat an access token is allowed to do, and the expiry, while the token's value stays the same. When an expiry is set, Keep and its date stay selected, and Never removes it.
- Revoke — Select Revoke, then Revoke again to confirm. Apps using the token stop working right away, and the row disappears.
- Expired — An expired token stays in the list and is rejected, so edit it to set a new expiry, or revoke it.
To rotate a token, create a replacement with the same scopesWhat an access token is allowed to do, update the client and check that one request works, then revoke the old token.
Call the API
The Calling the API section of the page shows the Base URL, the header, and the main paths with the scopeWhat an access token is allowed to do each one needs.
- Base URL — The address your browser has the control panel open at, such as
https://bot.example.com. Every path starts with/api/v1. - Header — Send
Authorization: Bearer dsb_…with every request, and a token request never needs the browser's CSRF header. - JSON — Send bodies as JSON with
Content-Type: application/json, and answers are JSON. An image upload sends the raw PNG, JPEG, WebP, or GIF file with its ownContent-Typeinstead, and/logs/streamanswers with server-sent events.
Passing the token with curl's -H option puts it in the process list, where other users on the machine can see it. Piping the header to curl's --config - keeps it out, as long as printf is the shell's builtin:
read -r -s STONKER_TOKEN
printf 'header = "Authorization: Bearer %s"\n' "$STONKER_TOKEN" \
| curl --config - --silent --show-error --fail-with-body \
https://bot.example.com/api/v1/bot
unset STONKER_TOKEN
read -r -s reads the token without showing it or saving it to the shell history, and the examples below use the same pattern.
Endpoints
| Method and path | Scope | What it does |
|---|---|---|
GET /api/v1/auth/me | Any | Shows the token's ID, name, scopesWhat an access token is allowed to do, and username |
GET /api/v1/servers | features:read | Lists the servers you can open, with how many features each has on |
GET /api/v1/servers/{serverId}/resources | features:read | Lists a server's channels and roles |
GET /api/v1/servers/{serverId}/features | features:read | Lists all 19 features with their state |
GET /api/v1/servers/{serverId}/features/{featureKey} | features:read | Shows one feature's settings, form, and example |
PUT /api/v1/servers/{serverId}/features/{featureKey} | features:write | Saves one feature's settings |
PUT /api/v1/servers/{serverId}/features/{featureKey}/enabled | features:write | Turns one feature on or off |
GET /api/v1/servers/{serverId}/invite-page | features:read | Shows the invite pageA public page that hands out short-lived Discord invites design and its public link |
PUT /api/v1/servers/{serverId}/invite-page | features:write | Saves the invite pageA public page that hands out short-lived Discord invites design |
POST /api/v1/servers/{serverId}/invite-page/images | features:write | Uploads a logo or banner image |
GET /api/v1/bot | bot:control | Shows the bot's status |
POST /api/v1/bot/actions | bot:control | Starts, stops, or restarts the bot |
GET /api/v1/logs | logs:read | Lists log entries |
GET /api/v1/logs/stream | logs:read | Sends new log entries as they arrive, as server-sent events |
serverId— A Server IDThe number Discord uses to name a server fromGET /api/v1/servers. A server your account can't open answers like an unknown one, with "That Discord server isn't available."featureKey— The feature's settings key, which is itsconfig.jsonsection name, such asauto-replies,message-proxies, orweb-applications.
Restart the Bot
printf 'header = "Authorization: Bearer %s"\n' "$STONKER_TOKEN" \
| curl --config - --silent --show-error --fail-with-body \
--header 'Content-Type: application/json' \
--request POST \
--data '{"action":"restart"}' \
https://bot.example.com/api/v1/bot/actions
The answer is HTTP 202 with {"desiredState":"running"}, and the bot picks the request up within a second or so. action is start, stop, or restart, and GET /api/v1/bot then reports the status: ready, starting, stopped, failed, configuration_required, or unresponsive.
Turn a Feature On
printf 'header = "Authorization: Bearer %s"\n' "$STONKER_TOKEN" \
| curl --config - --silent --show-error --fail-with-body \
--header 'Content-Type: application/json' \
--request PUT \
--data '{"enabled":true}' \
https://bot.example.com/api/v1/servers/123456789012345678/features/auto-replies/enabled
Turning a feature on checks its saved settings first. A feature that isn't set up answers HTTP 409 with "Set up this feature before turning it on."
Read New Log Entries
printf 'header = "Authorization: Bearer %s"\n' "$STONKER_TOKEN" \
| curl --config - --silent --show-error --fail-with-body \
'https://bot.example.com/api/v1/logs?component=bot&level=warn&limit=50'
- Filters —
componentisbot,web, orworker,levelis the lowest level to include,qsearches event names and details, andlimittakes 1 to 500, 200 by default. - Only newer entries — The answer has
itemsand acursor, and sendingafter=<cursor>next time returns only the entries written since.
Save a Feature's Settings
Read the feature first, then send the whole configuration back with the expectedRevision you read and any new secret values in secrets.
{
"configuration": [
{
"name": "Relay news bot",
"channel": { "channel-id": "123456789012345678" },
"webhook": { "webhook-url": { "$secret": "" } }
}
],
"expectedRevision": 3,
"secrets": {
"/0/webhook/webhook-url": "https://discord.com/api/webhooks/123456789012345678/your-webhook-token"
}
}
- New secrets — Put
{ "$secret": "" }where the secret goes, and send its value insecrets, keyed by the JSON pointer to that spot. - Saved secrets — Keep the
{ "$secret": "<key>" }you read, and leave it out ofsecrets. - Conflicts — If someone saved the feature since you read it, the answer is HTTP 409 with "This feature changed since you opened it. Reload to see the latest version."
Responses and Errors
A failed request answers with an error object that has a stable code for scripts and a message for people.
{
"error": {
"code": "scope_required",
"message": "This token doesn't have the bot:control scope."
}
}
A body that fails its checks also lists each problem in issues, with the field, the message, and the path as a list. The top-level message repeats the first one, except when turning on a feature whose saved settings fail, which answers "Fix this feature's settings before turning it on."
{
"error": {
"code": "invalid_request",
"message": "Choose start, stop, or restart.",
"issues": [
{
"field": "action",
"message": "Choose start, stop, or restart.",
"path": ["action"]
}
]
}
}
Status Codes
| Status | Error code | Meaning |
|---|---|---|
200 | — | The request worked |
201 | — | An image upload worked, and the answer has the image's id and url |
202 | — | The bot accepted a start, stop, or restart |
400 | invalid_json | The body isn't valid JSON |
401 | authentication_required | The token is missing, malformed, unknown, expired, or revoked, or its owner is suspended |
403 | scope_required | The token lacks the route's scopeWhat an access token is allowed to do |
403 | permission_required | Your role can't make this change, such as "Your role can't change settings." |
403 | session_required | The route needs a signed-in browser session |
404 | server_not_found | The server doesn't exist, or your account can't open it |
404 | feature_not_found | The feature key doesn't exist |
404 | not_found | No route matches the method and path |
409 | revision_conflict | Someone saved the feature or the invite pageA public page that hands out short-lived Discord invites after you read it |
409 | feature_not_configured | The feature isn't set up yet |
409 | bot_token_required | No Bot TokenThe bot's password for Discord, from the Developer Portal is saved, so the bot can't start |
413 | payload_too_large | The body is over 64 KB, or over 2 MB for a feature save or an image upload |
415 | unsupported_encoding | The body isn't UTF-8 JSON |
415 | unsupported_image | An upload isn't a PNG, JPEG, WebP, or GIF image |
422 | invalid_request | A field failed its check, and issues lists each problem |
429 | rate_limited | The address sent more than 300 requests in a minute |
500 | internal_error | Something unexpected went wrong, and the Web log has the detail |
The checks run in order: the JSON body, the rate limit, the token, its scopeWhat an access token is allowed to do, your role, the server, and then the body's fields.
Rate Limits
- Limit — Every path under
/api/v1, including the control panel's own requests, allows 300 requests per minute from one address, or one/56network for IPv6. - Headers — Answers carry
RateLimit-Policy,RateLimit-Limit,RateLimit-Remaining, andRateLimit-Reset, and a429also carriesRetry-Afterin seconds. - Behind a proxy — The address comes from
X-Forwarded-Forwhen a trusted proxyA nearby reverse proxy whose forwarded headers are believed sends it, as described in Remote Access.
Routes Tokens Can't Use
Some routes need a signed-in browser sessionYour browser's sign-in, good for 24 hours, so a token gets 403 with "A signed-in browser session is required."
- Your account — The password, the username, the authenticator appA phone app that makes six-digit sign-in codes, recovery codesA one-time backup code for when your authenticator is gone, and passkeysSign in with Face ID, Touch ID, or a security key.
- Tokens and users — Listing, creating, editing, and revoking tokens, and every route on the Users page.
- Notifications — Every route on the Notifications page, including Send test.
- Bot Token and Backup — Saving the Bot TokenThe bot's password for Discord, from the Developer Portal, exporting configuration, and importing an export fileA JSON backup of your settings, secrets in plain text or an older
config.jsonfrom Backup. - Saved secrets notice —
DELETE /api/v1/auth/removed-secrets, which dismisses the notice a lost installation keyThe key that locks your secrets; back it up with the database leaves. A token'sGET /api/v1/auth/mealso leaves out theremovedSecretslist that a browser sessionYour browser's sign-in, good for 24 hours gets.
A request with an Authorization header is always handled as a token request, even when the browser also sends a session cookie.