> ## 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.

# Create a phone number block

> Creates a new phone number block.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/numbers-identity/porting-phone-numbers.yml post /porting_orders/{porting_order_id}/phone_number_blocks
openapi: 3.1.0
info:
  title: Telnyx Porting Phone Numbers API
  version: 2.0.0
  description: API for porting phone numbers, blocks, extensions, and configurations.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /porting_orders/{porting_order_id}/phone_number_blocks:
    post:
      tags:
        - Porting Orders
      summary: Create a phone number block
      description: Creates a new phone number block.
      operationId: createPortingPhoneNumberBlock
      parameters:
        - name: porting_order_id
          in: path
          description: Identifies the Porting Order associated with the phone number block
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        $ref: '#/components/requestBodies/CreatePortingPhoneNumberBlock'
      responses:
        '201':
          $ref: '#/components/responses/ShowPortingPhoneNumberBlock'
        '404':
          description: Not found
        '422':
          description: Unprocessable entity. Check message field in response for details.
      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 phoneNumberBlock = await
            client.portingOrders.phoneNumberBlocks.create(
              '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
              {
                activation_ranges: [{ end_at: '+4930244999910', start_at: '+4930244999901' }],
                phone_number_range: { end_at: '+4930244999910', start_at: '+4930244999901' },
              },
            );


            console.log(phoneNumberBlock.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
            )

            phone_number_block =
            client.porting_orders.phone_number_blocks.create(
                porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
                activation_ranges=[{
                    "end_at": "+4930244999910",
                    "start_at": "+4930244999901",
                }],
                phone_number_range={
                    "end_at": "+4930244999910",
                    "start_at": "+4930244999901",
                },
            )

            print(phone_number_block.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\tphoneNumberBlock, err := client.PortingOrders.PhoneNumberBlocks.New(\n\t\tcontext.TODO(),\n\t\t\"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e\",\n\t\ttelnyx.PortingOrderPhoneNumberBlockNewParams{\n\t\t\tActivationRanges: []telnyx.PortingOrderPhoneNumberBlockNewParamsActivationRange{{\n\t\t\t\tEndAt:   \"+4930244999910\",\n\t\t\t\tStartAt: \"+4930244999901\",\n\t\t\t}},\n\t\t\tPhoneNumberRange: telnyx.PortingOrderPhoneNumberBlockNewParamsPhoneNumberRange{\n\t\t\t\tEndAt:   \"+4930244999910\",\n\t\t\t\tStartAt: \"+4930244999901\",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", phoneNumberBlock.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.portingorders.phonenumberblocks.PhoneNumberBlockCreateParams;

            import
            com.telnyx.sdk.models.portingorders.phonenumberblocks.PhoneNumberBlockCreateResponse;


            public final class Main {
                private Main() {}

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

                    PhoneNumberBlockCreateParams params = PhoneNumberBlockCreateParams.builder()
                        .portingOrderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
                        .addActivationRange(PhoneNumberBlockCreateParams.ActivationRange.builder()
                            .endAt("+4930244999910")
                            .startAt("+4930244999901")
                            .build())
                        .phoneNumberRange(PhoneNumberBlockCreateParams.PhoneNumberRange.builder()
                            .endAt("+4930244999910")
                            .startAt("+4930244999901")
                            .build())
                        .build();
                    PhoneNumberBlockCreateResponse phoneNumberBlock = client.portingOrders().phoneNumberBlocks().create(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


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


            phone_number_block =
            telnyx.porting_orders.phone_number_blocks.create(
              "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
              activation_ranges: [{end_at: "+4930244999910", start_at: "+4930244999901"}],
              phone_number_range: {end_at: "+4930244999910", start_at: "+4930244999901"}
            )


            puts(phone_number_block)
        - lang: CLI
          source: |-
            telnyx porting-orders:phone-number-blocks create \
              --api-key 'My API Key' \
              --porting-order-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e \
              --activation-range "{end_at: '+4930244999910', start_at: '+4930244999901'}" \
              --phone-number-range "{end_at: '+4930244999910', start_at: '+4930244999901'}"
components:
  requestBodies:
    CreatePortingPhoneNumberBlock:
      required: true
      content:
        application/json:
          schema:
            type: object
            required:
              - phone_number_range
              - activation_ranges
            properties:
              phone_number_range:
                type: object
                required:
                  - start_at
                  - end_at
                properties:
                  start_at:
                    description: >-
                      Specifies the start of the phone number range for this
                      porting phone number block.
                    type: string
                    pattern: ^\+\d{7,15}$
                    example: '+4930244999901'
                  end_at:
                    description: >-
                      Specifies the end of the phone number range for this
                      porting phone number block.
                    type: string
                    pattern: ^\+\d{7,15}$
                    example: '+4930244999910'
              activation_ranges:
                description: >-
                  Specifies the activation ranges for this porting phone number
                  block. The activation range must be within the block range and
                  should not overlap with other activation ranges.
                type: array
                items:
                  type: object
                  required:
                    - start_at
                    - end_at
                  properties:
                    start_at:
                      type: string
                      description: >-
                        Specifies the start of the activation range. Must be
                        greater or equal the start of the extension range.
                      pattern: ^\+\d{7,15}$
                      example: '+4930244999901'
                    end_at:
                      type: string
                      description: >-
                        Specifies the end of the activation range. It must be no
                        more than the end of the extension range.
                      pattern: ^\+\d{7,15}$
                      example: '+4930244999910'
  responses:
    ShowPortingPhoneNumberBlock:
      description: Successful response
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                $ref: '#/components/schemas/PortingPhoneNumberBlock'
  schemas:
    PortingPhoneNumberBlock:
      type: object
      properties:
        id:
          description: Uniquely identifies this porting phone number block.
          type: string
          format: uuid
          example: f24151b6-3389-41d3-8747-7dd8c681e5e2
          readOnly: true
        country_code:
          description: >-
            Specifies the country code for this porting phone number block. It
            is a two-letter ISO 3166-1 alpha-2 country code.
          type: string
          example: DE
        phone_number_type:
          description: Specifies the phone number type for this porting phone number block.
          type: string
          example: local
          enum:
            - landline
            - local
            - mobile
            - national
            - shared_cost
            - toll_free
        phone_number_range:
          description: >-
            Specifies the phone number range for this porting phone number
            block.
          type: object
          properties:
            start_at:
              description: >-
                Specifies the start of the phone number range for this porting
                phone number block.
              type: string
              pattern: ^\+\d{7,15}$
              example: '+4930244999901'
            end_at:
              description: >-
                Specifies the end of the phone number range for this porting
                phone number block.
              type: string
              pattern: ^\+\d{7,15}$
              example: '+4930244999910'
        activation_ranges:
          description: >-
            Specifies the activation ranges for this porting phone number block.
            The activation range must be within the phone number range and
            should not overlap with other activation ranges.
          type: array
          items:
            type: object
            properties:
              start_at:
                description: >-
                  Specifies the start of the activation range. Must be greater
                  or equal the start of the phone number range.
                type: string
                pattern: ^\+\d{7,15}$
                example: '+4930244999901'
              end_at:
                description: >-
                  Specifies the end of the activation range. It must be no more
                  than the end of the phone number range.
                type: string
                pattern: ^\+\d{7,15}$
                example: '+4930244999910'
        record_type:
          type: string
          example: porting_phone_number_block
          description: Identifies the type of the resource.
          readOnly: true
        created_at:
          type: string
          format: date-time
          description: ISO 8601 formatted date indicating when the resource was created.
          example: '2021-03-19T10:07:15.527Z'
          readOnly: true
        updated_at:
          type: string
          format: date-time
          description: >-
            ISO 8601 formatted date indicating when the resource was last
            updated.
          example: '2021-03-19T10:07:15.527Z'
          readOnly: true
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````