# Connect Twilio

Source: https://kirora.io/docs/guides/messaging/sms/connect-twilio

Create a Twilio API key, connect it in Kirora, paste the inbound URL into each number or Messaging Service, and send your first text.

Kirora sends through your own Twilio account, from the numbers, Messaging Services and short codes you already have. Twilio bills you at your rates; Kirora adds nothing per message.

## Before you start

- **A Twilio account with credit.** A trial account sends only Twilio's predefined messages, only to numbers verified in it, so upgrade before you test your own text.
- **A sender that's approved to send.** In the US, a local number needs **A2P 10DLC** registration and a toll-free number needs **toll-free verification** before carriers deliver your messages. Elsewhere, check each country's rules. See [Choose and register your senders](https://kirora.io/docs/guides/messaging/sms/senders-and-registration).
- **The owner, admin or developer role** in Kirora.

Kirora uses Twilio's default US region.

## Create an API key

1. In the Twilio Console, go to **Settings › Account settings › API keys & auth tokens**.
2. Choose **Create API key**, give it a name such as *Kirora*, and keep the key type **Standard**.
3. Copy the **SID** (it starts with `SK`) and the **Secret**. Twilio shows the secret only once.
4. Copy your **Account SID** (it starts with `AC`) from the Console's home page.

Use your live credentials, not Twilio's test credentials: test credentials can't send real messages or list your numbers.

## Connect it in Kirora

1. Go to **Settings › Messaging › SMS** and choose **Connect** on the Twilio card. You can also start from **Integrations › Twilio**.
2. Enter the **Account SID**, **API key SID** and **API key secret**.
3. Enter the **Auth Token** from the Console's home page too. It's optional but recommended: Twilio signs every callback with it, and Kirora then refuses any callback that isn't signed. You can add, replace or remove it later under **Settings** on **Integrations › Twilio**, without re-entering the API key.
4. Choose **Connect**. Kirora checks the key with Twilio, then lists your senders and shows your balance. If Twilio refuses the key, you'll see why.

## Paste the inbound URL into Twilio

Kirora shows an **Inbound URL** on the Twilio page, under **Paste this into Twilio**. It brings replies and STOP back to Kirora. Delivery reports need no setup: Kirora asks for them with every message.

**For a phone number:**

1. In the Console, go to **Phone Numbers › Manage › Active numbers** and open the number.
2. Under **Messaging Configuration**, set **A message comes in** to **Webhook**, paste the URL and keep **HTTP POST**.
3. Choose **Save configuration**.

**For a Messaging Service:**

1. Go to **Messaging › Services** and open the service.
2. Open **Integration**, choose **Send a webhook** under **Incoming Messages**, and paste the URL as the **Request URL**.
3. Choose **Save**.

With **Send a webhook** chosen, every number in the service uses the service's URL. If the service is set to **Defer to sender's webhook**, paste the URL into each number instead. Do this for every number and service you send from.

*Screenshot: The Inbound URL under Paste this into Twilio on Kirora's Twilio page*

## Check your senders

Kirora lists the account's SMS-capable **numbers**, **toll-free numbers**, **short codes** and **Messaging Services**. They appear on the **Senders** tab of **Settings › Messaging › SMS**.

- **A sender ID** (letters, such as *Juniper*) used on its own isn't something Twilio can list. Either add it to a Messaging Service and send from the service, or add it by hand: on the **Senders** tab choose **Add**, pick the **Connection** if you have more than one, choose **Sender ID** as the **Kind** and enter it exactly as registered.
- **Added a sender in Twilio?** Kirora syncs every day. To see it straight away, choose **Sync senders** from the connection's menu on **Integrations › Twilio**.

## Send a test

1. As an owner or admin, open a sender's menu on the **Senders** tab and choose **Send a test**.
2. Pick a contact with a phone number and choose **Send test**.
3. If the sender takes replies, reply STOP from that phone, then START. Kirora records the opt-out, then lifts it, which proves replies reach Kirora.

Tests aren't kept as messages, so look for delivery reports on your first campaign or transactional text.

## Opt-outs on Twilio

On numbers and toll-free numbers, Twilio acts on STOP itself: it blocks the phone from that sender and sends its own confirmation, which it bills you for. A short code needs its keyword replies set up in Twilio. Either way, Kirora records the opt-out once the reply reaches it, and stops SMS to that phone from every sender in your workspace.

If you've turned on Twilio's **Advanced Opt-Out** and added your own keywords, such as another language's word for STOP, Kirora follows Twilio's reading of each reply.

Because Twilio enforces STOP, a Twilio sender shows **STOP works** from the start, and its marketing texts can end with *Reply STOP to opt out* instead of a link.

## When a send fails

Kirora shows Twilio's reason with every failed message. The ones you're most likely to meet:

| Twilio code | What it means | What to do |
| --- | --- | --- |
| `21608`, `572002`, `572003`, `572006` | The account is a trial, or has no approved compliance profile | Upgrade the account, or finish its regulatory setup |
| `21610` | The contact replied STOP to this sender | Nothing: Kirora records the opt-out |
| `21211`, `21614` | The number is invalid, or isn't a mobile | Correct the contact's number |
| `30003` | The phone was off or out of reach | Nothing: it may arrive next time |
| `30005`, `30006` | The number no longer exists, or can't receive SMS | Kirora stops texting that number |
| `20003` | Twilio refused the API key | **Replace credentials** with a valid key |
| `20005` | The account isn't active, most often because its balance ran out | Top up in Twilio |

For US messages refused by carriers, check the sender's A2P 10DLC or toll-free verification status in the Twilio Console. See also [Troubleshoot SMS](https://kirora.io/docs/guides/messaging/sms/troubleshoot-sms).

## Next steps

- [Choose and register your senders](https://kirora.io/docs/guides/messaging/sms/senders-and-registration)
- [Write and send an SMS](https://kirora.io/docs/guides/messaging/sms/send-sms)
- [Send each country from its own sender](https://kirora.io/docs/guides/messaging/sms/sender-groups)