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

# Send batch

POST https://connect.chatbridge.mx/v1/sms/batches
Content-Type: application/json

Sends SMS messages to up to 250 recipients in a single request, with the same text for the whole batch or a text per number. The send is **asynchronous**: the API validates the request, responds `202 Accepted` immediately with a `batch_id` and one `message_id` per number (in the order of the request), and processes the numbers in the background.

`text`, `has_accents` and `complement` at the root are the batch defaults; each item of `messages` can override any of them. An item's `complement` replaces the batch one entirely (`link` and `ttl_events` are not merged), and every number with a `complement` gets its own short link.

Numbers are validated against the mask in the background, so an invalid number does not reject the batch: it is reported with status `INVALID_FORMAT` (does not match the mask format), `INVALID_SOURCE` (not found in the numbering plan or not a mobile number) or `OUTPUT_NOT_FOUND` (no output for its operator).

`webhook_mode` selects the notifications: `INDIVIDUAL` (default) sends the regular status webhook per number, with an extra `batch_id`; `BATCH` sends a single `batchStatus` webhook once every number has a send result.

Reference: https://docs.chatbridge.mx/sms/messages/send-sms-batch

## Authentication

- `x-api-key` header (required) — Account authentication key. The App-Key must have the SMS channel enabled; it cannot be used against the endpoints of other channels.
- `Authorization` header (bearer token, required) — OAuth 2.0 access token issued by `POST /api/oauth/token` (client-credentials). Takes precedence over `x-api-key` when both are sent. See the Authentication section.

## Request

### Body (application/json)

This endpoint expects a SendBatchRequest.

- `mask` (string, required) — Sender mask identifier obtained through GET /v1/sms/masks. Applies to the whole batch.
- `messages` (list of BatchMessage, required)
- `text` (string, optional) — Default text of the batch. Required when any item of `messages` does not carry its own `text`.
- `has_accents` (boolean, optional, default: false) — Default encoding of the batch (see `SendMessageRequest`).
- `complement` (Complement, optional) — Appends a trackable short link to the end of the message. The link is shortened and added to the text automatically before sending.
- `webhook_mode` (enum, optional, default: INDIVIDUAL) — `INDIVIDUAL`: the regular `messageStatus` webhook per number, with `batch_id`. `BATCH`: a single `batchStatus` webhook for the whole batch.
  - Allowed values: `INDIVIDUAL`, `BATCH`

## Response

### 202

Batch accepted and queued. Store `batch_id` and the `message_id` of each number: they are the keys to correlate the webhooks.

- `statusCode` (integer, optional)
- `message` ("ACCEPTED", optional)
- `batch_id` (string, optional) — Batch identifier; it comes in the webhooks of the batch.
- `webhook_mode` (enum, optional)
  - Allowed values: `INDIVIDUAL`, `BATCH`
- `total` (integer, optional) — Numbers received in the batch.
- `messages` (list of SendBatchResponseMessagesItems, optional) — One entry per number, in the order of the request.

## Errors

### 400 Bad Request Error

The request contains invalid data or the mask cannot be used. Body validation errors respond with `errorCode` 400 and name the failing field, including the position of the number (for example `messages[3].text`). Per-number rules (format, numbering plan, operator output) are not validated here: they are reported per number in the background.

- `message` (string, optional)
- `error` (string, optional)
- `statusCode` (integer, optional)
- `errorCode` (integer, optional)

### 401 Unauthorized Error

Authentication is missing or invalid.

- `message` (string, optional)
- `error` (string, optional)
- `statusCode` (integer, optional)
- `errorCode` (integer, optional)

### 403 Forbidden Error

The API Key does not have access to the SMS channel.

- `message` (string, optional)
- `error` (string, optional)
- `statusCode` (integer, optional)
- `errorCode` (integer, optional)

### 413 Content Too Large Error

The request body exceeds the maximum size allowed.

- `message` (string, optional)
- `error` (string, optional)
- `statusCode` (integer, optional)
- `errorCode` (integer, optional)

### 429 Too Many Requests Error

The requests-per-minute limit was exceeded.

- `message` (string, optional)
- `error` (string, optional)
- `statusCode` (integer, optional)
- `errorCode` (integer, optional)

### 500 Internal Server Error

Unhandled internal error, or the batch could not be queued. No message was sent; the request can be retried.

