The app API
What the Sonoe chat app (iPhone; later web and others) uses for people. To build a bot, see Sonoe chat bots.
Base: https://sonoeai.com. The same routes exist in two ways:
- with the session:
/api/chat/…, with theX-Sonoe: 1header on changes; - with the app key:
/v1/chat/…, withAuthorization: Bearer sk_sonoe_….
Routes
Relative to /api/chat/ or /v1/chat/.
| Route | What |
|---|---|
GET chats | my chats (most recent first): ultimo, sin_leer, miembros (with admin, leido, estado), bots (with permisos), actividad, silenciado_hasta, con (in a 1:1: the person or the bot) · and the total sin_leer |
POST chats | {"tipo": "directo", "con": "@ana"} or {"con": "/lados"} (if it already exists: the same one, existente: true) · {"tipo": "grupo", "nombre": "…", "miembros": ["@ana", "/lados"]} |
GET chats/{id} · PATCH chats/{id} | one · {"nombre"} (admins) |
POST chats/{id}/members | {"miembro": "@ana"} or "/lados" (admins; a private bot only by its owner) |
PATCH chats/{id}/members/{usuario} · DELETE | {"admin": true} · remove (admins) |
PATCH chats/{id}/bots/{nombre} · DELETE | {"leer_grupo": true} · remove the bot (admins) |
POST chats/{id}/leave · PUT chats/{id}/mute | leave · {"minutos": 60} (null: until unmuted; 0: unmute) |
GET chats/{id}/messages?before=&limit= | oldest to newest, and hay_mas |
POST chats/{id}/messages | {"texto", "responde_a"} |
PATCH · DELETE chats/{id}/messages/{m} | my own |
POST chats/{id}/messages/{m}/reactions · DELETE …/reactions/{valor} | {"emoji"} or {"sticker"} |
POST chats/{id}/messages/{m}/action | {"accion": "id", "valor": "opción"} (a bot's button or option) |
POST chats/{id}/messages/{m}/answer | to a pedido: {"ubicacion": {lat, lng, precision}} · {"valor"} · {"confirmado"} · {"texto"} · {"campos"} · {"rechazado": true} |
POST chats/{id}/read | {"hasta": m} (optional) → leido, total sin_leer (for the badge) |
GET chats/{id}/messages/{m}/seen | "seen by" |
POST chats/{id}/typing | "typing…" (send it every ~3 s while typing; it lasts 6 s) |
GET search?q= | people and bots, each with tipo (@… people only, /… bots only) |
GET stickers · GET people/{usuario} · GET bots/{nombre} | the pack in my language · a profile with its status · a bot (commands, necesita, owner) |
GET · PUT · DELETE status | my status ({"tipo", "emoji", "texto", "cancion", "artista", "destino", "minutos", "app"}) |
GET · POST status/grants · DELETE status/grants/{bot} | which bots can set my status |
GET chats/{id}/stream · GET stream | live (SSE): one chat · my inbox |
GET me | how I look: name, avatar (the shape), foto and status |
PUT me/photo · DELETE me/photo | my photo: the image as the body (Content-Type: image/jpeg, png, webp or gif; up to 8 MB). Sonoe crops it square, makes it a 512 × 512 WebP and strips its metadata |
PUT · DELETE chats/{id}/photo | a group's photo (admins) |
PUT · DELETE my-bots/{nombre}/photo | a bot of yours' photo (the forma and color of its avatar without a photo: PATCH my-bots/{nombre}) |
GET photos/{c, b or g}/{id}.webp?v=… | a photo (the URL foto gives, with its version: it can be cached forever) |
GET · PUT prefs | how I see the chat: {"vista": "lista"} (if never chosen), "burbujas" or "turnos", kept with the account |
PUT chats/{id}/link-previews | {"activo": false}: don't show link previews in that chat (vistas_enlaces on the chat) |
A message
{id, chat, autor, tipo: "texto"|"aviso", texto, bloques, aviso, responde_a, menciones, traza,
reacciones: [{tipo, valor, n, mia, quienes}], estado: "listo"|"escribiendo", medio, creado, editado, borrado}autor: {"tipo": "persona", usuario, nombre, avatar} or {"tipo": "bot", nombre, nombre_visible, avatar, color}; null in a notice. Notices carry a code for the app to translate: aviso.codigo = entro, salio, renombro, admin, no_admin, bot_agregado, bot_quitado, bot_lee_grupo, bot_no_lee_grupo (with usuario, bot, por, nombre).
Live events
They arrive as data: {…}:
| Event | What |
|---|---|
hola | on open: the chat's current actividad, or sin_leer in the inbox |
mensaje · mensaje_editado · mensaje_borrado | a new, edited or deleted message |
mensaje_listo | a stream finished |
flujo | mensaje, delta |
reaccion | |
escribiendo | quien, segundos |
leido | usuario, mensaje |
actividad_bot | bot, actividad or null |
estado | quien, estado |
chat | it changed: fetch it again |
The inbox receives chat, escribiendo, leido (my own), actividad_bot (summarized) and estado. The stream closes every hour: reconnect and fetch what you missed with GET …/messages.
Phone notifications
Register the device with POST /v1/devices {"token", "app": "ios", "environment", "chat": true}. New messages arrive (from people and bots; a stream when it finishes), with aps.badge = everything unread, thread-id/apns-collapse-id = chat-{id}, and in the payload chat, mensaje, mencion, de_bot. A muted chat doesn't notify.