# Batches

Batches are sets of SMS messages. You can send a single message or many. Batches are queued and sent at the rate limit in FIFO (first-in-first-out) order.

## Send

The first step is to set a webhook URL at Webhook tab under Settings, to ensure receipt of all DLRs (delivery reports).&#x20;

Depending on the length of the body, one message might be split into multiple parts and charged accordingly.

<mark style="color:green;">`POST`</mark> `https://app.9bits.net:2096/ng/v1/sendsms`

#### Headers

| Name                                            | Type                        | Description |
| ----------------------------------------------- | --------------------------- | ----------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer \<YOUR\_TOKEN\_HERE> |             |
| Content-Type<mark style="color:red;">\*</mark>  | application/json            |             |

#### Request Body

| Key                                    | Value                               | Description |
| -------------------------------------- | ----------------------------------- | ----------- |
| from<mark style="color:red;">\*</mark> | myCode                              |             |
| body<mark style="color:red;">\*</mark> | Hello Buddy. Let's go!              |             |
| to<mark style="color:red;">\*</mark>   | \["2348020000000", 23480300000000"] |             |

<pre class="language-python" data-title="Request sample"><code class="lang-python"><strong>
</strong><strong>import requests
</strong>
url = "https://app.9bits.net:9020/ng/v1/sendsms"

payload = {
  "from": "Your_sender_ID",
  "to": [
    "Recipient_number"
  ],
  "content": "Your_message"
}

headers = {
  "Content-Type": "application/json",
  "Authorization": "Bearer &#x3C;YOUR_TOKEN_HERE>"
}

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

data = response.json()
print(data)
</code></pre>

{% code title="Response sample" %}

```python

{
    "status_code": 200,
    "message": "request is being processed",
    "reference_id": "fdab8f46df049e58b0af7c2d7",
    "recipients_processed": 2
}
```

{% endcode %}

REQUEST AND RESPONSE BODY SCHEMA: application/json

<mark style="color:green;">body</mark> <mark style="color:red;">(required)</mark>        The message content.

<mark style="color:green;">to</mark> <mark style="color:red;">(required)</mark>             List of Phone numbers and group IDs that will receive the batch.

<mark style="color:green;">from</mark> <mark style="color:red;">(required)</mark>        Sender number. Must be an alphanumeric ID that was registered on the web portal.

<mark style="color:green;">delivery\_report</mark>        Default: "none". Request delivery report callback. Note that delivery reports can be fetched  from the API regardless of this setting.

|      | Description                                                                                                                                                                        |
| ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| none | No delivery report callback will be sent                                                                                                                                           |
| yes  | A delivery report callback will be sent for each status change of a message. These delivery reports also include a timestamp of when the Delivery Report originated from the SMSC. |

<mark style="color:green;">send\_at</mark>                   If set in the future, the message will be delayed until `send_at` occurs. If set in the past, messages will be sent immediately.

<mark style="color:green;">reference\_id</mark>          A unique reference for each transaction.

<mark style="color:green;">created\_at</mark>            Timestamp for when batch was created.
