ByDomuDevelopers

Enviar mensaje de WhatsApp

POSThttps://api.bydomu.com/v1/conversations/{contactId}/messages

This reference is generated from the API’s code, so descriptions are in Spanish. Names, parameters and examples are the same in every language.

Envía un mensaje al contacto respetando la ventana de servicio de 24 h de Meta.

  • Ventana abierta: manda body y se entrega como texto libre (la respuesta es el mensaje guardado).
  • Ventana cerrada: manda templateId + variables con una plantilla APROBADA (la respuesta trae waMessageId, renderedBody y usage).
  • Ninguna de las dos es posible (opt-out, sin plantilla, sin ventana): 409 CONFLICT con el motivo en error.message, el modo en error.reason (FREE_FORM, TEMPLATE_ONLY, HUMAN_AGENT_ONLY, BLOCKED) y, si falta la plantilla, error.windowExpiresAt.

La API nunca envía como human_agent: esa vía es de una persona real en el buzón. Si la organización no tiene un número de WhatsApp activo, responde 404.

Permission required

messages:write

Required header

X-API-Key · secret key

Access level

Level 3 · with support review

Path parameters

1 · required
contactIdstring · required
ID del contacto

Headers

1 · all optional
Idempotency-Keystring · optional
Clave única de la operación (8-128 caracteres de [a-zA-Z0-9._:-]). Un reintento con la misma clave y el mismo cuerpo devuelve la respuesta original sin repetir la operación. Vive 24 horas.8–128 chars

Body (JSON)

3 · all optional
bodystring · optional
Texto libre. Solo con la ventana de 24 h abierta.1–4096 chars
templateIdstring · optional
Plantilla aprobada, para la ventana cerrada.
variablesobject · optional
Valores de las variables de la plantilla.default {}

Response 201

SentMessage · 10 fields
dataVentana abierta: el mensaje guardado.
idstring
waMessageIdstring
channelstringWHATSAPP, INSTAGRAM, FACEBOOK, SMS, EMAIL, WEB
directionstringINBOUND, OUTBOUND
typestringTEXT, IMAGE, DOCUMENT, AUDIO, VIDEO, LOCATION
bodystring
timestampstring
contactIdstring
agentIdstring
agentid · firstName · lastName
idstring
firstNamestring
lastNamestring

Possible errors

shaped as { "error": { "code", "message" } }
  • 400Datos inválidos: el cuerpo o la query no cumplen el esquema, o `Idempotency-Key` está mal formada.
  • 401UNAUTHORIZED
  • 402PAYMENT_REQUIRED
  • 403FORBIDDEN
  • 404NOT_FOUND
  • 409DUPLICATE
  • 429RATE_LIMITED
  • 500INTERNAL_ERROR
  • 502WHATSAPP_ERROR
RequestPOST/v1/conversations/{contactId}/messages
Official SDK · @bydomu/sdk · not on npm yet
import { ByDomu } from "@bydomu/sdk";

const bydomu = new ByDomu({
  apiKey: process.env.BYDOMU_API_KEY,
});

const { data } = await bydomu.conversations.sendMessage("clx1con001", {
  "body": "Hola María, ¿te queda bien la visita del jueves a las 10?"
});
201 Created · example
{
  "data": {
    "id": "clx1msg002",
    "waMessageId": "wamid.HBgMNTczMDAxMjM0NTY3FQIAERgSQzU",
    "channel": "WHATSAPP",
    "direction": "INBOUND",
    "type": "TEXT",
    "body": "Hola María, ¿te queda bien la visita del jueves a las 10?",
    "timestamp": "2026-09-25T10:35:00.000Z",
    "contactId": "clx1con001",
    "agentId": "clx1usr001",
    "agent": {
      "id": "clx1usr001",
      "firstName": "Carlos",
      "lastName": "Rodríguez"
    }
  }
}