> ## Documentation Index
> Fetch the complete documentation index at: https://docs.webrouter.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Twilio

> Twilio SMS and voice: messages, calls, phone numbers, usage records, balance and phone number lookup.

![](https://mintcdn.com/webrouter/8QP9EZc8V07Kl-0I/logo/data-apis/twilio.webp?fit=max\&auto=format\&n=8QP9EZc8V07Kl-0I\&q=85\&s=78c9f0723b318294576ad39908f1bd72)

[Web Catalog · Messaging](https://docs.webrouter.net/data-apis.md?category=messaging)

Needs&#x20;

`TWILIO_ACCOUNT_SID`

,&#x20;

`TWILIO_AUTH_TOKEN`

Endpoints

7

Auth

HTTP Basic

[Vendor docs](https://www.twilio.com/docs/usage/api)

&#x20;·&#x20;

[Pricing](https://www.twilio.com/en-us/pricing)

## Setup

| Variable | | What it is |
| - | - | - |
| `TWILIO_ACCOUNT_SID` | required | Your Twilio Account SID (AC...), from the Console home page. |
| `TWILIO_AUTH_TOKEN` | required | The account's Auth Token, from the Console home page. |

Put them in your environment or `.env`; [Data APIs](https://docs.webrouter.net/vendors.md) covers the other ways.

## Notes

* Account-scoped paths take the Account SID as AccountSid: pass the same AC... value the credentials use.
* Paths end in .json; leave it off and the API answers XML.
* Lists page by PageSize (max 1000) and PageToken; follow next\_page\_uri from the answer rather than building the token.
* Dates in list filters are GMT YYYY-MM-DD; DateSent\< and DateSent> give a range.

## Endpoints

GET

List messages

SMS/MMS/WhatsApp messages sent and received, newest first.

[Open](#twilio-messages-list)

GET

Get a message

One message with status, error code, price and segments.

[Open](#twilio-messages-get)

GET

List calls

Calls to and from the account.

[Open](#twilio-calls-list)

GET

List your phone numbers

Twilio numbers on the account.

[Open](#twilio-phone-numbers-list)

GET

List usage records

Usage and cost by category over a date range.

[Open](#twilio-usage-records)

GET

Get account balance

The account's current balance and currency.

[Open](#twilio-balance-get)

GET

Look up a phone number

Validity and formatting of a number, plus optional paid data such as line type or caller name.

[Open](#twilio-lookup)

### List messages

GET

`/Accounts/{AccountSid}/Messages.json`

`twilio.messages.list`

SMS/MMS/WhatsApp messages sent and received, newest first.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `AccountSid`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        Your Account SID (AC...), the same value as TWILIO\_ACCOUNT\_SID.
      </td>
    </tr>

    <tr>
      <td>
        `To`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Only messages to this number, E.164.
      </td>
    </tr>

    <tr>
      <td>
        `From`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Only messages from this number.
      </td>
    </tr>

    <tr>
      <td>
        `DateSent`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Sent on this GMT date, YYYY-MM-DD.
      </td>
    </tr>

    <tr>
      <td>
        `DateSent_before`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Sent on or before this date.
      </td>
    </tr>

    <tr>
      <td>
        `DateSent_after`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Sent on or after this date.
      </td>
    </tr>

    <tr>
      <td>
        `PageSize`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        1 to 1000, default 50.
      </td>
    </tr>

    <tr>
      <td>
        `PageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Page token from next\_page\_uri.
      </td>
    </tr>

    <tr>
      <td>
        `Page`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Page index, sent with PageToken.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://www.twilio.com/docs/messaging/api/message-resource) · Same job: [AgentMail](https://docs.webrouter.net/data-apis/agentmail.md#agentmail-messages-list), [AgentPhone](https://docs.webrouter.net/data-apis/agentphone.md#agentphone-numbers-messages), [Resend](https://docs.webrouter.net/data-apis/resend.md#resend-emails-received-list), [Saperly](https://docs.webrouter.net/data-apis/saperly.md#saperly-messages-list), [Slack](https://docs.webrouter.net/data-apis/slack.md#slack-conversations-history), [Sprout Social](https://docs.webrouter.net/data-apis/sprout-social.md#sprout-social-messages-list)

### Get a message

GET

`/Accounts/{AccountSid}/Messages/{Sid}.json`

`twilio.messages.get`

One message with status, error code, price and segments.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `AccountSid`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        Your Account SID (AC...), the same value as TWILIO\_ACCOUNT\_SID.
      </td>
    </tr>

    <tr>
      <td>
        `Sid`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        Message SID (SM... or MM...).
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://www.twilio.com/docs/messaging/api/message-resource)

### List calls

GET

`/Accounts/{AccountSid}/Calls.json`

`twilio.calls.list`

Calls to and from the account.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `AccountSid`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        Your Account SID (AC...), the same value as TWILIO\_ACCOUNT\_SID.
      </td>
    </tr>

    <tr>
      <td>
        `To`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Only calls to this number.
      </td>
    </tr>

    <tr>
      <td>
        `From`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Only calls from this number.
      </td>
    </tr>

    <tr><td>`Status`</td><td>string</td><td>query</td><td>Call status. One of `queued`, `ringing`, `in-progress`, `completed`, `busy`, `failed`, `no-answer`, `canceled`</td></tr>

    <tr>
      <td>
        `StartTime_after`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Started on or after this UTC date, YYYY-MM-DD.
      </td>
    </tr>

    <tr>
      <td>
        `StartTime_before`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Started before this UTC date.
      </td>
    </tr>

    <tr>
      <td>
        `PageSize`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        1 to 1000, default 50.
      </td>
    </tr>

    <tr>
      <td>
        `PageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Page token from next\_page\_uri.
      </td>
    </tr>

    <tr>
      <td>
        `Page`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Page index, sent with PageToken.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://www.twilio.com/docs/voice/api/call-resource)

### List your phone numbers

GET

`/Accounts/{AccountSid}/IncomingPhoneNumbers.json`

`twilio.phone_numbers.list`

Twilio numbers on the account.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `AccountSid`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        Your Account SID (AC...), the same value as TWILIO\_ACCOUNT\_SID.
      </td>
    </tr>

    <tr>
      <td>
        `PhoneNumber`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Number or pattern; \* matches any digit.
      </td>
    </tr>

    <tr>
      <td>
        `FriendlyName`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Friendly name.
      </td>
    </tr>

    <tr>
      <td>
        `PageSize`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        1 to 1000, default 50.
      </td>
    </tr>

    <tr>
      <td>
        `PageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Page token from next\_page\_uri.
      </td>
    </tr>

    <tr>
      <td>
        `Page`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Page index, sent with PageToken.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://www.twilio.com/docs/phone-numbers/api/incomingphonenumber-resource)

### List usage records

GET

`/Accounts/{AccountSid}/Usage/Records.json`

`twilio.usage.records`

Usage and cost by category over a date range.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `AccountSid`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        Your Account SID (AC...), the same value as TWILIO\_ACCOUNT\_SID.
      </td>
    </tr>

    <tr>
      <td>
        `Category`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Usage category, e.g. sms or calls.
      </td>
    </tr>

    <tr>
      <td>
        `StartDate`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        GMT YYYY-MM-DD, or an offset like -30days.
      </td>
    </tr>

    <tr>
      <td>
        `EndDate`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        GMT YYYY-MM-DD, or an offset like +30days.
      </td>
    </tr>

    <tr>
      <td>
        `IncludeSubaccounts`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Include subaccounts' usage; default true.
      </td>
    </tr>

    <tr>
      <td>
        `PageSize`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        1 to 1000, default 50.
      </td>
    </tr>

    <tr>
      <td>
        `PageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Page token from next\_page\_uri.
      </td>
    </tr>

    <tr>
      <td>
        `Page`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Page index, sent with PageToken.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://www.twilio.com/docs/usage/api/usage-record)

### Get account balance

GET

`/Accounts/{AccountSid}/Balance.json`

`twilio.balance.get`

The account's current balance and currency.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `AccountSid`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        Your Account SID (AC...), the same value as TWILIO\_ACCOUNT\_SID.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://github.com/twilio/twilio-oai)

> [!NOTE]
>
> * May lag recent charges; subaccounts carry no balance.

### Look up a phone number

GET

`/v2/PhoneNumbers/{PhoneNumber}`

`twilio.lookup`

Validity and formatting of a number, plus optional paid data such as line type or caller name.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`PhoneNumber` required</td><td>string</td><td>path</td><td>E.164 or national format (default country +1). Example `+14155552671`</td></tr>

    <tr>
      <td>
        `Fields`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Comma-separated data packages: line\_type\_intelligence, caller\_name, sim\_swap, call\_forwarding, line\_status, reassigned\_number, sms\_pumping\_risk...
      </td>
    </tr>

    <tr>
      <td>
        `CountryCode`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        ISO alpha-2 country for a national-format number.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://www.twilio.com/docs/lookup/v2-api) · Same job: [HLR Lookup](https://docs.webrouter.net/data-apis/hlrlookup.md#hlrlookup-hlr-lookup), [Telnyx](https://docs.webrouter.net/data-apis/telnyx.md#telnyx-number-lookup), [Trestle](https://docs.webrouter.net/data-apis/trestleiq.md#trestleiq-phone-validate), [Whitepages Pro](https://docs.webrouter.net/data-apis/whitepages.md#whitepages-phone-get)

```python Python theme={null}
router.call_data_api("twilio.lookup", {'PhoneNumber': '+14155552671'})
```

```text MCP theme={null}
call_data_api(endpoint="twilio.lookup", params={"PhoneNumber": "+14155552671"})
```

> [!NOTE]
>
> * The basic lookup with no Fields is free; every data package in Fields is billed.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.