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

# List phone numbers

> List all phone numbers for an account with cursor-based pagination.



## OpenAPI

````yaml GET /accounts/{account_id}/phone_numbers
openapi: 3.1.1
info:
  title: Surge
  version: '1.0'
servers:
  - url: https://api.surge.app
security:
  - authorization: []
paths:
  /accounts/{account_id}/phone_numbers:
    get:
      tags:
        - Phone numbers
      summary: List phone numbers
      description: List all phone numbers for an account with cursor-based pagination.
      operationId: ListPhoneNumbers
      parameters:
        - in: path
          name: account_id
          required: true
          schema:
            description: The account ID to list phone numbers for.
            example: acct_01j9a43avnfqzbjfch6pygv1td
            type: string
        - in: query
          name: after
          required: false
          schema:
            description: >-
              Cursor for forward pagination. Use the next_cursor from a previous
              response.
            type: string
        - in: query
          name: before
          required: false
          schema:
            description: >-
              Cursor for backward pagination. Use the previous_cursor from a
              previous response.
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PhoneNumberList'
          description: List of phone numbers
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Surge from '@surgeapi/node';


            const client = new Surge({
              apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
            });


            // Automatically fetches more pages as needed.

            for await (const phoneNumber of
            client.phoneNumbers.list('acct_01j9a43avnfqzbjfch6pygv1td')) {
              console.log(phoneNumber.id);
            }
        - lang: Python
          source: |-
            import os
            from surge import Surge

            client = Surge(
                api_key=os.environ.get("SURGE_API_KEY"),  # This is the default and can be omitted
            )
            page = client.phone_numbers.list(
                account_id="acct_01j9a43avnfqzbjfch6pygv1td",
            )
            page = page.data[0]
            print(page.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/stainless-sdks/surge-go\"\n\t\"github.com/stainless-sdks/surge-go/option\"\n)\n\nfunc main() {\n\tclient := surge.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.PhoneNumbers.List(\n\t\tcontext.TODO(),\n\t\t\"acct_01j9a43avnfqzbjfch6pygv1td\",\n\t\tsurge.PhoneNumberListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n"
        - lang: Ruby
          source: |-
            require "surge_api"

            surge = SurgeAPI::Client.new(api_key: "My API Key")

            page = surge.phone_numbers.list("acct_01j9a43avnfqzbjfch6pygv1td")

            puts(page)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Surge\Client;

            use Surge\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('SURGE_API_KEY') ?: 'My API
            Key');


            try {
              $page = $client->phoneNumbers->list(
                'acct_01j9a43avnfqzbjfch6pygv1td', after: 'after', before: 'before'
              );

              var_dump($page);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
components:
  schemas:
    PhoneNumberList:
      description: A paginated list of phone numbers
      example:
        data:
          - campaign_id: null
            id: pn_01jsjwe4d9fx3tpymgtg958d9w
            name: (801) 555-1234
            number: '+18015551234'
            type: local
        pagination:
          next_cursor: null
          previous_cursor: null
      properties:
        data:
          description: The list of phone numbers
          items:
            $ref: '#/components/schemas/PhoneNumber'
          type: array
        pagination:
          $ref: '#/components/schemas/Pagination'
      required:
        - data
        - pagination
      title: PhoneNumberList
      type: object
    ErrorResponse:
      description: An error response
      example:
        error:
          message: The requested resource could not be found.
          type: not_found
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
      title: ErrorResponse
      type: object
    PhoneNumber:
      description: A phone number that can be used to send and receive messages and calls
      example:
        campaign_id: cpn_01jjnn7s0zfx5tdcsxjfy93et2
        id: pn_01jsjwe4d9fx3tpymgtg958d9w
        name: (801) 555-1234
        number: '+18015551234'
        type: local
      properties:
        campaign_id:
          description: >-
            The unique identifier of the campaign this phone number is attached
            to, if any
          type:
            - string
            - 'null'
        id:
          description: Unique identifier for the phone number
          type: string
        name:
          description: A human-readable name for the phone number
          type:
            - string
            - 'null'
        number:
          description: The phone number in E.164 format
          example: '+18015551234'
          format: phone-number
          pattern: ^\+[1-9]\d{6,14}$
          type: string
        type:
          description: Whether the phone number is local, toll-free, or short code
          enum:
            - local
            - short_code
            - toll_free
          type: string
      required:
        - id
        - name
        - number
        - type
        - campaign_id
      title: PhoneNumber
      type: object
    Pagination:
      description: Cursor-based pagination information
      example:
        next_cursor: g3QAAAABZAACaWRtAAAAGnBuXzAxamtzY2s5eDdkeW0wZnBxZjdjYmRyeQ==
        previous_cursor: null
      properties:
        next_cursor:
          description: Cursor for the next page of results. Null if there is no next page.
          type:
            - string
            - 'null'
        previous_cursor:
          description: >-
            Cursor for the previous page of results. Null if there is no
            previous page.
          type:
            - string
            - 'null'
      title: Pagination
      type: object
    Error:
      description: An error response
      example:
        message: The requested resource was not found.
        type: not_found
      properties:
        detail:
          additionalProperties: true
          description: Additional details about the error.
          type: object
        message:
          description: A human-readable error message.
          example: The requested resource was not found.
          type: string
        type:
          description: A unique error code.
          example: not_found
          type: string
      required:
        - type
        - message
      title: Error
      type: object
  securitySchemes:
    authorization:
      bearerFormat: Surge API token
      scheme: bearer
      type: http

````