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

# Twilio Integration: SMS, WhatsApp, and Voice for Agents

> Agents can send and read SMS and WhatsApp messages, place and review calls, look up phone numbers, and send verification codes. Connect with a Twilio API key.

## Overview

OneCLI connects AI agents to [Twilio](https://www.twilio.com) with an API key. Agents can send and read SMS, MMS, and WhatsApp messages, place calls and read call logs, look up phone numbers, and send one-time verification codes. The gateway signs every request with the key, so your agent never sees it.

This suits support and operations agents: texting a customer an update, checking whether a message was delivered, or verifying a phone number before an account change.

Connecting takes about two minutes.

<a id="self-hosted" style={{ scrollMarginTop: "8rem" }} />

## Connect Twilio

<Steps>
  <Step title="Create an API key in Twilio">
    In the [Twilio Console](https://console.twilio.com), select **API keys & tokens** on the home page (or open **Account** > **API keys & tokens**), then select **Create API key**.

    <Frame caption="The Twilio Console home page. API keys & tokens is under your Account SID and Auth Token.">
      <img src="https://mintcdn.com/chartdbinc/N5soiK0KHcr5ARHv/images/integrations/twilio/twilio-console-home.png?fit=max&auto=format&n=N5soiK0KHcr5ARHv&q=85&s=5aabe44aff06f451570fdd23b122105d" alt="Twilio Console home page showing the account card with a masked Account SID, a hidden Auth Token, and the API keys & auth tokens link." width="1600" height="456" data-path="images/integrations/twilio/twilio-console-home.png" />
    </Frame>

    | Setting | Value |
    | - | - |
    | **Friendly name** | Something you'll recognize, such as `OneCLI` |
    | **Region** | The region your account's data lives in. Most accounts use **United States (US1)** |
    | **Key type** | **Standard**. Pick **Restricted** to limit the key to specific products |

    Select **Create**, then copy the key's **SID** (it starts with `SK`) and its **Secret**. Twilio shows the secret only once.

    <Tip>
      Prefer an API key over your Auth Token. You can revoke a key on its own, without touching anything else that uses your account. Avoid **Main** keys: they can manage subaccounts and other keys, which agents don't need.
    </Tip>
  </Step>

  <Step title="Paste it in OneCLI">
    In the OneCLI dashboard, open **Connections** > **Twilio** and fill in the form.

    <Frame caption="The Twilio connect window in OneCLI.">
      <img src="https://mintcdn.com/chartdbinc/N5soiK0KHcr5ARHv/images/integrations/twilio/onecli-connect-twilio.png?fit=max&auto=format&n=N5soiK0KHcr5ARHv&q=85&s=5a47bc17c12fd6f3685f0198597a11c5" alt="OneCLI connect window for Twilio, showing the setup guide link, the Region dropdown set to United States (US1), the API key SID and API key secret fields, and the Connect Twilio button." width="944" height="1703" data-path="images/integrations/twilio/onecli-connect-twilio.png" />
    </Frame>

    | Field | Value |
    | - | - |
    | **Region** | The region you created the key in: **US1** (the default), **IE1** (Ireland), or **AU1** (Australia) |
    | **API key SID** | The key's SID, starting with `SK` |
    | **API key secret** | The key's secret |

    Select **Connect Twilio**. OneCLI checks the key with Twilio in that region before saving it, so a wrong secret, or a key from another region, is rejected right away.

    You don't need to enter your Account SID. OneCLI looks it up from the key and uses it as the connection's name, so agents know which account they are working in.
  </Step>
</Steps>

<Accordion title="Using your Account SID and Auth Token instead">
  If you can't create an API key, paste your **Account SID** (it starts with `AC`) into **API key SID**, and your **Auth Token** into **API key secret**. Both are on the Twilio Console home page.

  <Warning>
    The Auth Token has full access to your account. If it leaks, you have to rotate it, which breaks everything else that uses it. An API key is safer.
  </Warning>
</Accordion>

<Note>
  Twilio keeps credentials per region: a US1 key doesn't work in IE1 or AU1. Agents can always call the US hosts in Twilio's docs, such as `https://api.twilio.com`. For an IE1 or AU1 connection, the gateway sends each request to that region's host for you.
</Note>

## What agents can do

| Area | What agents can do |
| - | - |
| **Messages** | Send SMS, MMS, and WhatsApp messages, list and read messages and their media, and cancel or delete messages |
| **Calls** | Place outbound calls, list and read calls and recordings, and end or redirect a live call |
| **Phone numbers** | List the account's numbers, search numbers available to buy, and buy, configure, or release numbers |
| **Lookup** | Validate and format a phone number, and read its carrier and line type |
| **Verify** | Send a one-time code by SMS, WhatsApp, voice, or email, and check it |
| **Messaging services** | Read and manage messaging services and their senders |
| **Conversations** | Read conversations, add participants, and send conversation messages |
| **Account** | Read the account balance and usage records |

<Note>
  Some products, including Studio, Conversations, and Functions, aren't available on Twilio trial accounts. On a trial account, Twilio only sends messages and calls to phone numbers you've verified.
</Note>

## Quick example

No `Authorization` header is needed. The gateway adds Twilio's Basic auth:

```bash theme={null}
# Send an SMS (replace AC... with the Account SID shown on the connection)
curl -s -X POST "https://api.twilio.com/2010-04-01/Accounts/ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/Messages.json" \
  --data-urlencode "To=+14155550100" \
  --data-urlencode "From=+14155550199" \
  --data-urlencode "Body=Your order has shipped."

# Look up a phone number's carrier and line type
curl -s "https://lookups.twilio.com/v2/PhoneNumbers/+14155552671?Fields=line_type_intelligence"
```

For every endpoint and parameter, see the [Twilio API reference](https://www.twilio.com/docs/usage/api).

## Controlling access

[Grant](/docs/guides/agent-access) the connection to each agent that needs it, and choose per tool what runs freely, what needs approval, and what's blocked.

Twilio writes reach real people and cost money. **Send a message**, **Place a call**, and **Send a verification code** each contact someone, and **Buy, configure, or release phone numbers** changes what you're billed for. A good default is to let agents read messages, calls, and lookups freely, and put every one of those writes behind approval.

Organization [rules](/docs/guides/rules) add guardrails on top. A blocked request never reaches Twilio.

To disconnect, remove the connection in **Connections** > **Twilio**, then delete the key in the Twilio Console under **Account** > **API keys & tokens**.


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