# Twilio API for AI agents: send SMS, place calls and check phone numbers

> How an agent sends SMS, places calls and validates numbers with Twilio, what each call returns and what it costs per message, minute and lookup.

- Published: 2026-10-31
- Author: AMXP
- Topic: Voice and messaging
- Tags: #twilio #ai-agents #sms #voice #phone-lookup
- 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 and what kind of line it is before you spend money on it.

## 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`, `failed` and a few others; the first response is usually `queued`, so delivery has to be checked later or pushed to a `StatusCallback` URL
- `num_segments`: how many segments the body was split into, which is what you are billed on
- `price` and `price_unit`: often empty at first, because the price is filled in after sending
- `error_code` and `error_message`: set when the status is `failed` or `undelivered`

**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`), a `duration` in seconds once the call ends, and `answered_by` (`human` or `machine`) if you turned on `MachineDetection`. What the call actually says is defined by TwiML, passed inline as `Twiml` or fetched from a `Url`.

**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` to get the paid data packages.

## 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

const run = await amxp.execute(tool.id, {
  To: "+14155550123",
  From: "+14155550100",
  Body: "Reminder: your appointment is tomorrow at 10:00. Reply C to confirm.",
  StatusCallback: "https://example.com/hooks/sms-status",
})
// run.output.sid, run.output.status ("queued"), run.output.num_segments
```

A good habit for agents: run a basic Lookup on any number a user typed before texting or calling it. Basic validation is free and catches typos early.

For comparison, the direct call to Twilio's own API 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.

## What it costs

Twilio's US list prices, as of October 2026:

- **SMS**: [$0.0083 per outbound SMS and $0.0083 per inbound SMS in the US](https://www.twilio.com/en-us/sms/pricing/us) on long codes, toll-free and short codes. Messages are charged per segment, so a long body billed as three segments costs three times as much. US carrier fees are added on top and vary by carrier.
- **MMS**: [$0.022 per outbound MMS in the US](https://www.twilio.com/en-us/sms/pricing/us).
- **Voice**: [$0.0140 per minute to make calls and $0.0085 per minute to receive calls on a US local number](https://www.twilio.com/en-us/voice/pricing/us); receiving on a toll-free number is $0.0220 per minute.
- **Lookup**: [basic formatting and validation is free; line type intelligence is $0.008 per request and US caller name is $0.01 per request](https://www.twilio.com/en-us/user-authentication-identity/pricing/lookup).

Worked example: 100 single-segment reminders in the US is 100 × $0.0083 = $0.83 before carrier fees. A line type check on each number first adds 100 × $0.008 = $0.80.

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

## When to use something else

- **You need a number of your own.** Sending SMS needs a sender, and Twilio lists a US long code at [$1.15 per month](https://www.twilio.com/en-us/sms/pricing/us). If your agent sends from a fixed brand number, registered campaigns or high volume, your own Twilio account is the better choice. AMXP is for the gaps: occasional sends, prototypes, and agents that should not hold carrier credentials.
- **You want the agent to hold a conversation on the call.** Twilio places the call; something else has to listen and talk. [Vapi](/tools/vapi), [Retell AI](/tools/retell-ai) and [Bland AI](/tools/bland-ai) run the voice agent, and [Saperly](/tools/saperly) handles phone calls for agents.
- **You only need email.** [AgentMail](/tools/agentmail) gives agents their own inboxes.
- **Price or coverage elsewhere.** [Telnyx](/tools/telnyx) and [Plivo](/tools/plivo) offer similar SMS and voice APIs and are worth comparing for your destination countries.

## 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 can be blank in the first response. Fetch the message again later, or use a `StatusCallback`.

### 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.

## 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
