> For the complete documentation index, see [llms.txt](https://docs.360dialog.com/partner/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/partner/messaging/sending-and-receiving-messages/text-messages.md).

# Sending Messages

{% hint style="info" %}
You can only send a text message up until 24 hours after receiving a message from the user. If you have not received a message from the user within this time, you will need to start a new conversation by [sending a Template message.](/partner/messaging/template-messages/sending-template-messages.md)
{% endhint %}

To send text messages, specify `text` in the `type` field. A text message can be a maximum of 4096 characters long. It's recommended to keep the message length under 1600 characters for optimal rendering on most devices.

## How to send a text message

To send a message, use this [endpoint](https://docs.360dialog.com/docs/messaging-api/api-reference/messages#post-messages)

## Formatting in Text Messages

WhatsApp allows some formatting in messages. To format all or part of a message, use these formatting symbols:

| Formatting         | Symbol                   | Example                          |
| ------------------ | ------------------------ | -------------------------------- |
| **Bold**           | Asterisk (\*)            | Your total is \*$10.50\*.        |
| *Italics*          | Underscore (\_)          | Welcome to \_WhatsApp\_!         |
| ~~Strike-through~~ | Tilde (\~)               | This is \~better\~ best!         |
| `Code`             | Three backticks (\`\`\`) | \`\`\`print 'Hello World';\`\`\` |

## How to send URLs in Text Messages <a href="#urls" id="urls"></a>

By default, the mobile WhatsApp application recognizes URLs and makes them clickable. To include a URL preview, include `"preview_url": true` and make sure the URL begins with `http://` or `https://`. A hostname is required; IP  addresses are not matched.

When sending a preview URL with Cloud API hosting, the `preview-url` should be inside the text object.&#x20;

**Example:**

```json
    "text":  {// the text object
        "preview_url": true,
        "body": You have to check out this amazing messaging service https://www.whatsapp.com/"
    }

```

The majority of the time when you send a URL, whether with a preview or not, the receiver of the message will see a URL that they can click on.

URL previews are only rendered after one of the following has happened:

1. The business has sent a message template to the user.
2. The user initiates a conversation with a "click to chat" link.
3. The user adds the business phone number to their address book and initiates a conversation.

If the end user did not initiate the conversation with you - you must use a [Template message ](broken://pages/-MKJcOJCZHT02NZHO3yd)instead.&#x20;

## Replies <a href="#replies" id="replies"></a>

You can send any message as a reply to a previous message in a conversation by including the previous message's ID in the [`context`](#send-a-text-message-1) object. The recipient will receive the new message along with a contextual bubble that displays the previous message's content.

![](/files/ASkvLb3d4fS2hsSh8sIO)

Recipients will not see a contextual bubble if:

* replying with a template message (`"type":"template"`)
* replying with an image, video, PTT, or audio, and the recipient is on KaiOS

Sample request:

```json
POST https://waba-v2.360dialog.io/messages
{
   "messaging_product": "whatsapp",
   "context": {
     "message_id": "MESSAGE_ID"
   },
   "to": "<phone number> or <wa_id>",
   "type": "text",
   "text": {
     "preview_url": False,
     "body": "your-text-message-content"
   }
 }
```

A successful response includes an object with an identifier prefixed with `wamid`. Use the ID listed after `wamid` to track your message status.

{% hint style="info" %}
**Note**: if the previous message is more than 30 days old or doesn't correspond to any message in the conversation, the message will be sent normally instead of as a reply.
{% endhint %}

Sample response:

```json
{
  "messaging_product": "whatsapp",
  "contacts": [{
    "input": "PHONE_NUMBER",
    "wa_id": "WHATSAPP_ID",
  }]
  "messages": [{
    "id": "wamid.ID",
  }]
}

```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.360dialog.com/partner/messaging/sending-and-receiving-messages/text-messages.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
