Referencia para AI Agents
Formato compacto machine-readable para agentes de IA como Antigravity, Claude Code, Cursor, etc. Copiá este bloque en el contexto de tu agente para conectarte al gateway inmediatamente.
bash
# SinapsIA Connect — API Reference for AI Agents
# Version: 1.1 Certified | Base URL: https://wa.sinapsia.com.ar
# Auth: header `apikey: {API_KEY}` on all requests except GET /health
## Instance lifecycle
CREATE POST /instance/create
body: { instanceName, webhookUrl, webhookSecret }
instanceName format: {tenantId}__{clientId}__{label} (lowercase, underscores only)
QR GET /instance/{name}/qr
→ { qrcode: "data:image/png;base64,..." } expires ~40s
PAIRING POST /instance/{name}/pairing-code/request
body: { phoneNumber: "549..." } → { pairingCode: "123456" }
STATUS GET /instance/{name}/status
→ { instanceName, state: "close|connecting|open", phoneNumber, connectedAt, messagesQueuedCount }
LIST GET /tenant/{tenantId}/instances
GET /tenant/{tenantId}/client/{clientId}/instances
QUEUE GET /instance/{name}/queue → { urgent, normal, bulk, total }
DELETE DELETE /instance/{name} → 204
## Send messages (all return 202 { id, status:"pending", lane, queuedAt })
TEXT POST /message/text { instanceName, to, text, lane? }
IMAGE POST /message/image { instanceName, to, imageUrl, caption?, lane? }
DOC POST /message/document { instanceName, to, documentUrl, fileName, caption?, lane? }
AUDIO POST /message/audio { instanceName, to, audioUrl, lane? }
VIDEO POST /message/video { instanceName, to, videoUrl, caption?, lane? }
ROUTE POST /message/route { tenantId, clientId, to, type, ...fields, lane? } # round-robin
MSG STATUS GET /message/{id} → { id, instanceName, lane, to, type, status, createdAt, sentAt, error }
## Lanes
urgent 1-2s delay 150/hr 1000/day # OTP, critical alerts
normal 3-8s delay 80/hr 500/day # conversations, notifications
bulk 8-15s delay 30/hr 200/day # mass campaigns
## Admin / monitoring
STATS GET /admin/stats
FLUSH DELETE /admin/queue/{instanceName} → { instanceName, flushed: N }
HEALTH GET /health (no auth needed)
## Webhooks (POST to your webhookUrl, signed with HMAC-SHA256 in x-gateway-signature)
Retries: 3x at 1s, 5s, 30s
Events: message.received | instance.connected | instance.disconnected
message.received payload:
{ event, instanceName, data: { from, pushName, messageType, text, messageId, timestamp }, timestamp }
messageType: conversation | imageMessage | documentMessage | audioMessage | videoMessage
text is null for media messages. Only fromMe:false messages are forwarded.
## Error codes
400 body invalid (see issues[]) | 401 bad apikey | 403 wrong tenant | 404 not found
409 already exists | 502 WhatsApp error | 500 internal error
## Spintax
{option1|option2} resolved randomly at send time. Supported in: text, caption fields.Instrucciones de uso para el agente
- Obtener
API_KEYytenantIddel operador humano. - Verificar conectividad con
GET /health(no requiere auth). - Crear instancia con
POST /instance/create. ElinstanceNamedebe seguir el formatotenantId__clientId__label. - Polling
GET /instance/{name}/statuscada 3-5s hastastate: "open". - Enviar mensajes con
POST /message/text(o el tipo correspondiente). - Para limpiar al finalizar:
DELETE /instance/{name}.
Gotchas críticos
- El QR expira en ~40s. Volver a llamar
/qrsi se venció. - El número
tova sin+: usar5491112345678, no+54 9 11.... - Todos los envíos son asíncronos (
202). El mensaje no fue enviado aún cuando retorna — se puso en cola. - Si el
instanceNameno empieza con tutenantId, recibirás403. - El
webhookSecretnecesita mínimo 16 caracteres.