# WhatsApp Business

## Obtener plantillas aprobadas de WhatsApp Business

> Retorna todas las plantillas (templates) que están aprobadas en la cuenta de WhatsApp Business vinculada.

```json
{"openapi":"3.0.3","info":{"title":"Prometheo External API","version":"1.0.0"},"tags":[{"name":"WhatsApp Business"}],"servers":[{"url":"https://api.prometheo.ai/public/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key"}},"schemas":{"WabaTemplatesResponse":{"type":"object","required":["success","templates"],"properties":{"success":{"type":"boolean"},"templates":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","description":"ID de la plantilla"},"name":{"type":"string","description":"Nombre de la plantilla"},"language":{"type":"string","description":"Código de idioma de la plantilla"},"status":{"type":"string","description":"Estado de la plantilla (siempre APPROVED en esta respuesta)"},"category":{"type":"string","description":"Categoría de la plantilla"},"components":{"type":"array","description":"Componentes de la plantilla (header, body, footer, buttons)","items":{"type":"object","additionalProperties":true}}}}}}},"ApiError":{"type":"object","required":["success","message"],"properties":{"success":{"type":"boolean"},"message":{"type":"string"},"error":{"type":"string"}}}}},"paths":{"/whatsapp-business/templates":{"get":{"tags":["WhatsApp Business"],"summary":"Obtener plantillas aprobadas de WhatsApp Business","description":"Retorna todas las plantillas (templates) que están aprobadas en la cuenta de WhatsApp Business vinculada.","responses":{"200":{"description":"Plantillas obtenidas exitosamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WabaTemplatesResponse"}}}},"400":{"description":"Conexión de WhatsApp Business no encontrada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"No autorizado (API Key ausente o inválida)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"500":{"description":"Error al obtener plantillas","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}}}}
```

## POST /whatsapp-business/message/text

> Enviar mensaje de texto por WhatsApp Business

```json
{"openapi":"3.0.3","info":{"title":"Prometheo External API","version":"1.0.0"},"tags":[{"name":"WhatsApp Business"}],"servers":[{"url":"https://api.prometheo.ai/public/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key"}},"schemas":{"WabaTextRequest":{"type":"object","required":["phone_number","message"],"properties":{"phone_number":{"type":"string"},"message":{"type":"string"}}},"WabaTextResponse":{"type":"object","required":["success","message","data"],"properties":{"success":{"type":"boolean"},"message":{"type":"string"},"data":{"type":"object","required":["phone_number","sent_at"],"properties":{"whatsapp_business_response":{"type":"object","additionalProperties":true},"phone_number":{"type":"string"},"sent_at":{"type":"string","format":"date-time"}}}}},"ApiError":{"type":"object","required":["success","message"],"properties":{"success":{"type":"boolean"},"message":{"type":"string"},"error":{"type":"string"}}},"Validation24hError":{"type":"object","required":["success","error","message"],"properties":{"success":{"type":"boolean"},"error":{"type":"string","enum":["conversation_not_found","last_user_message_not_found","more_than_24_hours"]},"message":{"type":"string"},"more_than_24_hours":{"type":"boolean","description":"Presente cuando error = more_than_24_hours"},"hours_since_last_message":{"type":"number"},"last_message_at":{"type":"string","format":"date-time"}}}}},"paths":{"/whatsapp-business/message/text":{"post":{"tags":["WhatsApp Business"],"summary":"Enviar mensaje de texto por WhatsApp Business","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WabaTextRequest"}}}},"responses":{"200":{"description":"Enviado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WabaTextResponse"}}}},"400":{"description":"Error de validación, ventana 24h, o conexión WABA ausente","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ApiError"},{"$ref":"#/components/schemas/Validation24hError"}]}}}},"401":{"description":"No autorizado (API Key ausente o inválida)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"500":{"description":"Error interno al enviar el mensaje","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}}}}
```

## Enviar imagen por WhatsApp Business

> Campo del archivo: "image". Tamaño máximo 5MB. Solo imágenes (image/\*).