- `message` (string, optional)
- `error` (string, optional)
- `statusCode` (integer, optional)
- `errorCode` (integer, optional)

## Types

### BatchMessage

- `to` (string, required) — Destination number, same rules as `to` in the single send. National mask: 10 digits, also accepted with the Mexico country code `52`/`+52` or `521`/`+521`. International mask: E.164 with or without `+`, always with the country code.
- `text` (string, optional) — Text of this number; defaults to the batch `text`.
- `has_accents` (boolean, optional) — Encoding of this number; defaults to the batch `has_accents`.
- `complement` (Complement, optional) — Short link of this number. Replaces the batch `complement` entirely; defaults to it when omitted.

### Complement

Appends a trackable short link to the end of the message. The link is shortened and added to the text automatically before sending.

- `link` (string, required) — Destination URL to shorten.
- `ttl_events` (integer, optional, default: 1440) — Validity of the short link for click tracking, in minutes. Default: 1440 (24 hours).

### SendBatchResponseMessagesItems

- `to` (string, optional)
- `message_id` (string, optional) — Identifier of this number's send, used in its webhooks.

## Examples

### Batch defaults with per-number overrides and a single webhook

**Request**

```json
{
  "mask": "6a4bffd5e77672e33fd5304f",
  "messages": [
    {
      "to": "5555555555"
    },
    {
      "to": "5544444444",
      "text": "Tu pedido llegó a la sucursal.",
      "has_accents": true
    },
    {
      "to": "5533333333",
      "complement": {
        "link": "https://mitienda.mx/pedidos/5533333333"
      }
    }
  ],
  "text": "Tu pedido va en camino.",
  "complement": {
    "link": "https://mitienda.mx/pedidos",
    "ttl_events": 1440
  },
  "webhook_mode": "BATCH"
}
```

**Response**

```json
{
  "statusCode": 202,
  "message": "ACCEPTED",
  "batch_id": "66fa1c0e2a1b2c3d4e5f6071",
  "webhook_mode": "BATCH",
  "total": 3,
  "messages": [
    {
      "to": "5555555555",
      "message_id": "c2b6e1a4-1f3d-4b7a-8c1e-2a6f9d3b7e10"
    },
    {
      "to": "5544444444",
      "message_id": "9f1a2b3c-4d5e-4f60-8a1b-2c3d4e5f6071"
    },
    {
      "to": "5533333333",
      "message_id": "4d7e8f90-1a2b-4c3d-9e4f-5a6b7c8d9e0f"
    }
  ]
}
```

**SDK Code**

```python Batch defaults with per-number overrides and a single webhook
import requests

url = "https://connect.chatbridge.mx/v1/sms/batches"

payload = {
    "mask": "6a4bffd5e77672e33fd5304f",
    "messages": [
        { "to": "5555555555" },
        {
            "to": "5544444444",
            "text": "Tu pedido llegó a la sucursal.",
            "has_accents": True
        },
        {
            "to": "5533333333",
            "complement": { "link": "https://mitienda.mx/pedidos/5533333333" }
        }
    ],
    "text": "Tu pedido va en camino.",
    "complement": {
        "link": "https://mitienda.mx/pedidos",
        "ttl_events": 1440
    },
    "webhook_mode": "BATCH"
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Batch defaults with per-number overrides and a single webhook
const url = 'https://connect.chatbridge.mx/v1/sms/batches';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"mask":"6a4bffd5e77672e33fd5304f","messages":[{"to":"5555555555"},{"to":"5544444444","text":"Tu pedido llegó a la sucursal.","has_accents":true},{"to":"5533333333","complement":{"link":"https://mitienda.mx/pedidos/5533333333"}}],"text":"Tu pedido va en camino.","complement":{"link":"https://mitienda.mx/pedidos","ttl_events":1440},"webhook_mode":"BATCH"}'
};

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

```go Batch defaults with per-number overrides and a single webhook
package main

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

