HTTP API
The backend speaks two versions of its API. v2 streams the agent's work and is what the Allay plugin uses. v1 returns one JSON answer and stays for the archived Telegram bot and plugins before 2.0. This page is the short tour. The full contract with the plugin is the Plugin protocol, and a Postman collection sits in postman.json.
#Who asks and who pays: the headers
Since 6.0 every request but health, a new license, a player's copy by link, and Telegram's webhook carries Authorization: Bearer …: the server's license on a hosted backend, PLUGIN_TOKEN on a self-hosted one. Without it the answer is 401. A server with its own key adds X-Provider-Key: <key> and a provider block in the body. See Security and privacy and Who pays for the model.
Everything about a player is filed under the calling server's tenant: a request reaches only its own server's players, whatever user_id it names.
#v1: one JSON answer
POST /api/ask answers a question, and POST /api/askx turns a request into commands. They run the same agent without game tools.
curl -X POST https://allay.chat/api/ask \
-H "Authorization: Bearer $LICENSE" -H "Content-Type: application/json" \
-d '{"question": "How do I craft a diamond pickaxe?", "platform": "telegram", "user_id": "42"}'
{"answer": "...", "status": "success", "timestamp": "...", "platform": "telegram", "user_id": "42"}
#v2: a stream of events
The plugin opens one POST /api/v2/chat per question:
curl -N -X POST https://allay.chat/api/v2/chat \
-H "Authorization: Bearer $LICENSE" -H "Content-Type: application/json" -H "Accept: text/event-stream" \
-d '{"mode": "ask", "message": "what should I do next?", "user_id": "5627dd98-...", "player": {"name": "Steve"}, "tools": ["get_inventory"]}'
The server answers with Server-Sent Events while the agent works:
startnames the run and the model.reasoningcarries pieces of the model's reasoning, when the model exposes it.tool_callasks the plugin to run a game tool, such as the inventory. The plugin posts the result toPOST /api/v2/chat/{run_id}/tools/{call_id}, with the sameAuthorization. Another server's result gets404.tool_statustells what the agent does right now: reading the inventory, searching the web.textstreams the answer as it's written, thenusageanddoneclose the run. A Minecraft answer comes by whole lines, in the game's&codes: Markdown the model slips in (**bold**,*italics*,# headings, backticks) becomes&l,&o, or plain text first, since the chat would show the stars.
For /askx, a commands event with the command list replaces the text. An error event ends a failed run. With a request_id in the body (since 6.31) the run outlives a dropped connection: GET /api/v2/chat/{run_id}/events with Last-Event-ID reads on, and DELETE /api/v2/chat/{run_id} cancels it (A dropped connection). Plugin protocol has every field of the request and every event.
mode is ask, askx, or task (a wake of an automation agent). visibility: "public" marks a question everyone online sees.
#Other endpoints
The player endpoints are spelled out in Conversation memory, the license in License endpoints, and the panel's setup in Admin panel setup.
| Request | What it does |
|---|---|
GET /api/health |
The name, status, version, whether billing is on, and since 6.9 the privacy policy's revision. Open to anyone |
GET /api/v2/users/{user_id} |
Everything kept about the player: their name, memories and places, deaths, state, consent, session, agents' threads, runs |
POST /api/v2/users/{user_id}/export |
A link to that copy, good for 24 hours. Since 6.9 |
GET /api/v2/exports/{token} |
The copy as a JSON file. The link is the key, so no Authorization. Since 6.9 |
POST /api/v2/users/{user_id}/deaths |
The plugin reports a death: when, where, the cause, the drops. Since 6.9 |
GET, PUT /api/v2/users/{user_id}/state |
The plugin's state for the player: time zone, settings, goals, at most 32 KB. Since 6.9 |
POST /api/v2/chat-history |
The server's chat for chat_history: { server_id, lines: [{ at, channel: "public" | "local" | "private", from: {uuid, name}, to?: {uuid, name}, audience?: [uuid], text }] }, 1–200 lines, text up to 1024 characters with § colors. A private line needs to, a local one names who saw it in audience (up to 200). A line already kept (the same sender and millisecond) is skipped. Answers { saved }. A server hands over at most 1200 lines a minute: past that a batch gets 429 RATE_LIMITED with Retry-After (since 6.34.1), and the plugin sends it again later. No player's consent is needed: the chat is everyone's on the server. Since 6.34 |
DELETE /api/v2/chat-history?server_id=… |
Forgets everything kept of that server's chat, as its admins ask with /allay chathistory reset. Answers { deleted }. Since 6.34 |
GET, PUT /api/v2/users/{user_id}/workstate |
The work state of the player's automation agents on one server, so they go on after a restart, at most 64 KB. Since 6.32; 6.31 calls it /agents, which still works |
PUT /api/v2/server |
The plugin registers its server at start: name, MOTD, address, versions, and since 6.12 what Allay runs on and where (loader, side). A name another tenant's server holds answers 409 NAME_TAKEN |
PUT /api/v2/users/{user_id}/privacy |
Full privacy on or off ({ "full": true }): on, the admin panel forgets the player's name, UUID, and face |
DELETE /api/v2/users/{user_id} |
Erases the player: their name, memories, deaths, state, links, consent, session, threads, and traces go. Runs keep only numbers |
GET, PUT, DELETE /api/v2/users/{user_id}/consent |
Reads, records ({ "version": 2, "hash": "…", "age_confirmed": true, "age_band": "16_17" }), or withdraws the player's agreement to the plugin's notice. Since 6.1, and the hash of the notice, the policy's revision, and the age answer since 6.9. Since 6.9 a withdrawal also erases what the agreement covered and answers { withdrawn, memories, deaths }, and a hosted backend answers 403 CONSENT_REQUIRED to a player without an agreement |
DELETE /api/v2/users/{user_id}/session |
Clears the player's session. Memories stay |
GET, POST, DELETE /api/v2/users/{user_id}/memories |
Lists, adds (with a place since 6.9), or deletes all of the player's memories |
PATCH, DELETE /api/v2/users/{user_id}/memories/{id} |
Changes (since 6.27: text, title, tags, the pin, the place) or deletes one memory |
GET, POST /api/v2/license |
A license and its status. POST without a license makes one, free and open to anyone |
POST /api/v2/admin/init |
A one-time setup or recovery link for the admin panel. Wants PLUGIN_TOKEN |
POST /api/telegram/webhook |
The payment bot's updates |
/api/admin/* |
The admin panel's own API |
#Errors
Before a stream starts, errors come as { "error": { "code", "message" } } with an HTTP status. After it starts, they come as an error event. The codes are listed in Troubleshooting and in the Plugin protocol.
Next: Plugin protocol