```json
{"openapi":"3.0.3","info":{"title":"Prometheo External API","version":"1.0.0"},"tags":[{"name":"WhatsApp Business"}],"servers":[{"url":"https://api.prometheo.ai/public/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key"}},"schemas":{"WabaImageResponse":{"type":"object","required":["success","message","data"],"properties":{"success":{"type":"boolean"},"message":{"type":"string"},"data":{"type":"object","required":["phone_number","file_name","file_size","sent_at"],"properties":{"whatsapp_business_response":{"type":"object","additionalProperties":true},"phone_number":{"type":"string"},"file_name":{"type":"string"},"file_size":{"type":"number"},"caption":{"type":"string","nullable":true},"sent_at":{"type":"string","format":"date-time"}}}}},"ApiError":{"type":"object","required":["success","message"],"properties":{"success":{"type":"boolean"},"message":{"type":"string"},"error":{"type":"string"}}},"Validation24hError":{"type":"object","required":["success","error","message"],"properties":{"success":{"type":"boolean"},"error":{"type":"string","enum":["conversation_not_found","last_user_message_not_found","more_than_24_hours"]},"message":{"type":"string"},"more_than_24_hours":{"type":"boolean","description":"Presente cuando error = more_than_24_hours"},"hours_since_last_message":{"type":"number"},"last_message_at":{"type":"string","format":"date-time"}}}}},"paths":{"/whatsapp-business/message/image":{"post":{"tags":["WhatsApp Business"],"summary":"Enviar imagen por WhatsApp Business","description":"Campo del archivo: \"image\". Tamaño máximo 5MB. Solo imágenes (image/*).","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["phone_number","image"],"properties":{"phone_number":{"type":"string","description":"Número de teléfono en formato internacional"},"caption":{"type":"string","nullable":true,"description":"Texto opcional del pie de foto"},"image":{"type":"string","format":"binary","description":"Archivo de imagen (máx 5MB)"}}}}}},"responses":{"200":{"description":"Enviado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WabaImageResponse"}}}},"400":{"description":"Error de validación, tipo de archivo no permitido o límites de Multer","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ApiError"},{"$ref":"#/components/schemas/Validation24hError"}]}}}},"401":{"description":"No autorizado (API Key ausente o inválida)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"500":{"description":"Error interno al enviar la imagen","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}}}}
```

## Enviar mensaje usando una plantilla de WhatsApp Business

> Envía un mensaje usando una plantilla (template) aprobada a un número específico. Las plantillas pueden incluir parámetros dinámicos. Este endpoint NO requiere que el contacto haya enviado un mensaje en las últimas 24 horas.

```json
{"openapi":"3.0.3","info":{"title":"Prometheo External API","version":"1.0.0"},"tags":[{"name":"WhatsApp Business"}],"servers":[{"url":"https://api.prometheo.ai/public/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key"}},"schemas":{"WabaTemplateRequest":{"type":"object","required":["phone_number","template_name","template_language"],"properties":{"phone_number":{"type":"string","description":"Número de teléfono en formato internacional"},"template_name":{"type":"string","description":"Nombre de la plantilla a enviar"},"template_language":{"type":"string","description":"Código de idioma de la plantilla"},"parameters":{"type":"object","description":"Parámetros dinámicos de la plantilla (opcional)","additionalProperties":{"type":"string"}}}},"WabaTemplateResponse":{"type":"object","required":["success","message","data"],"properties":{"success":{"type":"boolean"},"message":{"type":"string"},"data":{"type":"object","required":["phone_number","template_name","template_language","sent_at"],"properties":{"whatsapp_business_response":{"type":"object","additionalProperties":true},"phone_number":{"type":"string"},"template_name":{"type":"string"},"template_language":{"type":"string"},"sent_at":{"type":"string","format":"date-time"}}}}},"ApiError":{"type":"object","required":["success","message"],"properties":{"success":{"type":"boolean"},"message":{"type":"string"},"error":{"type":"string"}}}}},"paths":{"/whatsapp-business/message/template":{"post":{"tags":["WhatsApp Business"],"summary":"Enviar mensaje usando una plantilla de WhatsApp Business","description":"Envía un mensaje usando una plantilla (template) aprobada a un número específico. Las plantillas pueden incluir parámetros dinámicos. Este endpoint NO requiere que el contacto haya enviado un mensaje en las últimas 24 horas.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WabaTemplateRequest"}}}},"responses":{"200":{"description":"Mensaje con plantilla enviado exitosamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WabaTemplateResponse"}}}},"400":{"description":"Error de validación o plantilla no encontrada/no aprobada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"No autorizado (API Key ausente o inválida)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"500":{"description":"Error interno al enviar el mensaje con plantilla","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}}}}
```
