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

# Remove phone numbers from a DIR

> Deregister phone numbers from a DIR. The enterprise is resolved server-side from the DIR id. Returns a partial-success envelope.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/branded-calling/phone-numbers.yml delete /dir/{dir_id}/phone_numbers
openapi: 3.1.0
info:
  title: Telnyx Branded Calling Phone Numbers API
  version: 2.0.0
  description: >-
    Register and deregister phone numbers under a verified DIR, and track their
    vetting batches.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /dir/{dir_id}/phone_numbers:
    delete:
      tags:
        - Phone Numbers
      summary: Remove phone numbers from a DIR
      description: >-
        Deregister phone numbers from a DIR. The enterprise is resolved
        server-side from the DIR id. Returns a partial-success envelope.
      operationId: deleteDirPhoneNumbersSimplified
      parameters:
        - $ref: '#/components/parameters/DirId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkDeletePhoneNumbersRequest'
            example:
              phone_numbers:
                - '+19493253498'
      responses:
        '200':
          description: Bulk-delete response. Inspect both `deleted` and `errors`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PhoneNumberBulkDeleteResponse'
        default:
          $ref: '#/components/responses/branded-calling_GenericErrorResponse'
        4XX:
          $ref: '#/components/responses/branded-calling_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 phoneNumber = await
            client.dir.phoneNumbers.remove('16635d38-75a6-4481-82e8-69af60e05011',
            {
              phone_numbers: ['+19493253498'],
            });


            console.log(phoneNumber.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 = client.dir.phone_numbers.remove(
                dir_id="16635d38-75a6-4481-82e8-69af60e05011",
                phone_numbers=["+19493253498"],
            )
            print(phone_number.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\tphoneNumber, err := client.Dir.PhoneNumbers.Remove(\n\t\tcontext.TODO(),\n\t\t\"16635d38-75a6-4481-82e8-69af60e05011\",\n\t\ttelnyx.DirPhoneNumberRemoveParams{\n\t\t\tPhoneNumbers: []string{\"+19493253498\"},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", phoneNumber.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.dir.phonenumbers.PhoneNumberRemoveParams;

            import
            com.telnyx.sdk.models.dir.phonenumbers.PhoneNumberRemoveResponse;


            public final class Main {
                private Main() {}

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

                    PhoneNumberRemoveParams params = PhoneNumberRemoveParams.builder()
                        .dirId("16635d38-75a6-4481-82e8-69af60e05011")
                        .addPhoneNumber("+19493253498")
                        .build();
                    PhoneNumberRemoveResponse phoneNumber = client.dir().phoneNumbers().remove(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


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


            phone_number =
            telnyx.dir.phone_numbers.remove("16635d38-75a6-4481-82e8-69af60e05011",
            phone_numbers: ["+19493253498"])


            puts(phone_number)
        - 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 {
              $phoneNumber = $client->dir->phoneNumbers->remove(
                '16635d38-75a6-4481-82e8-69af60e05011', phoneNumbers: ['+19493253498']
              );

              var_dump($phoneNumber);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx dir:phone-numbers remove \
              --api-key 'My API Key' \
              --dir-id 16635d38-75a6-4481-82e8-69af60e05011 \
              --phone-number "'+19493253498'"
components:
  parameters:
    DirId:
      name: dir_id
      in: path
      description: The DIR id. Lowercase UUID.
      required: true
      schema:
        type: string
        format: uuid
        example: 16635d38-75a6-4481-82e8-69af60e05011
  schemas:
    BulkDeletePhoneNumbersRequest:
      type: object
      required:
        - phone_numbers
      additionalProperties: false
      properties:
        phone_numbers:
          type: array
          items:
            type: string
            example: '+19493253498'
          minItems: 1
          maxItems: 15
    PhoneNumberBulkDeleteResponse:
      type: object
      description: >-
        Bulk-delete partial-success response. `data` is the list of phone
        numbers that were soft-deleted. `meta.errors` holds per-number failures
        (e.g. number not associated with this DIR). When EVERY number in the
        request fails, the endpoint instead returns 400 with the canonical
        Telnyx error envelope and `data`/`meta` are absent.
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            type: string
            example: '+19493253498'
          description: >-
            Phone numbers that were successfully soft-deleted. Bare E.164
            strings.
        meta:
          type: object
          required:
            - errors
          properties:
            errors:
              type: array
              items:
                $ref: '#/components/schemas/PhoneNumberItemError'
              description: >-
                Per-number failures that did not block the call. Each entry has
                `phone_number`, `code`, `title`, `detail`.
    PhoneNumberItemError:
      type: object
      description: >-
        Per-number error returned by the bulk-delete endpoint. Bulk-add does not
        use this shape - it returns a 400 with the canonical envelope grouping
        numbers by failure category.
      required:
        - phone_number
        - code
        - title
        - detail
      properties:
        phone_number:
          type: string
          example: '+19493253498'
        code:
          type: string
          enum:
            - not_associated
          description: >-
            Stable per-number error code. Currently only `not_associated` is
            emitted, when the number is not attached to this DIR.
          example: not_associated
        title:
          type: string
          example: Phone number not associated
        detail:
          type: string
          example: Phone number not associated with this DIR.
    branded-calling_Errors:
      type: object
      required:
        - errors
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/branded-calling_Error'
          description: List of one or more error entries. Order is not significant.
      description: >-
        Canonical Telnyx error envelope. Returned on every 4xx and 5xx response
        from this service. `errors` is non-empty; multiple entries indicate
        multiple distinct problems with the same request (e.g. one entry per
        invalid phone number on a bulk operation).
    branded-calling_Error:
      type: object
      required:
        - code
        - title
        - detail
        - meta
      properties:
        code:
          type: string
          example: '10005'
          description: >-
            Stable numeric Telnyx error catalog id. See `meta.url` for the full
            catalog entry.
        title:
          type: string
          example: Invalid parameters
          description: >-
            Short human-readable category, e.g. `Bad Request`, `Duplicate
            resource`, `Not Found`, `Forbidden`. Treat as advisory only - the
            stable identifier is `code`.
        detail:
          type: string
          example: field required
          description: >-
            Context-specific message describing what went wrong on this
            particular request. May embed offending values; do not rely on it
            for programmatic matching - branch on `code`.
        meta:
          type: object
          required:
            - url
          properties:
            url:
              type: string
              format: uri
              example: https://developers.telnyx.com/docs/overview/errors/10005
            pending_check_ids:
              type: array
              items:
                type: string
                format: uuid
              description: >-
                Set on `422 vetting_checks_incomplete` responses from
                `/admin/dir/{id}/approve` and
                `/admin/phone-number-batches/approve`. Lists the still-pending
                vetting check ids.
            pending_check_codes:
              type: array
              items:
                type: string
              description: >-
                Codes of the pending vetting checks (e.g.
                `loa_signature_valid`).
            pending_check_labels:
              type: array
              items:
                type: string
              description: Human-readable labels of the pending vetting checks.
          description: >-
            Carries `url` linking to the Telnyx error catalog entry for this
            `code`. Useful for forwarding the user to documentation.
        source:
          type: object
          description: Optional pointer at the offending field of the request.
          properties:
            pointer:
              type: string
              example: /body/legal_name
            parameter:
              type: string
              example: page[size]
      description: >-
        A single entry in the canonical Telnyx error envelope. `code` is the
        stable Telnyx error catalog id; the human-readable explanation lives at
        `meta.url`. `detail` is a context-specific message; `source.pointer`
        (when present) names the offending field of the request.
  responses:
    branded-calling_GenericErrorResponse:
      description: >-
        An error occurred. The response carries the standard Telnyx error
        envelope.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/branded-calling_Errors'
          examples:
            validation_error:
              summary: 422 - request body failed validation
              value:
                errors:
                  - code: '10005'
                    title: Invalid parameters
                    detail: field required
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10005
                    source:
                      pointer: /body/legal_name
            bad_request:
              summary: 400 - request rejected by a state guard
              description: >-
                Returned when the request itself is well-formed but the resource
                is in a state that disallows this action (e.g. updating a DIR
                while it is being vetted, or deleting an enterprise that still
                has DIRs in vetting).
              value:
                errors:
                  - code: '10015'
                    title: Bad Request
                    detail: Cannot update DIR in 'verified' status
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10015
            not_found:
              summary: 404 - resource does not exist or is not yours
              value:
                errors:
                  - code: '10009'
                    title: Resource not found
                    detail: Enterprise not found.
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10009
            conflict:
              summary: 409 - request conflicts with current resource state
              value:
                errors:
                  - code: '10021'
                    title: Resource in use
                    detail: >-
                      DIR has 1 active infringement claim(s). Resolve the claim
                      before making this change.
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10021
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````