> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.muchau.com.br/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.muchau.com.br/_mcp/server.

# Enviar uma mensagem

POST https://dev.muchau.com.br/api/messages/send
Content-Type: application/json

Envia uma mensagem do WhatsApp de um dos seus números conectados. Suporta texto, templates, imagens, documentos, áudio, vídeo, localização e mensagens interativas. Adicione o header `Idempotency-Key` para evitar envios duplicados.

Reference: https://docs.muchau.com.br/api/reference/messages/enviar-uma-mensagem

## Authentication

- `Authorization` header (bearer token, required) — API Key in the format `mk_live_<43-chars>`. Obtain from the Dashboard or `POST /auth/api-keys`.

## Request

### Body (application/json)

This endpoint expects an object.

- `number_id` (string, required) — ID of the WhatsApp number to send from
- `type` (enum, required) — Type of WhatsApp message to send
  - Allowed values: `text`, `template`, `image`, `document`, `audio`, `video`, `location`, `interactive`
- `to` (string, optional) — Recipient phone number in E.164 format (e.g., 5511999998888)
- `recipient` (string, optional) — Recipient BSUID (e.g., US.13491208655302741918)
- `text` (ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaText, optional) — Text message payload — required when type is 'text'
- `template` (ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaTemplate, optional) — Template message payload — required when type is 'template'
- `image` (ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaImage, optional) — Image message payload — required when type is 'image'. Provide either id or link
- `document` (ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaDocument, optional) — Document message payload — required when type is 'document'. Provide either id or link
- `audio` (ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaAudio, optional) — Audio message payload — required when type is 'audio'. Provide either id or link
- `video` (ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaVideo, optional) — Video message payload — required when type is 'video'. Provide either id or link
- `location` (ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaLocation, optional) — Location message payload — required when type is 'location'
- `interactive` (map from string to any, optional) — Interactive message payload (list, button, product, etc.) — required when type is 'interactive'

## Response

### 200

Default Response

- `id` (string, required) — Muchaw DEV internal message ID
- `wa_message_id` (string, required) — WhatsApp message ID returned by Meta Cloud API
- `status` (string, required) — Current delivery status of the message

## Errors

### 400 Bad Request Error

Default Response

- `error` (ApiMessagesSendPostResponsesContentApplicationJsonSchemaError, required)

### 401 Unauthorized Error

Default Response

- `error` (ApiMessagesSendPostResponsesContentApplicationJsonSchemaError, required)

### 404 Not Found Error

Default Response

- `error` (ApiMessagesSendPostResponsesContentApplicationJsonSchemaError, required)

## Types

### ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaText

Text message payload — required when type is 'text'

- `body` (string, required) — Text content of the message

### ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaTemplate

Template message payload — required when type is 'template'

- `name` (string, required) — Name of the pre-approved WhatsApp template
- `language` (ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaTemplateLanguage, required) — Language configuration for the template
- `components` (list of map from string to any, optional) — Template components (header, body, button parameters)

### ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaImage

Image message payload — required when type is 'image'. Provide either id or link

- `id` (string, optional) — Meta media ID of a previously uploaded image
- `link` (string, optional) — Public URL of the image
- `caption` (string, optional) — Caption displayed below the image

### ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaDocument

Document message payload — required when type is 'document'. Provide either id or link

- `id` (string, optional) — Meta media ID of a previously uploaded document
- `link` (string, optional) — Public URL of the document
- `filename` (string, optional) — Filename displayed to the recipient
- `caption` (string, optional) — Caption displayed with the document

### ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaAudio

Audio message payload — required when type is 'audio'. Provide either id or link

- `id` (string, optional) — Meta media ID of a previously uploaded audio file
- `link` (string, optional) — Public URL of the audio file

### ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaVideo

Video message payload — required when type is 'video'. Provide either id or link

- `id` (string, optional) — Meta media ID of a previously uploaded video
- `link` (string, optional) — Public URL of the video
- `caption` (string, optional) — Caption displayed with the video

### ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaLocation

Location message payload — required when type is 'location'

- `latitude` (double, required) — Latitude of the location
- `longitude` (double, required) — Longitude of the location
- `name` (string, optional) — Name of the location (e.g., business name)
- `address` (string, optional) — Full address of the location

### ApiMessagesSendPostResponsesContentApplicationJsonSchemaError

- `code` (string, required) — Machine-readable error code (e.g., UNAUTHORIZED, NOT_FOUND, VALIDATION_ERROR)
- `message` (string, required) — Human-readable error description
- `status` (integer, required) — HTTP status code
- `meta` (ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorMeta, optional)
- `error_shield` (ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShield, optional)

### ApiMessagesSendPostRequestBodyContentApplicationJsonSchemaTemplateLanguage

Language configuration for the template

- `code` (string, required) — BCP 47 language code (e.g., en_US, pt_BR)

### ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorMeta

- `meta_code` (integer, required)
- `meta_message` (string, required)
- `meta_subcode` (integer, required, nullable)
- `type` (string, required, nullable)
- `fbtrace_id` (string, required, nullable)
- `error_data` (any, optional)

### ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShield

- ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShield0
- ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShield1

### ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShield0

- `matched` (boolean, required)
- `entry_id` (string, required)
- `category` (enum, required)
  - Allowed values: `template`, `number`, `messaging`, `flow`, `permission`, `rate_limit`, `other`
- `severity` (enum, required)
  - Allowed values: `informational`, `recoverable`, `blocking`, `critical`
- `actor` (enum, required)
  - Allowed values: `developer`, `end_client`, `muchau`
- `human_message` (ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0HumanMessage, required)
- `action` (ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0Action, required)
- `action_url` (string, required, nullable)
- `docs_url` (string, required)
- `copy_text` (ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0CopyText, required)
- `version` (integer, required)
- `last_updated` (string, required)

### ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShield1

- `matched` (boolean, required)
- `note` (ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf1Note, required)

### ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0HumanMessage

- `pt` (string, required)
- `en` (string, required)

### ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0Action

- `pt` (string, required)
- `en` (string, required)

### ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0CopyText

- `pt` (string, required, nullable)
- `en` (string, required, nullable)

### ApiMessagesSendPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf1Note

- `pt` (string, required)
- `en` (string, required)

## Examples

**Request**

```json
{
  "number_id": "string",
  "type": "text"
}
```

**Response**

```json
{
  "id": "string",
  "wa_message_id": "string",
  "status": "string"
}
```

**SDK Code**

```python
import requests

url = "https://dev.muchau.com.br/api/messages/send"

payload = {
    "number_id": "string",
    "type": "text"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://dev.muchau.com.br/api/messages/send';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"number_id":"string","type":"text"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://dev.muchau.com.br/api/messages/send"

	payload := strings.NewReader("{\n  \"number_id\": \"string\",\n  \"type\": \"text\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://dev.muchau.com.br/api/messages/send")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"number_id\": \"string\",\n  \"type\": \"text\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://dev.muchau.com.br/api/messages/send")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"number_id\": \"string\",\n  \"type\": \"text\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://dev.muchau.com.br/api/messages/send', [
  'body' => '{
  "number_id": "string",
  "type": "text"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://dev.muchau.com.br/api/messages/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"number_id\": \"string\",\n  \"type\": \"text\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "number_id": "string",
  "type": "text"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://dev.muchau.com.br/api/messages/send")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```