Bot API reference (v1)
Base URL: https://<your-yuva-host>/api/bot/v1. Every authenticated request carries Authorization: Bot <token> (authentication). Request and response bodies are JSON (content-type: application/json), except the file upload, which takes the raw file bytes.
The full OpenAPI 3.1.0 schema is served at GET /api/bot/v1/openapi.json without authentication.
Headers and errors#
Every response carries X-Request-Id (if your request sends a valid [A-Za-z0-9_-]{1,64} id, it is echoed back) and X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset (seconds). A 429 also sends Retry-After (seconds), and a 405 sends Allow.
Error responses are always { "error": "<Turkish message>", "code": "<CODE>", "docs": "https://yuva.chat/gelistirici#<CODE>" }, plus optional field (for validation errors) and retryAfter (seconds on 429).
| Status | Code | Meaning |
|---|---|---|
| 400 | BAD_REQUEST | Malformed request (bad id, missing content-type, invalid JSON, out-of-range limit/cursor, …). |
| 401 | INVALID_TOKEN | Missing, wrong, expired, revoked or rotated token, or the bot was deleted. |
| 403 | FORBIDDEN / SCOPE_MISSING | Lacks lodge/channel right (write, speak, manageMessages, …) or token scope (read/write/voice). |
| 404 | NOT_FOUND / UNKNOWN_ROUTE | Unknown endpoint, or missing/inaccessible lodge, channel, message or voice room. |
| 405 | METHOD_NOT_ALLOWED | The endpoint exists but not with this HTTP method (Allow lists accepted methods). |
| 409 | VOICE_UPGRADE_REQUIRED | LiveKit lodge joined without "sfu": true (voice). |
| 411 | CONTENT_LENGTH_REQUIRED | File upload missing a valid content-length header. |
| 413 | PAYLOAD_TOO_LARGE | Body too large (JSON over 512 kB, or file over upload limit). |
| 415 | UNSUPPORTED_MEDIA_TYPE | File type or content signature not accepted for upload. |
| 429 | RATE_LIMITED | Rate limited (rate limits). Wait Retry-After seconds. |
| 500 | INTERNAL | Server error. Retry later with backoff and share X-Request-Id. |
Ids: lodges (servers), channels (rooms) and messages have integer ids. Users and bots have string ids; a bot's id looks like bot_0123456789abcdef01234567. Timestamps are ISO 8601 strings in UTC.
Objects#
Lodge#
jsonc
{ "id": 12, "name": "Kahve Evi", "slug": "kahve-evi", "hue": 210, "inviteCode": null, // always null for bots "ownerId": "u_…", "memberCount": 41, "memberDms": true, "myAllowDms": false, "myRole": "member", "myPerms": { "read": true, "write": true, "speak": true, "share": false, "mention": true, "mentionAll": false }, "myStaff": { "manageChannels": false, "manageMessages": false, "muteMembers": false, "moveMembers": false, "kickMembers": false, "assignRoles": false, "manageInvites": false, "manageBots": false, "overrideRanks": false }}myPerms are the bot's lodge-wide rights; a room can narrow or widen them with overrides, so use each channel's own perms (below) to decide what to do in a room.
Channel#
jsonc
{ "id": 301, "lodgeId": 12, "slug": "genel", "name": "genel", "topic": "", "sortOrder": 0, "kind": "text", // "text" or "voice" "userLimit": 0, // 0 = unlimited; 1–99 on voice rooms "perms": { "read": true, "write": true, "speak": false, "share": false, "mention": true, "mentionAll": false } }Member#
People and bots in a lodge. Bots have "isBot": true.
jsonc
{ "userId": "u_…", "displayName": "Ayşe", "handle": "ayse#0042", "bio": "", "avatarHue": 30, "avatarVersion": 0, "presence": "online", "isAdmin": false, "isBot": false, "joinedAt": "…", "lastSeenAt": "…", "lodgeRoleId": 5, "lodgeRoleName": "Moderatör", "lodgeOwner": false, "perms": { … }, "staff": { … } }Members carry more display fields (pronouns, status, look, banner, activity); ignore what you don't need.
Message#
jsonc
{ "id": 9001, "channelId": 301, "body": "selam @ayse", "createdAt": "2025-05-01T10:00:00.000Z", "author": { "userId": "bot_…", "displayName": "Zar Botu", "handle": "zar-botu#1234", "avatarHue": 120, "avatarVersion": 0, "isBot": true }, "hasImage": false, // image bytes: GET /api/media/image/{id} is session-only; bots read `body` "file": null, // or { "id": 7, "name": "rapor.pdf", "size": 1234, "mime": "application/pdf", // "voice": null | { "durationMs": 4200, "peaks": number[] } } (a voice message) "expiredAttachment": null, "replyTo": null, // the message this one answers: { "id", "author", "excerpt", "deleted", // "attachment": "image" | "file" | "voice" | "poll" | null } "preview": null, // link card for the first URL: { "url", "siteName", "title", "description", // "image": { "width", "height" } | null }; arrives later as a `message.update` "poll": null, // { "id", "options": [{ "id", "text", "votes", "mine" }], "multiple", "closesAt", // "closed", "voters" } "saved": false, // the reader's own bookmark; always false for a bot "reactions": [{ "emoji": "heart", "count": 2, "me": false }], "pinned": false, "editedAt": null, "deleted": false, "expiresAt": null}Mentions are written in the body: @name (or @name#1234 when the name is ambiguous); @everyone / @here ping the room. A mention needs the mention right, @everyone/@here need mentionAll; without them the message is refused (403), the same as for a person.
Event#
jsonc
{ "type": "message.create", "lodgeId": 12, "channelId": 301, "message": { … } }{ "type": "message.update", "lodgeId": 12, "channelId": 301, "message": { … } } // edit, reaction, pin, link card, poll vote{ "type": "message.delete", "lodgeId": 12, "channelId": 301, "messageId": 9001 }Meta & Discovery#
GET /meta (and GET /api/bot/v1)#
Unauthenticated metadata endpoint returning { "api": 1, "minSdk": { "js": "2.0.0", "python": "0.2.0" }, "limits": { … }, "uploads": UploadPolicy }. uploads is what a trusted member may upload right now, as site admins set it in Yönetim → Dosyalar: extensions (lowercase, no dot), maxMb, memberMaxMb, perTypeMb (tighter caps per extension), ttlHours, dailyFiles, dailyMb. Read it again rather than caching it for long: admins can change it at any time.
curl https://yuva.chat/api/bot/v1/metaGET /openapi.json#
Returns the full OpenAPI 3.1.0 JSON specification without authentication.
curl https://yuva.chat/api/bot/v1/openapi.jsonAccount#
GET /me#
The bot's own member record, active token metadata (id, label, scopes, createdAt, expiresAt), effective BotGrant per lodge and its own upload rules: { "bot": Member, "token": TokenMeta, "grants": [{ "lodgeId", "lodgeName", "grant" }], "uploads": UploadPolicy | null }. uploads uses the bot's own size cap (as on /meta), and is null while the bot is untrusted (no uploads at all). Use bot.userId to skip your own messages in events.
curl -H "Authorization: Bot $YUVA_BOT_TOKEN" https://yuva.chat/api/bot/v1/meLodges#
GET /lodges#
Requires scope read. The lodges the bot was added to. { "lodges": Lodge[] }.
curl -H "Authorization: Bot $YUVA_BOT_TOKEN" https://yuva.chat/api/bot/v1/lodgesGET /lodges/{lodgeId}#
Requires scope read. { "lodge": Lodge, "channels": Channel[], "members": Member[] }. Only rooms the bot can read are listed, each with the bot's effective rights there (after room overrides). 404 if the bot is not in this lodge.
curl -H "Authorization: Bot $YUVA_BOT_TOKEN" https://yuva.chat/api/bot/v1/lodges/12GET /lodges/{lodgeId}/members#
Requires scope read. Paginated member list with limit (1–200, default 50) and cursor. Response: { "members": Member[], "nextCursor": string | null }.
curl -H "Authorization: Bot $YUVA_BOT_TOKEN" "https://yuva.chat/api/bot/v1/lodges/12/members?limit=50"Messages#
GET /channels/{channelId}/messages#
Requires scope read. Up to 100 messages, oldest first. Needs read in the room.
| Query | Meaning |
|---|---|
| (none) | The newest page. |
beforeId | The page just before this message id (older history). |
afterId | Messages after this id (catching up). |
aroundId | A page centred on this message. |
Response: { "messages": Message[] }.
curl -H "Authorization: Bot $YUVA_BOT_TOKEN" "https://yuva.chat/api/bot/v1/channels/301/messages?beforeId=9001"POST /channels/{channelId}/messages#
Requires scope write and write in the room (plus mention / mentionAll for mentions). Accepts an optional Idempotency-Key header (1–128 chars): repeating the same key within 24 hours returns the original response without creating a duplicate message.
jsonc
{ "body": "Merhaba!", // up to 20000 characters; may be empty when an attachment is sent "fileId": 7, // optional: an id from POST /channels/{id}/files "replyToId": 9001, // optional: a message in the same room this one answers; its author is // notified like a mention when the bot has the `mention` right "image": { // optional, instead of fileId: an inline JPEG "mime": "image/jpeg", "data": "<base64, at most 350000 chars>", "width": 640, "height": 480 }}Response: { "message": Message }. Attachments need a trusted account; a bot inherits its owner's trust level, capped at trusted.
A longer text doesn't fit body; send it as a .txt attachment instead (upload it with POST /channels/{id}/files, then send its fileId with an empty body), as the apps do when a draft passes 20000 characters. Every client shows .txt and .log attachments inline, so they read without a download.
curl -X POST -H "Authorization: Bot $YUVA_BOT_TOKEN" -H "Content-Type: application/json" \ -H "Idempotency-Key: msg-123" -d '{"body":"Merhaba!"}' \ https://yuva.chat/api/bot/v1/channels/301/messagesPOST /channels/{channelId}/files#
Requires scope write and write in the room. Upload a file to attach to a message. Body: the raw bytes. Headers: content-length (required), x-file-name: <url-encoded file name> (its extension decides the type), optional Idempotency-Key. Response: { "file": { "id", "name", "size", "mime" } }. Then send a message with "fileId": file.id. Uploads follow the rules in uploads (GET /me): a closed extension is 415, a file over maxMb (or the extension's perTypeMb) is 413, and the daily quota (dailyFiles files / dailyMb MB per rolling 24 hours, shared with the bot's account like a person's) is 429. Files are deleted ttlHours after upload.
curl -X POST -H "Authorization: Bot $YUVA_BOT_TOKEN" \ -H "Content-Length: 12" -H "X-File-Name: note.txt" --data-binary "hello world!" \ https://yuva.chat/api/bot/v1/channels/301/filesPOST /channels/{channelId}/typing#
Requires scope write and write in the room. Broadcasts a typing indicator ({ "typing": true } by default). Response: { "ok": true }.
curl -X POST -H "Authorization: Bot $YUVA_BOT_TOKEN" -H "Content-Type: application/json" \ -d '{"typing":true}' https://yuva.chat/api/bot/v1/channels/301/typingGET /channels/{channelId}/changes?since=<cursor>#
Requires scope read. Edits, deletions (as deleted: true tombstones), reactions and pins in one room since since. Without since you get only a starting cursor. Response: { "changed": Message[], "now": "<cursor for the next call>" }. The cursor overlaps by a few seconds; apply changes idempotently. Most bots use /events instead.
curl -H "Authorization: Bot $YUVA_BOT_TOKEN" "https://yuva.chat/api/bot/v1/channels/301/changes"GET /messages/{messageId}#
Requires scope read and read in the message's room. Fetches a single non-deleted message. Response: { "message": Message }.
curl -H "Authorization: Bot $YUVA_BOT_TOKEN" https://yuva.chat/api/bot/v1/messages/9001PATCH /messages/{messageId}#
Requires scope write. Edit the bot's own message. Body { "body": "new text" }. Response { "message": Message }.
curl -X PATCH -H "Authorization: Bot $YUVA_BOT_TOKEN" -H "Content-Type: application/json" \ -d '{"body":"güncel"}' https://yuva.chat/api/bot/v1/messages/9001DELETE /messages/{messageId}#
Requires scope write. Delete the bot's own message, or anyone's in a room where the bot has the manageMessages staff right. { "ok": true }.
curl -X DELETE -H "Authorization: Bot $YUVA_BOT_TOKEN" https://yuva.chat/api/bot/v1/messages/9001POST /messages/{messageId}/reactions#
Requires scope write and write in the room. Toggle a reaction. Body { "emoji": "heart" }: a built-in key (heart, up, smile, fire, spark), a lodge custom emoji as c<id> (only in its own lodge), or one Unicode emoji ("🔥", "👍🏽", "🧑💻", "🇹🇷": a single RGI emoji sequence, skin tones and ZWJ sequences included; text, several emoji or an empty string get Bu tepki yok.). Response { "reactions": Reaction[] }.
curl -X POST -H "Authorization: Bot $YUVA_BOT_TOKEN" -H "Content-Type: application/json" \ -d '{"emoji":"heart"}' https://yuva.chat/api/bot/v1/messages/9001/reactionsDELETE /messages/{messageId}/reactions/{emoji}#
Requires scope write and write in the room. Removes the bot's own reaction (idempotent). URL-encode Unicode emojis. Response { "reactions": Reaction[] }.
curl -X DELETE -H "Authorization: Bot $YUVA_BOT_TOKEN" https://yuva.chat/api/bot/v1/messages/9001/reactions/heartPOST /messages/{messageId}/pin#
Requires scope write and the manageMessages staff right. Toggle a pin. Response { "pinned": boolean }.
curl -X POST -H "Authorization: Bot $YUVA_BOT_TOKEN" https://yuva.chat/api/bot/v1/messages/9001/pinDELETE /messages/{messageId}/pin#
Requires scope write and manageMessages. Idempotently unpins a message; succeeds even if already unpinned. Response { "pinned": false }.
curl -X DELETE -H "Authorization: Bot $YUVA_BOT_TOKEN" https://yuva.chat/api/bot/v1/messages/9001/pinEvents#
GET /events?cursor=<cursor>#
Requires scope read. Long-lived bots poll this every 1–3 seconds (or receive push deliveries via webhooks). It reports new, edited and deleted messages in every text room, in every lodge, the bot can read.
First call without
cursor:{ "events": [], "cursor": "…" }: nothing yet, just where to start.Later calls with the last
cursor:{ "events": Event[], "cursor": "…" }. Always keep the returned cursor.At most 100 new messages per call; if you got 100, poll again right away.
message.updateevents can repeat for a few seconds after a change; treat them as "this is the message now".The bot's own messages appear too: compare
message.author.userIdwithGET /me.Rooms the bot gains or loses access to are picked up automatically on the next call.
curl -H "Authorization: Bot $YUVA_BOT_TOKEN" "https://yuva.chat/api/bot/v1/events"Voice#
All voice endpoints require scope voice. See the voice guide for the full flow, LiveKit and mesh. All voice endpoints are per lodge.
A lodge's voice runs on LiveKit or as a peer-to-peer mesh, and every VoicePeer says which with sfu. In a LiveKit lodge, a join or beat without "sfu": true is refused with 409 (VOICE_UPGRADE_REQUIRED) "Bu sunucunun sesi LiveKit üzerinden. yuva-bot 2.0.0 (JS) veya 0.2.0 (Python) gerekir.": the client has to be updated, retrying does not help. Send "sfu": true always; it changes nothing in a mesh lodge.
GET /voice/ice#
ICE (STUN/TURN) servers for the mesh's WebRTC links (a LiveKit lodge doesn't need them). { "iceServers": [{ "urls": string | string[], "username"?, "credential"? }], "expiresAt": number | null }.
GET /lodges/{lodgeId}/voice#
Who is in which voice room of the lodge. { "peers": VoicePeer[] }.
POST /lodges/{lodgeId}/voice/join#
Take a seat in a voice room. Body { "channelId": 302, "muted": false, "deafened": false, "sfu": true }. Needs speak in that room. If the room has userLimit > 0 and is full, joining fails with 403 ("Bu oda dolu (N/M).") unless the bot has moveMembers. Joining another room of the same lodge moves the seat. Response { "peers": VoicePeer[] }.
POST /lodges/{lodgeId}/voice/beat#
Keep the seat. Send every 5 seconds; a seat without a beat for 20 seconds is dropped. Body { "channelId": 302, "muted": false, "deafened": false, "sfu": true }. Response { "peers": VoicePeer[] }.
POST /lodges/{lodgeId}/voice/media#
The media ticket for the bot's current seat. Body optional ({ "session": "…" }). In a LiveKit lodge: { "media": { "url": "wss://…", "token": "<JWT>", "room": "l12-v302", "expiresAt": 1794500000000 } }. In a mesh lodge: { "media": null }.
POST /lodges/{lodgeId}/voice/leave#
Give up the seat (with a session, only if the seat is still that session's). Body optional. { "ok": true }.
POST /lodges/{lodgeId}/voice/signals#
Mesh lodges only. Send one WebRTC signal to a peer in the same room. Body { "channelId": 302, "toId": "u_…", "kind": "offer" | "answer" | "ice", "payload": "<JSON string, ≤ 20000 chars>" }. { "ok": true }.
POST /lodges/{lodgeId}/voice/drain#
Mesh lodges only. Signals addressed to the bot, oldest first. Body { "channelId": 302, "ack": [ids handled since the last drain] }. Response { "signals": [{ "id": 55, "fromId": "u_…", "kind": "offer", "payload": "…" }] }.