> For the complete documentation index, see [llms.txt](https://docs.360dialog.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.360dialog.com/docs/messaging-api/api-reference/messages.md).

# Messages

Endpoints for sending and managing messages

## Send Message

> Send a message via the messaging API. Supports text, media, and template messages with automatic routing to marketing messages endpoint when applicable. Supports MM API fallback mechanism, more info: <https://docs.360dialog.com/partner/messaging-and-calling/sending-marketing-messages/technical-details-for-mm-api>.

```json
{"openapi":"3.1.0","info":{"title":"Messaging API","version":"1.51.5"},"tags":[{"name":"Messages","description":"Endpoints for sending and managing messages"}],"servers":[{"description":"Production server","url":"https://waba-v2.360dialog.io"}],"security":[{"D360-API-KEY":[]}],"components":{"securitySchemes":{"D360-API-KEY":{"description":"API Key for Messaging API authentication. Send your API key in the D360-API-KEY header.","in":"header","name":"D360-API-KEY","type":"apiKey"}},"schemas":{"messages.Message":{"properties":{"audio":{"$ref":"#/components/schemas/messages.MediaObject"},"category":{"description":"Direct Send only. Category of the message to send as a template: utility or authentication (charged at the respective rates). Omitting it is equivalent to service: the regular service-message flow, where the message is dropped if the customer service window isn't open","enum":["utility","authentication","service"],"type":"string"},"context":{"$ref":"#/components/schemas/messages.MessageContext"},"direct_send_config":{"$ref":"#/components/schemas/messages.DirectSendConfig","description":"Direct Send only. Configuration of Direct Send features"},"document":{"$ref":"#/components/schemas/messages.MediaObject"},"image":{"$ref":"#/components/schemas/messages.MediaObject"},"interactive":{"$ref":"#/components/schemas/messages.InteractiveObject"},"location":{"$ref":"#/components/schemas/messages.LocationMessage"},"messaging_product":{"type":"string"},"reaction":{"$ref":"#/components/schemas/messages.ReactionMessage"},"recipient":{"description":"Business-scoped user ID (BSUID) of the message recipient, in the form <ISO 3166-2 country code>.<up to 128 alphanumeric chars>. Alternative to 'to'; required if 'to' is omitted","type":"string"},"recipient_type":{"enum":["individual","group"],"type":"string"},"sticker":{"$ref":"#/components/schemas/messages.MediaObject"},"template":{"$ref":"#/components/schemas/messages.TemplateMessage"},"text":{"$ref":"#/components/schemas/messages.TextMessage"},"to":{"description":"WhatsApp ID or phone number of the message recipient. Required unless recipient (BSUID) is provided","type":"string"},"ttl_seconds":{"description":"Direct Send only. Custom time-to-live of the message in seconds; requires category utility or authentication. Utility: 30-43200 (default 30 days). Authentication: 30-900 (default 600)","maximum":43200,"minimum":30,"type":"integer"},"type":{"enum":["text","image","audio","video","document","sticker","location","contacts","interactive","template","reaction"],"type":"string"},"video":{"$ref":"#/components/schemas/messages.MediaObject"}},"required":["messaging_product","recipient_type","type"],"type":"object"},"messages.MediaObject":{"properties":{"id":{"type":"string"},"link":{"type":"string"}},"type":"object"},"messages.MessageContext":{"properties":{"message_id":{"type":"string"}},"type":"object"},"messages.DirectSendConfig":{"properties":{"template_name":{"description":"Unique template name within the WABA. When provided, Direct Send creates or reuses a template with this exact name instead of auto-matching. Lowercase alphanumeric characters and underscores only","maxLength":512,"pattern":"^[a-z0-9_]+$","type":"string"}},"type":"object"},"messages.InteractiveObject":{"properties":{"action":{"$ref":"#/components/schemas/messages.ActionObject"},"body":{"$ref":"#/components/schemas/messages.BodyObject"},"footer":{"$ref":"#/components/schemas/messages.FooterObject"},"header":{"$ref":"#/components/schemas/messages.HeaderObject"},"type":{"enum":["button","call_permission_request","catalog_message","list","product","product_list","flow"],"type":"string"}},"type":"object"},"messages.ActionObject":{"additionalProperties":{},"type":"object"},"messages.BodyObject":{"properties":{"text":{"type":"string"}},"type":"object"},"messages.FooterObject":{"properties":{"text":{"type":"string"}},"type":"object"},"messages.HeaderObject":{"properties":{"document":{"$ref":"#/components/schemas/messages.MediaObject"},"image":{"$ref":"#/components/schemas/messages.MediaObject"},"text":{"type":"string"},"type":{"enum":["text","video","image","document"],"type":"string"},"video":{"$ref":"#/components/schemas/messages.MediaObject"}},"type":"object"},"messages.LocationMessage":{"properties":{"address":{"type":"string"},"latitude":{"type":"number"},"longitude":{"type":"number"},"name":{"type":"string"}},"type":"object"},"messages.ReactionMessage":{"properties":{"emoji":{"type":"string"},"message_id":{"type":"string"}},"type":"object"},"messages.TemplateMessage":{"properties":{"components":{"items":{"$ref":"#/components/schemas/messages.TemplateComponent"},"type":"array","uniqueItems":false},"language":{"$ref":"#/components/schemas/messages.LanguageObject"},"name":{"type":"string"}},"required":["language","name"],"type":"object"},"messages.TemplateComponent":{"properties":{"index":{"type":"integer"},"parameters":{"items":{"$ref":"#/components/schemas/messages.TemplateParameter"},"type":"array","uniqueItems":false},"sub_type":{"enum":["quick_reply","url"],"type":"string"},"type":{"enum":["header","body","button"],"type":"string"}},"required":["type"],"type":"object"},"messages.TemplateParameter":{"properties":{"currency":{"$ref":"#/components/schemas/messages.Currency"},"date_time":{"$ref":"#/components/schemas/messages.DateTime"},"document":{"$ref":"#/components/schemas/messages.MediaObject"},"image":{"$ref":"#/components/schemas/messages.MediaObject"},"location":{"$ref":"#/components/schemas/messages.LocationMessage"},"text":{"type":"string"},"type":{"enum":["text","currency","date_time","image","document","video","location"],"type":"string"},"video":{"$ref":"#/components/schemas/messages.MediaObject"}},"type":"object"},"messages.Currency":{"properties":{"amount_1000":{"type":"integer"},"code":{"type":"string"},"fallback_value":{"type":"string"}},"type":"object"},"messages.DateTime":{"properties":{"fallback_value":{"type":"string"}},"type":"object"},"messages.LanguageObject":{"properties":{"code":{"type":"string"}},"required":["code"],"type":"object"},"messages.TextMessage":{"properties":{"body":{"type":"string"},"preview_url":{"type":"boolean"}},"type":"object"},"messages.MessageResponsePayload":{"properties":{"contacts":{"items":{"$ref":"#/components/schemas/messages.ResponseContact"},"type":"array","uniqueItems":false},"messages":{"items":{"$ref":"#/components/schemas/messages.ResponseMessage"},"type":"array","uniqueItems":false},"messaging_product":{"type":"string"}},"type":"object"},"messages.ResponseContact":{"properties":{"input":{"description":"Recipient identifier as sent in the request (phone number or BSUID)","type":"string"},"user_id":{"description":"Business-scoped user ID (BSUID) of the recipient. Present only for businesses onboarded to BSUID","type":"string"},"wa_id":{"description":"WhatsApp ID of the recipient","type":"string"}},"type":"object"},"messages.ResponseMessage":{"properties":{"id":{"type":"string"},"message_status":{"enum":["accepted","held_for_quality_assessment","paused"],"type":"string"}},"type":"object"},"utils.ErrorResp":{"properties":{"error":{"type":"string"}},"type":"object"},"utils.ErrorCodeResp":{"properties":{"code":{"description":"Machine-readable error code. insufficient_balance: the account ran out of funds while sending; add funds to continue","enum":["insufficient_balance"],"type":"string"},"error":{"type":"string"}},"type":"object"}}},"paths":{"/messages":{"post":{"description":"Send a message via the messaging API. Supports text, media, and template messages with automatic routing to marketing messages endpoint when applicable. Supports MM API fallback mechanism, more info: https://docs.360dialog.com/partner/messaging-and-calling/sending-marketing-messages/technical-details-for-mm-api.","operationId":"send-message","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/messages.Message","summary":"requestBody","description":"Message Payload"}}},"description":"Message Payload","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/messages.MessageResponsePayload"}}},"description":"Message sent successfully"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/utils.ErrorResp"}}},"description":"Bad request"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/utils.ErrorResp"}}},"description":"Unauthorized"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/utils.ErrorCodeResp"}}},"description":"Forbidden - Sending is blocked for this number, or the balance is too low to send (code insufficient_balance)"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/utils.ErrorResp"}}},"description":"Internal server error"}},"summary":"Send Message","tags":["Messages"]}}}}
```

## Send Sample Message

> Submit a sample of a message and use case you plan to send via Direct Send, so Meta can classify it and generate a matching template. Upload 3-4 samples covering the message types and use cases you intend to send.

```json
{"openapi":"3.1.0","info":{"title":"Messaging API","version":"1.51.5"},"tags":[{"name":"Messages","description":"Endpoints for sending and managing messages"}],"servers":[{"description":"Production server","url":"https://waba-v2.360dialog.io"}],"security":[{"D360-API-KEY":[]}],"components":{"securitySchemes":{"D360-API-KEY":{"description":"API Key for Messaging API authentication. Send your API key in the D360-API-KEY header.","in":"header","name":"D360-API-KEY","type":"apiKey"}},"schemas":{"messages.SampleMessage":{"properties":{"category":{"description":"Required when submitting multiple button samples in a single request","enum":["utility","marketing","authentication"],"type":"string"},"interactive":{"$ref":"#/components/schemas/messages.InteractiveObject"},"text":{"$ref":"#/components/schemas/messages.TextMessage"},"type":{"enum":["text","interactive"],"type":"string"}},"required":["type"],"type":"object"},"messages.InteractiveObject":{"properties":{"action":{"$ref":"#/components/schemas/messages.ActionObject"},"body":{"$ref":"#/components/schemas/messages.BodyObject"},"footer":{"$ref":"#/components/schemas/messages.FooterObject"},"header":{"$ref":"#/components/schemas/messages.HeaderObject"},"type":{"enum":["button","call_permission_request","catalog_message","list","product","product_list","flow"],"type":"string"}},"type":"object"},"messages.ActionObject":{"additionalProperties":{},"type":"object"},"messages.BodyObject":{"properties":{"text":{"type":"string"}},"type":"object"},"messages.FooterObject":{"properties":{"text":{"type":"string"}},"type":"object"},"messages.HeaderObject":{"properties":{"document":{"$ref":"#/components/schemas/messages.MediaObject"},"image":{"$ref":"#/components/schemas/messages.MediaObject"},"text":{"type":"string"},"type":{"enum":["text","video","image","document"],"type":"string"},"video":{"$ref":"#/components/schemas/messages.MediaObject"}},"type":"object"},"messages.MediaObject":{"properties":{"id":{"type":"string"},"link":{"type":"string"}},"type":"object"},"messages.TextMessage":{"properties":{"body":{"type":"string"},"preview_url":{"type":"boolean"}},"type":"object"},"messages.SampleMessageResponse":{"properties":{"category":{"enum":["UTILITY","MARKETING","AUTHENTICATION"],"type":"string"},"success":{"type":"boolean"}},"type":"object"},"utils.ErrorResp":{"properties":{"error":{"type":"string"}},"type":"object"},"utils.ErrorCodeResp":{"properties":{"code":{"description":"Machine-readable error code. insufficient_balance: the account ran out of funds while sending; add funds to continue","enum":["insufficient_balance"],"type":"string"},"error":{"type":"string"}},"type":"object"}}},"paths":{"/messages/sample":{"post":{"description":"Submit a sample of a message and use case you plan to send via Direct Send, so Meta can classify it and generate a matching template. Upload 3-4 samples covering the message types and use cases you intend to send.","operationId":"post-sample-message","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/messages.SampleMessage","summary":"requestBody","description":"Sample message payload"}}},"description":"Sample message payload","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/messages.SampleMessageResponse"}}},"description":"Sample classified successfully"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/utils.ErrorResp"}}},"description":"Bad request"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/utils.ErrorResp"}}},"description":"Unauthorized"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/utils.ErrorCodeResp"}}},"description":"Forbidden - Sending is blocked for this number, or the balance is too low to send (code insufficient_balance)"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/utils.ErrorResp"}}},"description":"Internal server error"}},"summary":"Send Sample Message","tags":["Messages"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.360dialog.com/docs/messaging-api/api-reference/messages.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
