# Send one message to one or more recipients (/api/sendMessage)

One call, one body, one channel, many recipients — and one `message`
object back per recipient. A message is one row of delivery: one
person, one status. Sending to three numbers returns three objects.

Every recipient, its sender, and the credit for all of them are checked
before anything is sent. A missing contact or group, a contact without
an address on the channel, no sender for one of the recipients, or too
little credit refuses the whole call and nobody receives anything.

One recipient is sent while you wait, and its `status` is the outcome.
More than one recipient (a `grp_` group counts as its members) is
accepted, answered at once as `queued`, and sent in the background,
paced per number to keep it healthy. Follow each message with webhooks
or `GET /messages/{id}`. For bulk sends use several `to` or
`POST /messages/batch`: both are paced for you. Looping over single
sends is not.

Recipients must be in E.164 form, with the `+`. A local number is
refused rather than guessed: guessing the wrong country sends a
stranger a message and bills you for it.

Endpoint: POST /api/v1/messages
Full URL: https://app.sendkuy.com/api/v1/messages
- header parameter Idempotency-Key (optional): string — Any unique string, one per logical request. Retrying with the same key returns the first answer instead of doing the work twice, and answers with `Idempotent…
Request body (JSON, required); required fields: channel, to, body
Example "One WhatsApp message": {"channel":"whatsapp","to":["+6281234567890"],"body":"Your order is on its way."}
Example "Email needs a subject": {"channel":"email","to":["andi@example.com"],"subject":"Your order","body":"<p>Your order is on its way.</p>"}
Example "A newsletter with your own one-click unsubscribe": {"channel":"email","to":["andi@example.com"],"subject":"What is new this month","body":"<p>Three things we shipped.</p>","from_name":"Example Store","reply_to":"support@example.com","headers":{"List-Unsubscribe":"<https://example.com/news/unsubscribe/42?signature=abc>","List-Unsubscribe-Post":"List-Unsubscribe=One-Click"},"transactional":true}
Success status: 201

cURL:

```bash
curl -X POST https://app.sendkuy.com/api/v1/messages \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "channel": "whatsapp",
  "to": [
    "+6281234567890"
  ],
  "body": "Your order is on its way."
}'
```

Node.js:

```ts
import { SendKuy } from 'sendkuy';

const sendkuy = new SendKuy('sk_live_YOUR_API_KEY');

const result = await sendkuy.messages.send({
  channel: 'whatsapp',
  to: [
    '+6281234567890',
  ],
  body: 'Your order is on its way.',
});
```

PHP:

```php
<?php

use SendKuy\SendKuy;

$sendkuy = new SendKuy('sk_live_YOUR_API_KEY');

$result = $sendkuy->messages()->send([
    'channel' => 'whatsapp',
    'to' => [
        '+6281234567890',
    ],
    'body' => 'Your order is on its way.',
]);
```

Python:

```python
import requests

response = requests.request(
    "POST",
    "https://app.sendkuy.com/api/v1/messages",
    headers={"Authorization": "Bearer sk_live_YOUR_API_KEY"},
    json={
        "channel": "whatsapp",
        "to": [
            "+6281234567890"
        ],
        "body": "Your order is on its way."
    },
)

data = response.json()["data"]
```