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

# List available phone number blocks



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/numbers-identity/searching.yml get /available_phone_number_blocks
openapi: 3.1.0
info:
  title: Telnyx Phone Number Search API
  version: 2.0.0
  description: API for searching available phone numbers.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /available_phone_number_blocks:
    get:
      tags:
        - Phone Number Search
      summary: List available phone number blocks
      operationId: ListAvailablePhoneNumberBlocks
      parameters:
        - name: filter
          in: query
          style: deepObject
          explode: true
          description: >-
            Consolidated filter parameter (deepObject style). Originally:
            filter[locality], filter[country_code],
            filter[national_destination_code], filter[phone_number_type]
          schema:
            type: object
            properties:
              locality:
                type: string
                description: Filter phone numbers by city.
              country_code:
                type: string
                description: Filter phone numbers by country.
              national_destination_code:
                type: string
                description: Filter by the national destination code of the number.
              phone_number_type:
                type: string
                enum:
                  - local
                  - toll_free
                  - mobile
                  - national
                  - shared_cost
                description: Filter phone numbers by number type.
      responses:
        '200':
          $ref: '#/components/responses/ListAvailablePhoneNumbersBlockResponse'
        '400':
          $ref: '#/components/responses/numbers_BadRequestResponse'
        '401':
          $ref: '#/components/responses/numbers_UnauthorizedResponse'
        '404':
          $ref: '#/components/responses/numbers_NotFoundResponse'
        '422':
          $ref: '#/components/responses/numbers_UnprocessableEntity'
        '500':
          $ref: '#/components/responses/numbers_GenericErrorResponse'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Telnyx from 'telnyx';


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


            const availablePhoneNumberBlocks = await
            client.availablePhoneNumberBlocks.list();


            console.log(availablePhoneNumberBlocks.data);
        - lang: Python
          source: >-
            import os

            from telnyx import Telnyx


            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )

            available_phone_number_blocks =
            client.available_phone_number_blocks.list()

            print(available_phone_number_blocks.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tavailablePhoneNumberBlocks, err := client.AvailablePhoneNumberBlocks.List(context.TODO(), telnyx.AvailablePhoneNumberBlockListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", availablePhoneNumberBlocks.Data)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.availablephonenumberblocks.AvailablePhoneNumberBlockListParams;

            import
            com.telnyx.sdk.models.availablephonenumberblocks.AvailablePhoneNumberBlockListResponse;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    AvailablePhoneNumberBlockListResponse availablePhoneNumberBlocks = client.availablePhoneNumberBlocks().list();
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


            telnyx = Telnyx::Client.new(api_key: "My API Key")


            available_phone_number_blocks =
            telnyx.available_phone_number_blocks.list


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


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


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


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


            try {
              $availablePhoneNumberBlocks = $client->availablePhoneNumberBlocks->list(
                filter: [
                  'countryCode' => 'country_code',
                  'locality' => 'locality',
                  'nationalDestinationCode' => 'national_destination_code',
                  'phoneNumberType' => 'local',
                ],
              );

              var_dump($availablePhoneNumberBlocks);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx available-phone-number-blocks list \
              --api-key 'My API Key'
components:
  responses:
    ListAvailablePhoneNumbersBlockResponse:
      description: Successful response with a list of available phone numbers blocks.
      content:
        application/json:
          schema:
            type: object
            title: List Available Phone Numbers Blocks Response
            properties:
              data:
                type: array
                items:
                  $ref: '#/components/schemas/AvailablePhoneNumberBlock'
              meta:
                $ref: '#/components/schemas/AvailablePhoneNumbersMetadata'
    numbers_BadRequestResponse:
      description: >-
        Bad request, the request was unacceptable, often due to missing a
        required parameter.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/numbers_Errors'
    numbers_UnauthorizedResponse:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/numbers_Errors'
          examples:
            Authentication Failed:
              value:
                errors:
                  - code: '10009'
                    title: Authentication failed
                    detail: Could not understand the provided credentials.
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10009
    numbers_NotFoundResponse:
      description: The requested resource doesn't exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/numbers_Errors'
    numbers_UnprocessableEntity:
      description: Unprocessable entity. Check the 'detail' field in response for details.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/numbers_Errors'
    numbers_GenericErrorResponse:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/numbers_Errors'
  schemas:
    AvailablePhoneNumberBlock:
      type: object
      properties:
        record_type:
          type: string
          example: available_phone_number_block
          enum:
            - available_phone_number_block
        phone_number:
          type: string
          example: '+19705555000'
        range:
          type: integer
          example: 10
        region_information:
          type: array
          items:
            $ref: '#/components/schemas/RegionInformation'
        cost_information:
          $ref: '#/components/schemas/CostInformation'
        features:
          type: array
          items:
            $ref: '#/components/schemas/Feature'
      example:
        record_type: available_phone_number_block
        phone_number: '+19705555000'
        range: 10
        region_information:
          - region_type: country_code
            region_name: US
        cost_information:
          upfront_cost: '3.21'
          monthly_cost: '6.54'
          currency: USD
        features:
          - name: sms
          - name: voice
    AvailablePhoneNumbersMetadata:
      type: object
      example:
        total_results: 100
        best_effort_results: 50
      properties:
        total_results:
          type: integer
          example: 1
        best_effort_results:
          type: integer
          example: 0
    numbers_Errors:
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/numbers_Error'
      type: object
    RegionInformation:
      properties:
        region_type:
          type: string
          example: country_code
          enum:
            - country_code
            - rate_center
            - state
            - location
        region_name:
          type: string
          example: US
      example:
        region_type: country_code
        region_name: US
      type: object
    CostInformation:
      type: object
      properties:
        upfront_cost:
          type: string
          example: '3.21'
        monthly_cost:
          type: string
          example: '6.54'
        currency:
          type: string
          description: The ISO 4217 code for the currency.
          example: USD
      example:
        upfront_cost: '3.21'
        monthly_cost: '6.54'
        currency: USD
    Feature:
      properties:
        name:
          type: string
          example: sms
      example:
        name: sms
      type: object
    numbers_Error:
      properties:
        code:
          type: string
          example: '10007'
        title:
          type: string
          example: Unexpected error
        detail:
          type: string
          example: An unexpected error occured.
        source:
          type: object
          properties:
            pointer:
              description: JSON pointer (RFC6901) to the offending entity.
              type: string
              example: /base
            parameter:
              description: Indicates which query parameter caused the error.
              type: string
        meta:
          type: object
          properties:
            url:
              type: string
              description: URL with additional information on the error.
              example: https://developers.telnyx.com/docs/overview/errors/10015
      type: object
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````