Texto, moneda y fecha
Resumen para integración
- Endpoint:
POST https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging- Token: de mensajería, en el encabezado
Authorization: Bearer {{wa-msg-api-token}}(cómo generarlo)- Campos comunes:
from,to(teléfono o BSUID) ytype(detalle)- Valores de
typeen esta página:"template"- Respuesta: la misma para todos los mensajes (ver respuesta)
Parámetros de texto, moneda y fecha y hora que se sustituyen en los componentes header y body de la plantilla. Todos se envían con POST /v1/messaging; los encabezados, los campos comunes y la respuesta están en Conexión HTTP. La estructura general de la plantilla (objetos template y components) está en Mensajes con plantilla.
Texto
Parámetro de texto para los componentes header y body. En el objeto del parámetro, type debe ser "text".
Cuerpo
Campos de Texto:
| Nombre | Descripción | Tipo | Requerimientos |
|---|---|---|---|
| type | El valor es “text”. | String | Obligatorio |
| text | Texto que se sustituye en el componente. | String | Obligatorio (máximo 1024 caracteres) |
| parameter_name | Nombre del parámetro. Único valor aceptado: otp_code. | String | Opcional |
Ejemplo
Ejemplo completo de Texto (petición HTTP y cuerpo JSON):
Petición HTTP con header texto
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template":{"language": "es","name": "header_text","components":[{"type":"header","parameters":[{"type":"text","text":"123456"}]}]}}'
Body con header texto
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "header_text","components": [{"type": "header","parameters": [{"text": "123456","type": "text"}]}]}}
Petición HTTP con body texto
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template":{"language": "es","name": "body_text","components":[{"type":"body","parameters":[{"type":"text","text":"123456"}]}]}}'
Body con body texto
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "body_text","components": [{"type": "body","parameters": [{"text": "123456","type": "text"}]}]}}
Currency
Parámetro de moneda para los componentes header y body. En el objeto del parámetro, type debe ser "currency".
Cuerpo
Campos de Currency:
| Nombre | Descripción | Tipo | Requerimientos |
|---|---|---|---|
| type | El valor es “currency”. | String | Obligatorio |
| currency | Objeto con los datos de la moneda. | Objeto | Obligatorio |
Campos del objeto currency:
| Nombre | Descripción | Tipo | Requerimientos |
|---|---|---|---|
| fallback_value | En caso de que no se reconozca el código de moneda, se utilizará el valor de fallback_value. | String | Obligatorio |
| code | Código de moneda (ISO 4217). | String | Obligatorio |
| amount | Monto multiplicado por 1000, como un entero (por ejemplo, 100.99 → 100990). Internamente se representa como un entero de 64 bits, por lo que puedes enviar valores de moneda más allá del rango de Integer sin truncamiento. | Number | Obligatorio |
Ejemplo
Ejemplo completo de Currency (petición HTTP y cuerpo JSON):
Petición HTTP con header currency
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template":{"language": "es","name": "template_utility_23","components":[{"type":"header","parameters": [{"type": "currency","currency": {"fallback_value": "$100.99","code": "MXN","amount": 100990}}]}]}}'
Body con header currency
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "template_utility_23","components": [{"type": "header","parameters": [{"type": "currency","currency": {"fallback_value": "$100.99","code": "MXN","amount": 100990}}]}]}}
Petición HTTP con body currency
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template":{"language": "es","name": "template_utility_23","components":[{"type":"body","parameters": [{"type": "currency","currency": {"fallback_value": "$100.99","code": "MXN","amount": 100990}}]}]}}'
Body con body currency
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "template_utility_23","components": [{"type": "body","parameters": [{"type": "currency","currency": {"fallback_value": "$100.99","code": "MXN","amount": 100990}}]}]}}
Date time
Parámetro de fecha y hora para los componentes header y body. En el objeto del parámetro, type debe ser "date_time".
Cuerpo
Campos de Date time:
| Nombre | Descripción | Tipo | Requerimientos |
|---|---|---|---|
| type | El valor es “date_time”. | String | Obligatorio |
| date_time | Objeto con los datos de la fecha. | Objeto | Obligatorio |
Campos del objeto date_time (al menos uno de day_of_month, month, day_of_week, hour, year o minute debe estar presente):
| Nombre | Descripción | Tipo | Requerimientos |
|---|---|---|---|
| fallback_value | En caso de que no se reconozca la fecha, se utilizará el valor de fallback_value. | String | Obligatorio |
| day_of_month | Día del mes. | Number | Opcional |
| day_of_week | Día de la semana. | String | Opcional |
| year | Año. | Number | Opcional |
| month | Mes. | Number | Opcional |
| hour | Hora. | Number | Opcional |
| minute | Minuto. | Number | Opcional |
Ejemplo
Ejemplo completo de Date time (petición HTTP y cuerpo JSON):
Petición HTTP con header date time
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template":{"language": "es","name": "header_date_time","components":[{"type":"header","parameters": [{"type": "date_time","date_time": {"fallback_value": "Octubre 2, 1990","day_of_month": 30,"year": 2021,"month": 3,"hour": 13,"minute": 19}}]}]}}'
Body con header date time
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "header_date_time","components": [{"type": "header","parameters": [{"type": "date_time","date_time": {"fallback_value": "Octubre 2, 1990","day_of_month": 30,"year": 2021,"month": 3,"hour": 13,"minute": 19}}]}]}}
Petición HTTP con body date time
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template":{"language": "es","name": "body_date_time","components":[{"type":"body","parameters": [{"type": "date_time","date_time": {"fallback_value": "Octubre 2, 1990","day_of_month": 30,"year": 2021,"month": 3,"hour": 13,"minute": 19}}]}]}}'
Body con body date time
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "body_date_time","components": [{"type": "body","parameters": [{"type": "date_time","date_time": {"fallback_value": "Octubre 2, 1990","day_of_month": 30,"year": 2021,"month": 3,"hour": 13,"minute": 19}}]}]}}
