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

# Phone numbers

> Provision, release, and manage Twilio phone numbers for voice agents

Manage phone numbers provisioned via Twilio for voice agents. Phone numbers can be assigned to genies for inbound and outbound calling.

<Note>
  Standard users can only view phone numbers assigned to their own agents. Admin users can view all phone numbers across the platform.
</Note>

***

## List phone numbers

Returns a paginated list of phone numbers with user profile enrichment.

<ParamField body="resource" type="string" required>
  Must be `"phone-numbers"`.
</ParamField>

<ParamField body="action" type="string" required>
  Must be `"all"` or `"list"`.
</ParamField>

<ParamField body="data" type="object">
  <Expandable title="properties">
    <ParamField body="search" type="string">
      Filter by phone number digits.
    </ParamField>

    <ParamField body="country_code" type="string">
      Filter by country code (for example `"US"`, `"AU"`).
    </ParamField>

    <ParamField body="status" type="string">
      Filter by status.
    </ParamField>

    <ParamField body="is_transfer" type="boolean">
      Filter by transfer vs main numbers.
    </ParamField>

    <ParamField body="agent_id" type="string">
      Filter to a specific genie.
    </ParamField>

    <ParamField body="limit" type="number" default="50">
      Results per page. Maximum 500.
    </ParamField>

    <ParamField body="offset" type="number" default="0">
      Number of results to skip.
    </ParamField>

    <ParamField body="adminMode" type="boolean" default="false">
      Admin only. View all phone numbers across the platform.
    </ParamField>
  </Expandable>
</ParamField>

<ResponseField name="success" type="boolean" />

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="items" type="array">
      Array of phone number objects.
    </ResponseField>

    <ResponseField name="count" type="number">
      Total number of matching records.
    </ResponseField>

    <ResponseField name="limit" type="number">
      The limit that was applied.
    </ResponseField>

    <ResponseField name="offset" type="number">
      The offset that was applied.
    </ResponseField>
  </Expandable>
</ResponseField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -s https://api.helpgenie.ai/v1/phone-numbers \
    -H "Authorization: Bearer hg_live_YOUR_KEY"
  ```

  ```json Request body theme={null}
  {
    "resource": "phone-numbers",
    "action": "all",
    "data": {
      "country_code": "US",
      "limit": 50
    }
  }
  ```

  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "items": [
        {
          "id": "phone-123",
          "number": "+12345678901",
          "friendly_name": "Support Line",
          "country_code": "US",
          "status": "active",
          "agent_id": "550e8400-e29b-41d4-a716-446655440000",
          "is_transfer": false,
          "created_at": "2024-01-15T10:30:00.000Z"
        }
      ],
      "count": 1,
      "limit": 50,
      "offset": 0
    }
  }
  ```
</CodeGroup>

***

## Get phone number

Retrieves a single phone number by ID with profile enrichment.

<ParamField body="resource" type="string" required>
  Must be `"phone-numbers"`.
</ParamField>

<ParamField body="action" type="string" required>
  Must be `"get"`.
</ParamField>

<ParamField body="id" type="string" required>
  The phone number record ID.
</ParamField>

***

## Stats

Returns aggregated statistics across phone numbers.

<ParamField body="resource" type="string" required>
  Must be `"phone-numbers"`.
</ParamField>

<ParamField body="action" type="string" required>
  Must be `"stats"`.
</ParamField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="total" type="number">Total phone number count.</ResponseField>
    <ResponseField name="active" type="number">Active phone numbers.</ResponseField>
    <ResponseField name="inactive" type="number">Inactive phone numbers.</ResponseField>
  </Expandable>
</ResponseField>

***

## Export

Exports phone numbers as a CSV string. Supports the same filters as the list action.

<ParamField body="resource" type="string" required>
  Must be `"phone-numbers"`.
</ParamField>

<ParamField body="action" type="string" required>
  Must be `"export"`.
</ParamField>

CSV columns: Phone Number, Friendly Name, Genie Name, User Email, User Name, Country, Status, Type, Date Provisioned. Maximum 10,000 records.

***

## Provision

Provisions a new phone number via Twilio and assigns it to a genie. Delegates to the `twilio-handler` edge function.

<ParamField body="resource" type="string" required>
  Must be `"phone-numbers"`.
</ParamField>

<ParamField body="action" type="string" required>
  Must be `"provision"`.
</ParamField>

<ParamField body="data" type="object" required>
  <Expandable title="properties">
    <ParamField body="agent_id" type="string" required>
      Genie UUID to assign the number to.
    </ParamField>

    <ParamField body="country_code" type="string">
      Country for number provisioning.
    </ParamField>
  </Expandable>
</ParamField>

***

## Release

Releases a provisioned phone number. Delegates to the `twilio-handler` edge function.

<ParamField body="resource" type="string" required>
  Must be `"phone-numbers"`.
</ParamField>

<ParamField body="action" type="string" required>
  Must be `"release"`.
</ParamField>

<ParamField body="id" type="string" required>
  The phone number record ID to release.
</ParamField>

<Warning>
  This will release the phone number from Twilio. The number may become unavailable for re-provisioning.
</Warning>

***

## Update

Updates phone number configuration. Delegates to the `twilio-update-number` edge function.

<ParamField body="resource" type="string" required>
  Must be `"phone-numbers"`.
</ParamField>

<ParamField body="action" type="string" required>
  Must be `"update"`.
</ParamField>

<ParamField body="id" type="string" required>
  The phone number record ID to update.
</ParamField>
