# Twilio API for AI agents: what an SMS, a call and a lookup really cost

> How an agent sends SMS, places calls and checks numbers with Twilio: segments, carrier fees, minute rounding, what the API returns and what each call costs.

- Published: 2026-10-31
- Author: AMXP
- Topic: Voice and messaging
- Tags: #twilio #ai-agents #sms #voice #phone-lookup #telephony-pricing
- Canonical: https://amxp.ai/blog/twilio-api-for-ai-agents

Agents that book appointments, chase invoices or confirm deliveries eventually need to reach a phone. Twilio covers the three jobs that come up most: sending an SMS, placing a voice call, and checking whether a number is real before you spend money on it. The thing most people learn the expensive way: a 161-character reminder costs twice as much as a 160-character one, and a message that fails is not free either. This guide gives you the numbers, the fields that come back, and the mistakes an agent makes that a person would not.

- **$0.0083** per outbound SMS segment, US (list price, October 2026)
- **160** GSM-7 characters in one segment (153 each once it splits)
- **$0.014** per outbound voice minute, US (rounded up to the minute)
- **$0.008** per line-type lookup (basic validation is free)

## Why this matters for agents

A person sends one text and reads the reply. An agent sends ten thousand, never reads the bill, and retries whenever something looks wrong. Three properties of Twilio shape how that goes.

