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

# Import Phone Number

Import a phone number from a provider (Twilio or LiveKit SIP).

<Note>
  For Twilio numbers, you must first create a Twilio integration and provide its ID.
  For SIP numbers, LiveKit trunks are automatically created.
</Note>

### Headers

<ParamField header="X-API-Key" type="string" required>
  Your API key for authentication.
</ParamField>

<ParamField header="X-Organization-Id" type="string" required>
  The organization ID.
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be `application/json`.
</ParamField>

### Permissions

* `phone_numbers:create` (admin, agent\_manager)

### Request Body

<ParamField body="phone_number" type="string" required>
  Phone number in E.164 format (e.g., `+12345678900`).
</ParamField>

<ParamField body="provider" type="string" required>
  Provider type: `twilio` or `sip`.
</ParamField>

<ParamField body="supports_inbound" type="boolean" default="false">
  Whether the number supports inbound calls.
</ParamField>

<ParamField body="supports_outbound" type="boolean" default="false">
  Whether the number supports outbound calls.
</ParamField>

#### Twilio-Specific Parameters

<ParamField body="integration_id" type="string">
  Integration ID (required for Twilio provider). Must be a valid Twilio integration.
</ParamField>

#### SIP-Specific Parameters (LiveKit)

<ParamField body="sip_trunk_name" type="string">
  Name for the SIP trunk.
</ParamField>

<ParamField body="sip_username" type="string">
  SIP username for authentication.
</ParamField>

<ParamField body="sip_password" type="string">
  SIP password for authentication.
</ParamField>

<ParamField body="sip_server_address" type="string">
  SIP server address (required for outbound).
</ParamField>

<ParamField body="inbound_room_name" type="string">
  Room name pattern for inbound calls.
</ParamField>

<ParamField body="inbound_pin" type="string">
  Optional PIN for inbound calls (4-10 characters).
</ParamField>

<ParamField body="media_encryption" type="string" default="allow">
  SIP media encryption mode: `disable`, `allow`, or `require`.
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Indicates if the import was successful.
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable success message.
</ResponseField>

<ResponseField name="data" type="object">
  The created phone number object.
</ResponseField>

<RequestExample>
  ```json Twilio Request theme={null}
  {
    "phone_number": "+15551234567",
    "provider": "twilio",
    "supports_inbound": true,
    "supports_outbound": true,
    "integration_id": "intg_a1b2c3d4e5f6"
  }
  ```
</RequestExample>

<RequestExample>
  ```json SIP Request theme={null}
  {
    "phone_number": "+15559876543",
    "provider": "sip",
    "supports_inbound": true,
    "supports_outbound": true,
    "sip_trunk_name": "my-trunk",
    "sip_server_address": "sip.example.com",
    "sip_username": "user",
    "sip_password": "pass",
    "media_encryption": "require"
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "message": "Phone number imported successfully with twilio",
    "data": {
      "phone_number_id": "phon_a1b2c3d4e5f6",
      "phone_number": "+15551234567",
      "provider": "twilio",
      "status": "free",
      "supports_inbound": true,
      "supports_outbound": true,
      "integration_id": "intg_a1b2c3d4e5f6",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:30:00Z"
    }
  }
  ```
</ResponseExample>

### Errors

<ResponseField name="400" type="object">
  Missing required fields or invalid provider.
</ResponseField>

<ResponseField name="404" type="object">
  Integration not found (for Twilio).
</ResponseField>

<ResponseField name="403" type="object">
  Integration belongs to different organization.
</ResponseField>

<ResponseField name="409" type="object">
  Phone number already exists in the system.
</ResponseField>
