# SMS API

In Bonga, an SMS sender is an approved identity on a managed route or a SIM
subscription on a paired Android gateway. Set up managed sender IDs or pair
the gateway in your workspace before choosing a sender.

## Endpoints at a glance

| What do you want to do? | Endpoint | Key scope |
| --- | --- | --- |
| Find a managed sender or a specific SIM | [`GET /api/v2/senders?channel=sms`](/docs?view=reference#tag/sender-discovery/GET/api/v2/senders) | `messages:read` |
| Identify the sender's device or connection | [`GET /api/v2/connections?channel=sms`](/docs?view=reference#tag/sender-discovery/GET/api/v2/connections) | `messages:read` |
| Submit text to one recipient in the preview | [`POST /api/v2/messages`](/docs?view=reference#tag/messages/POST/api/v2/messages) | `messages:send` |
| Check the status of an accepted message | [`GET /api/v2/messages/{id}`](/docs?view=reference#tag/messages/GET/api/v2/messages/%7Bid%7D) | `messages:read` |

## List senders

Create a scoped API key with `messages:read`. Store it on your server.

```bash
curl "$BONGA_API_BASE_URL/api/v2/senders?channel=sms" \
  -H "Authorization: Bearer $BONGA_API_KEY"
```

The response contains `data.senders` and `data.connections`. The sender’s
`connection_id` identifies its connection, and the optional `address` is for
display. A managed sender may display a registered brand name or approved
number. A SIM sender can show its slot even when the phone number is unknown.

To see the senders for one gateway, add `connection_id` using the ID returned
by discovery. Choose the sender for the intended SIM slot and use its
`snd_…` ID as `from`. A device ID, phone number, brand name, or SIM slot
does not replace that ID in a message request.

## Submit and track in the preview

See the [v2 reference](/docs) for the SMS text example and status response.
Use a key with `messages:send` for submission, send to one E.164 recipient,
and retain your `Idempotency-Key` for replays. A `202` records preview
acceptance; it does not submit to a carrier or Android device.

Store the message ID returned in `data.id` alongside your order or job ID.
Use the `Location` response header to look up the message. The idempotency
key is for replaying the request; it is not the message ID. The current
preview does not return SMS segment counts, quotes, or charges.

Only senders with `ready: true` can accept preview messages. A configured
sender with `readiness_reason: "not_qualified"` is not available for submission.
An empty list means no sender matched your filters.

## Common responses

| Response | What to check |
| --- | --- |
| `401` | Use an active workspace API key in the Bearer header. |
| `403 PERMISSION_DENIED` | Check the scope required by the endpoint. |
| `409 SENDER_NOT_READY` | Re-run discovery and choose an eligible sender. |
| `409 IDEMPOTENCY_CONFLICT` | A retry must reuse both the key and payload. The preview also rejects identical normalized payloads under a different key. |
| `422 CHANNEL_UNQUALIFIED` | The selected channel or route is unavailable in this environment. |

Public v2 does not yet expose bulk sends (including personalized bulk),
scheduling, cancellation, SMS balances, sender registration, or delivery
webhooks. Use the workspace dashboard for available sending and billing
features.
