Bot API

Build bots and automations for your Enclave server.

Contents

Getting Started

1
Create a bot

Go to Server Settings → Manage Bots → Create Bot. Give it a name.

2
Copy the token

The bot token is shown once on creation. Copy it and store it securely. You can regenerate it later if needed.

3
Start building

Use any language that supports HTTP requests and/or WebSockets. The examples below use Python, but the API works with Node.js, Go, Rust, or anything else.

Authentication

All bot API requests use the Authorization header with the Bot prefix:

Authorization: Bot your-bot-token-here
Keep your token secret. Anyone with your bot token can send messages as your bot. Never commit tokens to version control or share them publicly.

Send a Message

POST /api/bots/send

Send a message to a channel as your bot.

Request Body

FieldTypeDescription
channelId required string The channel to send the message to. Must be in the bot's server.
content required string Message content (1-4000 characters). Supports Markdown.
replyToId optional string ID of a message to reply to.

Example

import requests

TOKEN = "your-bot-token"
API = "https://enclaveapp.online/api"

requests.post(f"{API}/bots/send", json={
    "channelId": "channel-uuid-here",
    "content": "Hello from my bot! 🤖"
}, headers={"Authorization": f"Bot {TOKEN}"})
Finding the channel ID: Right-click a channel name in Enclave and look at the URL — the last segment is the channel ID. Or use the server info endpoint.

Bot Management

These endpoints are for managing bots via the API. They require admin permissions (use your user JWT, not the bot token).

Create a Bot

POST /api/bots/:serverId

FieldTypeDescription
name requiredstringBot display name (1-32 chars)
avatar optionalstringAvatar URL

Returns the bot object and its token. The token is only shown once.

List Bots

GET /api/bots/:serverId

Returns all bots for the server. Tokens are not included.

Update a Bot

PATCH /api/bots/:serverId/:botId

FieldTypeDescription
name optionalstringNew display name
avatar optionalstring | nullNew avatar URL or null to remove
enabled optionalbooleanEnable or disable the bot

Delete a Bot

DELETE /api/bots/:serverId/:botId

Regenerate Token

POST /api/bots/:serverId/:botId/regenerate

Generates a new token. The old token stops working immediately.

Real-Time Events (Socket.IO)

Bots can connect to Socket.IO to receive real-time events like new messages, reactions, and member changes.

Connecting

import socketio

sio = socketio.Client()
sio.connect("https://enclaveapp.online", auth={
    "botToken": "your-bot-token"
})

On connection, the bot automatically joins all channel rooms in its server and starts receiving events.

Sending via Socket

You can also send messages and reactions through the socket connection:

# Send a message
sio.emit("bot-send-message", {
    "channelId": "channel-uuid",
    "content": "Hello!"
})

# Add a reaction
sio.emit("bot-add-reaction", {
    "messageId": "message-uuid",
    "emoji": "👍"
})

Event Reference

Events your bot receives when connected via Socket.IO:

EventDataDescription
new-messageMessageA new message was sent in a channel
message-editedMessageA message was edited
message-deleted{ messageId }A message was deleted
message-reactions-updated{ messageId, reactions[] }Reactions on a message changed
member-joined{ serverId, member }A new member joined the server
member-left{ serverId, userId }A member left or was removed
server-updatedServerServer settings were changed

Message Object

{
  "id": "uuid",
  "content": "Hello world",
  "channelId": "uuid",
  "userId": "uuid",
  "botId": "uuid" | null,
  "user": { "id", "username", "avatar" },
  "bot": { "id", "name", "avatar" } | null,
  "createdAt": "ISO 8601",
  "replyToId": "uuid" | null,
  "reactions": []
}

Full Example (Python)

A simple bot that responds to !ping with Pong! and !time with the current time:

import requests
import socketio
from datetime import datetime

TOKEN = "your-bot-token"
API = "https://enclaveapp.online/api"
HEADERS = {"Authorization": f"Bot {TOKEN}"}

sio = socketio.Client()

@sio.event
def connect():
    print("Bot connected!")

@sio.on("new-message")
def on_message(data):
    # Ignore messages from this bot
    if data.get("botId"):
        return

    content = data["content"]
    channel = data["channelId"]

    if content == "!ping":
        requests.post(f"{API}/bots/send", json={
            "channelId": channel,
            "content": "Pong! 🏓",
            "replyToId": data["id"]
        }, headers=HEADERS)

    elif content == "!time":
        now = datetime.now().strftime("%H:%M:%S")
        requests.post(f"{API}/bots/send", json={
            "channelId": channel,
            "content": f"The time is **{now}** ⏰"
        }, headers=HEADERS)

sio.connect("https://enclaveapp.online", auth={
    "botToken": TOKEN
})
sio.wait()
Install dependencies: pip install requests python-socketio[client] websocket-client

Rate Limits & Restrictions

Bots have the following limitations:

LimitValue
Max bots per server25
Message content length4,000 characters
Bot name length1-32 characters

Bots cannot: