Send and receive SMS with Twilio
Replifier sends SMS through your own Twilio account: your numbers, your rates and your reputation. This guide explains which credentials it needs, how senders are chosen, which URL to set in Twilio to receive replies and opt-outs, what limits the test send has and what the sms_* errors mean.
Which credentials it needs
Section titled “Which credentials it needs”Replifier stores four credentials from your Twilio account, encrypted. Each one has a single purpose:
| Credential | Shape | What it is used for |
|---|---|---|
| Account SID | Starts with AC |
Identifies your account in every call to Twilio. |
| API Key SID | Starts with SK |
The user for calls: sending messages, listing your numbers and verifying the account. |
| API Key Secret | Shown only once when you create the API Key | The password for those same calls. |
| Auth Token | The one from your Twilio account | Only to validate the signature of inbound webhooks. |
Replifier never uses the Auth Token to call the Twilio API: if you ever rotate it, only webhook validation is affected. Create the API Key in the Twilio console, under Account, API keys & tokens, and copy the secret right then: Twilio does not show it again.
Connect the account
Section titled “Connect the account”- Create the connection with the four credentials, in the app or through the API:
POST /v1/brands/{brand}/channel-connectionswithprovider: "twilio"and a key with thecredentials.managepermission. - Verify it (in the app, or with
POST /v1/channel-connections/{id}:verify). Replifier reads your Twilio account with the API Key and reports the result:- Active: the connection is ready and your numbers are synced.
- Suspended: this is a warning; Twilio will not let you send until you reactivate the account in its console.
- Invalid credentials: Twilio returned 401 or 403. Check the Account SID, the API Key and its secret.
- No answer: Twilio did not respond; try again in a few minutes.
Sender types
Section titled “Sender types”When it verifies, Replifier lists up to 100 numbers from your Twilio account and stores them as senders. The type is inferred from the number:
| Type | How it is recognized |
|---|---|
Short code (short_code) |
Up to 6 digits. |
Toll-free (toll_free) |
Starts with +1800 or +1888. |
Long number (long_code) |
Any other number. |
How senders behave:
- Default. As long as the connection has one, it always keeps an active default sender that can send SMS.
- By country. If you have numbers in several countries, Replifier picks the one from the same country as the recipient (inferred from the calling code). If there is none, it uses the default or the campaign sender. It never blocks a send.
- Numbers that left Twilio. They are disabled, not deleted, because your campaigns and flows may still refer to them.
Inbound message webhook
Section titled “Inbound message webhook”To receive replies, opt-outs and delivery statuses, set this URL in Twilio with the HTTP POST method:
https://api.replifier.com/v1/inbound/twilio/<CONNECTION_ID>Paste it in A message comes in on the number (or on the messaging service), and as the Status callback URL if you use that notification. The connection ID is the id field the API returns when you create it.
How the signature is validated
Section titled “How the signature is validated”Twilio signs every request with the X-Twilio-Signature header. Replifier computes the same signature and compares it in constant time:
- It takes the full URL Twilio called, with scheme, domain, path and parameters.
- It sorts the form parameters by name and appends them as
name+value, with no separators. - It computes the HMAC-SHA1 of that string with your Auth Token and encodes it in base64.
If it does not match, Replifier answers 400 with sms_webhook_invalid and processes nothing. The most common cause is that the URL set in Twilio is not exactly the one Twilio signed (for example, a different domain or an extra parameter), or that the stored Auth Token is a different one.
What it does with each message
Section titled “What it does with each message”- Replies. They arrive in the Inbox and count as a reply to the last campaign that number received in the previous 72 hours.
- Opt-outs. Words such as
STOP,BAJA,ALTOorCANCELARadd the number to the brand’s SMS suppressions. - Opt-ins.
START,ALTAorSIremove that suppression and confirm a pending keyword sign-up. - Statuses. Twilio notifications move the message forward in this order: queued, sent, delivered, read or failed. A late or repeated notification does not move the status back or duplicate the count.
Length and segments
Section titled “Length and segments”A long SMS is split into segments and each one is billed. The count depends on the encoding:
- GSM-7: 160 characters in the first segment and 153 in each following one. The characters
€ [ ] \ ^ { } | ~count double. - UCS-2: 70 characters in the first and 67 in the rest. A single character outside the GSM-7 alphabet, such as
á,í,ó,úor an emoji, makes the whole message use UCS-2.
Test send
Section titled “Test send”Before launching a campaign, send a test to your own phone: POST /v1/channel-connections/{id}/test-send with {"to": ["+15551234567"]} and the credentials.manage permission.
- It accepts up to 5 numbers per request, in E.164 format.
- Each connection allows up to 10 test recipients per hour. Every attempt counts, even if it fails.
- It goes out from the default sender. Twilio bills it to your account, but it does not use your campaign send quota.
- Past the limit, the response is 429 with the
Retry-Afterheader in seconds.
sms_* errors
Section titled “sms_* errors”Each error has its own page in the error catalog:
| Code | When it happens | What to do |
|---|---|---|
sms_webhook_invalid |
The Twilio signature does not match (400). | Check that the URL in Twilio is the one for the connection and that the stored Auth Token is the right one. |
sms_missing_auth_token |
The connection has no Auth Token (400). | Update the connection with your account’s Auth Token. |
sms_no_default_sender |
There is no active default sender (409). | Verify the connection to sync your numbers. |
sms_test_send_limited |
You passed the hourly cap of test recipients (429). | Wait as long as Retry-After says and try again. |
sms_from_required |
The request has no sender and the connection has no default. | Provide the from field or set a default sender. |
sms_invalid_number |
The number is not in E.164 format. | Use the international format, for example +15551234567. |
Done when
Section titled “Done when”The app shows the Twilio connection as active, your numbers appear as senders, the test SMS reached your phone and a reply from you shows up in the Inbox.