Bot API v1

Build something
your people will love.

Build a bot for your community. Create it, connect your worker, and choose the channels it can use.

Your first bot, from zero to “Pong!”

You’ll create an app, start a small Node.js worker, approve it from your ONYX account, and install it into a text channel. You host the worker. ONYX handles the channel permissions and command events.

  • An ONYX account and a server you can manage.
  • Node.js 22 or newer on your computer or hosting server.
  • The example bot, saved as onyx-bot.mjs. No packages to install.

01. Give your bot an identity.

Open Settings → Developer in ONYX. Enter a name and choose Create bot. Add a description and profile image, then copy its bot ID or start command.

You can own up to ten bot apps. The bot ID is public; it identifies your app and is not a login token.

02. Start the example worker.

Download the example into a folder on your computer. Open a terminal in that folder and run:

Terminal
node onyx-bot.mjs YOUR_BOT_ID

Replace YOUR_BOT_ID with the ID from Developer settings. The worker asks ONYX for a short-lived connection code. Keep the terminal running while you complete the next step.

03. Connect it to your account.

The terminal prints a verification URL and a ten-character code. Open the URL yourself, sign in to ONYX, and enter that code under Settings → Developer → Approve bot connection.

Approve only a code shown by your own running worker. A connection request expires after five minutes. Once approved, the bot receives its access token directly; the browser never receives or displays it.

04. Choose where it belongs.

In Developer settings, choose your bot under Install bot, select a server, and select the text channels it may use. Save the installation. You must be allowed to manage that server.

For someone else’s server, share the bot’s installation link from Developer settings. That server’s manager makes the decision and chooses the channels. Owning a bot never gives you access to someone else’s server.

05. Say hello with /ping.

The example registers a ping command when it connects. In an approved text channel, type /ping or choose it from the Bot commands menu. Your running worker replies with Pong!

If multiple bots offer the same command, use the menu to pick the right bot. To change the example’s answer, edit the response inside its event loop and restart the worker.

Inside the example event loop
const response = event.command === 'ping'
  ? 'Pong! Glad you’re here.'
  : 'That command is not available.';

The full example includes safe event handling and duplicate prevention. Keep that behavior when you customize it.

A small API. Useful building blocks.

The API is version 1. Requests and responses use JSON. Authenticated calls use a bot token in the Authorization: Bearer header. Only the pairing endpoints are unauthenticated.

Base URL
https://kqalpkxhrsuzdbtyeorb.supabase.co/functions/v1/bot-api
EndpointWhat it does
POST /pair/startStart owner-approved pairing. Keep the random device code inside your worker.
POST /pair/pollPoll for approval every 3 seconds. The approved token is returned once.
GET /meRead this bot’s identity and channel grants.
POST /commandsReplace the bot’s command list, up to 20 unique commands.
GET /events?after=CURSORReceive up to 50 invoked commands after a string-valued event cursor.
POST /messagesSend a text reply to an approved channel with a stable UUID nonce.
Register a command — request body
{
  "commands": [
    {
      "name": "ping",
      "description": "Check whether the bot can answer."
    }
  ]
}
Send a reply — request body
{
  "channel_id": "CHANNEL_UUID",
  "nonce": "A_STABLE_UUID_FOR_THIS_EVENT",
  "content": "Pong!"
}

Event IDs are strings, not JavaScript numbers. Preserve the same nonce when retrying a reply to avoid duplicates. Advance your event cursor after successfully handling the event. Command events are kept for up to seven days.

Useful access. Clear boundaries.

LimitValue
Apps per owner10
Commands per bot20
Authenticated requests120 per minute per bot
Messages30 per minute per bot; channel slowmode also applies
Message length1–4,000 characters
Command invocations30 per minute per user
PairingOnce per bot per 30 seconds; code valid for 5 minutes
Access tokenUp to 30 days; revocable at any time

A 429 response includes Retry-After: 60. Pause before trying again. Removing an installation or revoking the bot’s access removes its permission to act. Messages cannot use @everyone or @here mentions.

Keep the good stuff running.

Run your worker on your own computer for development. For continuous operation, deploy it to a host that supports a long-running Node.js process. Keep secrets in that host’s protected environment or secret store, and never ship them in a website or repository.

  • Handle expiry: stop and reconnect after an authentication failure; do not endlessly retry a revoked token.
  • Keep the cursor: save it on your server if your worker needs to resume across restarts.
  • Retry safely: reuse nonces and respect rate limits. The example polls every three seconds.
  • Log carefully: do not log credentials or unnecessary personal information.
  • Ask for less: install only in channels the bot actually needs.

ONYX does not run arbitrary bot code for you. Review third-party workers before connecting them to your account.

When something doesn’t answer.

What you seeWhat to check
The connection code expiredRestart the worker and approve its new code within five minutes.
401 / access stopped workingThe token may have expired or been revoked. Reconnect your worker.
403 / cannot send a replyCheck the installation and selected channels. Also check account or server restrictions.
429 / rate limitedWait for Retry-After and reduce your request or message frequency.
/ping shows no responseKeep the worker running, confirm installation, and select the right bot in the command menu.
Duplicate messages after retriesReuse the same UUID nonce for the same event; advance your cursor after success.

Still stuck? Send a private report through Settings → Bugs. Include the endpoint, status code and a minimal reproduction, with credentials removed.