func main() {

	url := "https://connect.chatbridge.mx/v1/sms/batches"

	payload := strings.NewReader("{\n  \"mask\": \"6a4bffd5e77672e33fd5304f\",\n  \"messages\": [\n    {\n      \"to\": \"5555555555\"\n    },\n    {\n      \"to\": \"5544444444\",\n      \"text\": \"Tu pedido llegó a la sucursal.\",\n      \"has_accents\": true\n    },\n    {\n      \"to\": \"5533333333\",\n      \"complement\": {\n        \"link\": \"https://mitienda.mx/pedidos/5533333333\"\n      }\n    }\n  ],\n  \"text\": \"Tu pedido va en camino.\",\n  \"complement\": {\n    \"link\": \"https://mitienda.mx/pedidos\",\n    \"ttl_events\": 1440\n  },\n  \"webhook_mode\": \"BATCH\"\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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 Batch defaults with per-number overrides and a single webhook
require 'uri'
require 'net/http'

url = URI("https://connect.chatbridge.mx/v1/sms/batches")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"mask\": \"6a4bffd5e77672e33fd5304f\",\n  \"messages\": [\n    {\n      \"to\": \"5555555555\"\n    },\n    {\n      \"to\": \"5544444444\",\n      \"text\": \"Tu pedido llegó a la sucursal.\",\n      \"has_accents\": true\n    },\n    {\n      \"to\": \"5533333333\",\n      \"complement\": {\n        \"link\": \"https://mitienda.mx/pedidos/5533333333\"\n      }\n    }\n  ],\n  \"text\": \"Tu pedido va en camino.\",\n  \"complement\": {\n    \"link\": \"https://mitienda.mx/pedidos\",\n    \"ttl_events\": 1440\n  },\n  \"webhook_mode\": \"BATCH\"\n}"

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

```java Batch defaults with per-number overrides and a single webhook
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://connect.chatbridge.mx/v1/sms/batches")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"mask\": \"6a4bffd5e77672e33fd5304f\",\n  \"messages\": [\n    {\n      \"to\": \"5555555555\"\n    },\n    {\n      \"to\": \"5544444444\",\n      \"text\": \"Tu pedido llegó a la sucursal.\",\n      \"has_accents\": true\n    },\n    {\n      \"to\": \"5533333333\",\n      \"complement\": {\n        \"link\": \"https://mitienda.mx/pedidos/5533333333\"\n      }\n    }\n  ],\n  \"text\": \"Tu pedido va en camino.\",\n  \"complement\": {\n    \"link\": \"https://mitienda.mx/pedidos\",\n    \"ttl_events\": 1440\n  },\n  \"webhook_mode\": \"BATCH\"\n}")
  .asString();
```

```php Batch defaults with per-number overrides and a single webhook
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://connect.chatbridge.mx/v1/sms/batches', [
  'body' => '{
  "mask": "6a4bffd5e77672e33fd5304f",
  "messages": [
    {
      "to": "5555555555"
    },
    {
      "to": "5544444444",
      "text": "Tu pedido llegó a la sucursal.",
      "has_accents": true
    },
    {
      "to": "5533333333",
      "complement": {
        "link": "https://mitienda.mx/pedidos/5533333333"
      }
    }
  ],
  "text": "Tu pedido va en camino.",
  "complement": {
    "link": "https://mitienda.mx/pedidos",
    "ttl_events": 1440
  },
  "webhook_mode": "BATCH"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Batch defaults with per-number overrides and a single webhook
using RestSharp;

var client = new RestClient("https://connect.chatbridge.mx/v1/sms/batches");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"mask\": \"6a4bffd5e77672e33fd5304f\",\n  \"messages\": [\n    {\n      \"to\": \"5555555555\"\n    },\n    {\n      \"to\": \"5544444444\",\n      \"text\": \"Tu pedido llegó a la sucursal.\",\n      \"has_accents\": true\n    },\n    {\n      \"to\": \"5533333333\",\n      \"complement\": {\n        \"link\": \"https://mitienda.mx/pedidos/5533333333\"\n      }\n    }\n  ],\n  \"text\": \"Tu pedido va en camino.\",\n  \"complement\": {\n    \"link\": \"https://mitienda.mx/pedidos\",\n    \"ttl_events\": 1440\n  },\n  \"webhook_mode\": \"BATCH\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Batch defaults with per-number overrides and a single webhook
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "mask": "6a4bffd5e77672e33fd5304f",
  "messages": [
    ["to": "5555555555"],
    [
      "to": "5544444444",
      "text": "Tu pedido llegó a la sucursal.",
      "has_accents": true
    ],
    [
      "to": "5533333333",
      "complement": ["link": "https://mitienda.mx/pedidos/5533333333"]
    ]
  ],
  "text": "Tu pedido va en camino.",
  "complement": [
    "link": "https://mitienda.mx/pedidos",
    "ttl_events": 1440
  ],
  "webhook_mode": "BATCH"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://connect.chatbridge.mx/v1/sms/batches")! 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()
```

### Same text for every number

**Request**

```json
{
  "mask": "6a4bffd5e77672e33fd5304f",
  "messages": [
    {
      "to": "5555555555"
    },
    {
      "to": "5544444444"
    }
  ],
  "text": "Tu pedido va en camino."
}
```

**Response**

```json
{
  "statusCode": 202,
  "message": "ACCEPTED",
  "batch_id": "66fa1c0e2a1b2c3d4e5f6071",
  "webhook_mode": "BATCH",
  "total": 3,
  "messages": [
    {
      "to": "5555555555",
      "message_id": "c2b6e1a4-1f3d-4b7a-8c1e-2a6f9d3b7e10"
    },
    {
      "to": "5544444444",
      "message_id": "9f1a2b3c-4d5e-4f60-8a1b-2c3d4e5f6071"
    },
    {
      "to": "5533333333",
      "message_id": "4d7e8f90-1a2b-4c3d-9e4f-5a6b7c8d9e0f"
    }
  ]
}
```

**SDK Code**

```python Same text for every number
import requests

url = "https://connect.chatbridge.mx/v1/sms/batches"

payload = {
    "mask": "6a4bffd5e77672e33fd5304f",
    "messages": [{ "to": "5555555555" }, { "to": "5544444444" }],
    "text": "Tu pedido va en camino."
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Same text for every number
const url = 'https://connect.chatbridge.mx/v1/sms/batches';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"mask":"6a4bffd5e77672e33fd5304f","messages":[{"to":"5555555555"},{"to":"5544444444"}],"text":"Tu pedido va en camino."}'
};

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

```go Same text for every number
package main

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

func main() {

	url := "https://connect.chatbridge.mx/v1/sms/batches"

	payload := strings.NewReader("{\n  \"mask\": \"6a4bffd5e77672e33fd5304f\",\n  \"messages\": [\n    {\n      \"to\": \"5555555555\"\n    },\n    {\n      \"to\": \"5544444444\"\n    }\n  ],\n  \"text\": \"Tu pedido va en camino.\"\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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 Same text for every number
require 'uri'
require 'net/http'

url = URI("https://connect.chatbridge.mx/v1/sms/batches")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"mask\": \"6a4bffd5e77672e33fd5304f\",\n  \"messages\": [\n    {\n      \"to\": \"5555555555\"\n    },\n    {\n      \"to\": \"5544444444\"\n    }\n  ],\n  \"text\": \"Tu pedido va en camino.\"\n}"

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

```java Same text for every number
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://connect.chatbridge.mx/v1/sms/batches")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"mask\": \"6a4bffd5e77672e33fd5304f\",\n  \"messages\": [\n    {\n      \"to\": \"5555555555\"\n    },\n    {\n      \"to\": \"5544444444\"\n    }\n  ],\n  \"text\": \"Tu pedido va en camino.\"\n}")
  .asString();
```

```php Same text for every number
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://connect.chatbridge.mx/v1/sms/batches', [
  'body' => '{
  "mask": "6a4bffd5e77672e33fd5304f",
  "messages": [
    {
      "to": "5555555555"
    },
    {
      "to": "5544444444"
    }
  ],
  "text": "Tu pedido va en camino."
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Same text for every number
using RestSharp;

var client = new RestClient("https://connect.chatbridge.mx/v1/sms/batches");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"mask\": \"6a4bffd5e77672e33fd5304f\",\n  \"messages\": [\n    {\n      \"to\": \"5555555555\"\n    },\n    {\n      \"to\": \"5544444444\"\n    }\n  ],\n  \"text\": \"Tu pedido va en camino.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Same text for every number
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "mask": "6a4bffd5e77672e33fd5304f",
  "messages": [["to": "5555555555"], ["to": "5544444444"]],
  "text": "Tu pedido va en camino."
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://connect.chatbridge.mx/v1/sms/batches")! 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()
```