First, you are billed on segments, not messages. Twilio charges [$0.0083 per outbound SMS segment in the US](https://www.twilio.com/en-us/sms/pricing/us) as of October 2026. A body of up to [160 GSM-7 characters is one segment; once it goes over, each segment carries only 153 characters](https://www.twilio.com/docs/glossary/what-sms-character-limit) because 7 are used for the reassembly header. A single curly quote or emoji switches the whole message to UCS-2, where a segment holds 70 characters, or 67 when split. Language models love curly quotes. Check `num_segments` on every response, and strip non-GSM characters before sending.

Second, the first response tells you almost nothing. A successful `POST` returns `status: "queued"`. Delivery, failure and price all arrive later, through a `StatusCallback` or by fetching the message again. An agent that reads `queued` as "done" will report success on messages that never arrived.

Third, there is no idempotency key on the Messages endpoint. If your HTTP call times out after Twilio accepted it, the text has gone out. A blind retry sends it twice, and the customer gets two reminders. Before retrying, list recent messages for that `To` number and the last few minutes, and only resend if nothing is there.

What to check before spending: that the number is valid (free), that it is a mobile line ($0.008), that you are sending inside the `ValidityPeriod` window you intend, and that the body is one segment. Each check is cheaper than the mistake it prevents.

## What Twilio returns

**Sending an SMS** creates a [Message resource](https://www.twilio.com/docs/messaging/api/message-resource). The fields an agent cares about:

- `sid`: the message ID, starting with `SM` or `MM`
- `status`: `queued`, `sending`, `sent`, `delivered`, `undelivered` or `failed`; `accepted` and `scheduled` appear only with a Messaging Service
- `num_segments`: what you are billed on; it starts at `0` on Messaging Service sends until a sender is assigned
- `price` and `price_unit`: populated after the message is sent, so usually `null` on the first response
- `error_code` and `error_message`: set when the status is `failed` or `undelivered`, `null` otherwise

The body limit is 1,600 characters, which is up to 11 segments at 153 each. `ValidityPeriod` defaults to 36,000 seconds (10 hours): a message still sitting in Twilio's queue after that is dropped, which is rarely what you want for a "your table is ready" text. Set it to a few minutes for time-sensitive sends.

**Placing a call** creates a [Call resource](https://www.twilio.com/docs/voice/api/call-resource) with a `sid` starting with `CA`, a `status` (`queued`, `ringing`, `in-progress`, `completed`, `busy`, `failed`, `no-answer` or `canceled`) and a `duration` in seconds once the call ends. What the call says comes from TwiML, passed inline as `Twiml` or fetched from a `Url`. If you turn on `MachineDetection=Enable`, `AnsweredBy` comes back as [`human`, `machine_start`, `fax` or `unknown`](https://www.twilio.com/docs/voice/answering-machine-detection); with `DetectMessageEnd` you also get `machine_end_beep`, `machine_end_silence` and `machine_end_other`. There is no plain `machine` value, so match on the prefix.

**Looking up a number** with [Lookup v2](https://www.twilio.com/docs/lookup/v2-api) returns `valid`, `phone_number` in E.164, `national_format`, `country_code` and `calling_country_code`, plus `validation_errors` when it fails. Add `Fields=line_type_intelligence` or `Fields=caller_name` for the paid packages. The paid fields are nested objects, and each can be `null` when Twilio has no data, so a lookup can succeed and still not answer your question.

## The economics

Twilio's US list prices, as of October 2026, from its [SMS](https://www.twilio.com/en-us/sms/pricing/us), [Voice](https://www.twilio.com/en-us/voice/pricing/us) and [Lookup](https://www.twilio.com/en-us/user-authentication-identity/pricing/lookup) pricing pages:

| Item | Price |
| --- | --- |
| SMS, outbound or inbound, per segment | $0.0083 |
| MMS, outbound | $0.022 |
| Carrier fee, outbound long-code SMS | AT&T $0.0035, T-Mobile $0.0045, Verizon $0.005 |
| Failed message processing fee | $0.001 per message |
| Voice, outbound, per minute | $0.0140 |
| Voice, inbound, per minute | $0.0085 local, $0.0220 toll-free |
| Answering machine detection | $0.0075 per call |
| Call recording | $0.0025 per minute |
| Lookup: validation | Free |
| Lookup: line type intelligence | $0.008 per request |
| Lookup: caller name (US) | $0.01 per request |
| US long code, per month | $1.15 |

Three multipliers matter. Segments multiply the base rate and the carrier fee. Carrier fees are added on top of the $0.0083 and depend on the recipient's network, so you cannot know the exact cost of a text before you send it. And [voice minutes are rounded up](https://help.twilio.com/articles/223132307-How-do-you-round-minutes-for-billing): a 61-second call bills as 2 minutes, so a 30-second confirmation call costs the same $0.014 as a 59-second one.

**1,000 outbound SMS on a US long code, list price** (October 2026, one segment each, before carrier fees)

| Item | Value |
| --- | --- |
| Twilio | $8.30 |
| Plivo | $7.70 |
| Telnyx | $4 |

Source: [Twilio SMS pricing (US)](https://www.twilio.com/en-us/sms/pricing/us). Plivo and Telnyx from their own US pricing pages; all three add carrier fees on top.

[Telnyx lists $0.004 per long-code SMS plus carrier fee](https://telnyx.com/pricing/messaging) and [Plivo $0.0077](https://www.plivo.com/sms/pricing/us/), as of October 2026. The carrier fees are nearly identical across all three (AT&T $0.0035, T-Mobile $0.0045), which is why the gap narrows once you add them.

**What one Twilio SMS segment costs by recipient carrier** (US long code, outbound, $0.0083 base plus carrier fee, October 2026)

| Item | Value |
| --- | --- |
| AT&T | $0.0118 |
| T-Mobile | $0.0128 |
| Verizon | $0.0133 |

Source: [Twilio SMS pricing (US)](https://www.twilio.com/en-us/sms/pricing/us). Carrier fees from the same page; Twilio adds them automatically.

Worked example: appointment reminders at three volumes, sent to T-Mobile customers for a round number.

- One segment (160 GSM-7 characters or fewer): $0.0083 + $0.0045 = $0.0128 each. 100 reminders cost $1.28, 1,000 cost $12.80, 10,000 cost $128.
- Two segments (a 180-character body, or a 160-character one with an emoji): everything doubles. 10,000 reminders cost $256.
- Add a line-type lookup first: 10,000 × $0.008 = $80 extra, once per number rather than per message.

A 2-minute confirmation call to each of those 10,000 customers is 10,000 × 2 × $0.014 = $280, plus $75 if you enable answering machine detection. Calls that end `failed` or `busy` are not billed for minutes.

Through AMXP, `inspect` shows the per-call price before the agent runs anything, and it is charged to your prepaid balance.

## How to call it from your agent

AMXP is in private preview, so this is how it works through AMXP once it opens. The agent finds the Twilio tool, reads its spec, then runs it with the same field names Twilio uses:

```ts
const [tool] = await amxp.discover({ query: "send an SMS", provider: "twilio" })
const spec = await amxp.inspect(tool.id) // params, price per call, examples

// 1. Free validation first, paid line type only if the number is new to you
const check = await amxp.execute(lookupTool.id, {
  PhoneNumber: "+14155550123",
  Fields: "line_type_intelligence",
})
if (!check.output.valid || check.output.line_type_intelligence?.type !== "mobile") return

// 2. Send one segment, with a short validity window and a status webhook
const run = await amxp.execute(tool.id, {
  To: "+14155550123",
  From: "+14155550100",
  Body: "Reminder: your appointment is tomorrow at 10:00. Reply C to confirm.", // 68 chars, GSM-7
  ValidityPeriod: 600,
  StatusCallback: "https://example.com/hooks/sms-status",
})
// run.output.status === "queued"; run.output.num_segments === "1"
// delivered / undelivered / failed arrives at the StatusCallback later
```

For comparison, the direct call is a form-encoded `POST` to `https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json` with `To`, `From` (or `MessagingServiceSid`) and `Body`, authenticated with your Account SID and auth token. Lookup is a `GET` to `https://lookups.twilio.com/v2/PhoneNumbers/{number}?Fields=line_type_intelligence`.

## What most people get wrong

**Treating `queued` as delivered.** The create response is an acknowledgement, not a receipt. Store the `sid`, and let the `StatusCallback` or a later fetch update the record. Report success to the user only on `delivered`, or on `sent` when the carrier does not return receipts.

**Letting the model write the body.** A model-written reminder with a curly apostrophe and an emoji is UCS-2, which halves the segment size to 70 characters. Normalise quotes, ban emoji, and assert `num_segments === "1"` in the response. If it is not, log it, because the cost of that template just doubled.

**Sending to numbers nobody validated.** An invalid `To` returns [error 21211](https://www.twilio.com/docs/api/errors/21211) and the request fails. A valid but filtered message ends `undelivered` with [error 30007](https://www.twilio.com/docs/api/errors/30007), and Twilio still charges a [$0.001 processing fee for each message that ends `failed`](https://www.twilio.com/en-us/sms/pricing/us). Validation is free. Use it.

**Retrying on timeout.** There is no idempotency key. A retry after a network timeout is a second message. List recent messages to the same `To` before resending.

**Forgetting `MachineDetection` on outbound calls.** Without it, your TwiML plays into voicemail and you pay for the minutes. With `MachineDetection=Enable`, `AnsweredBy` tells you `machine_start` and you can hang up or leave a shorter message. It costs $0.0075 per call and adds a short pause before the first word, so set `AsyncAmd=true` if you would rather start talking and adjust mid-call.

## When to use something else

- **You send from a fixed brand number at volume.** A sender costs [$1.15 per month for a US long code](https://www.twilio.com/en-us/sms/pricing/us), and registered 10DLC campaigns or short codes are account-level setup. If messaging is core to your product, your own Twilio account wins. AMXP is for the gaps: occasional sends, prototypes, and agents that should not hold carrier credentials.
- **Price per segment matters more than the ecosystem.** [Telnyx](/tools/telnyx) is about half Twilio's base rate on US long codes and [Plivo](/tools/plivo) is slightly cheaper; [Sinch](/tools/sinch) is worth a quote outside the US.
- **The agent should talk, not just dial.** Twilio places the call; something else has to listen and respond. [Vapi](/tools/vapi), [Retell AI](/tools/retell-ai) and [Bland AI](/tools/bland-ai) run the conversation, and [Saperly](/tools/saperly) handles phone calls for agents.
- **You only need email.** [AgentMail](/tools/agentmail) gives agents their own inboxes, and [Resend](/tools/resend) sends transactional mail.

## Common questions

### Can an AI agent send SMS without a Twilio account?

Once AMXP opens, an agent will be able to call Twilio's messaging tool from its AMXP balance without its own Twilio credentials. Today you need your own Twilio account and a sending number.

### Why is `price` empty in the response?

Twilio fills in [`price` after the message is sent](https://www.twilio.com/docs/messaging/api/message-resource), so it is `null` in the first response. Fetch the message again later, or read it from the `StatusCallback` payload once the status is final.

### How do I check whether a number is a mobile before texting it?

Use Lookup v2 with `Fields=line_type_intelligence`. It costs [$0.008 per request](https://www.twilio.com/en-us/user-authentication-identity/pricing/lookup) as of October 2026, while basic validation alone is free. Cache the answer per number; line types rarely change.

## References

1. [Twilio SMS pricing in the United States](https://www.twilio.com/en-us/sms/pricing/us), Twilio
2. [Twilio Voice pricing in the United States](https://www.twilio.com/en-us/voice/pricing/us), Twilio
3. [Twilio Lookup pricing](https://www.twilio.com/en-us/user-authentication-identity/pricing/lookup), Twilio
4. [Message resource](https://www.twilio.com/docs/messaging/api/message-resource), Twilio
5. [Call resource](https://www.twilio.com/docs/voice/api/call-resource), Twilio
6. [Lookup v2 API](https://www.twilio.com/docs/lookup/v2-api), Twilio
7. [What is the SMS character limit?](https://www.twilio.com/docs/glossary/what-sms-character-limit), Twilio
8. [Answering Machine Detection](https://www.twilio.com/docs/voice/answering-machine-detection), Twilio
9. [How do you round minutes for billing?](https://help.twilio.com/articles/223132307-How-do-you-round-minutes-for-billing), Twilio
10. [Error 30007: Message filtered](https://www.twilio.com/docs/api/errors/30007), Twilio
11. [Error 21211: Invalid To phone number](https://www.twilio.com/docs/api/errors/21211), Twilio
12. [Telnyx messaging pricing](https://telnyx.com/pricing/messaging), Telnyx
13. [Plivo SMS pricing, United States](https://www.plivo.com/sms/pricing/us/), Plivo
