> ## 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 CSV download



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/numbers-identity/management-config.yml post /phone_numbers/csv_downloads
openapi: 3.1.0
info:
  title: Telnyx Phone Number Management API
  version: 2.0.0
  description: API for managing and configuring phone numbers.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /phone_numbers/csv_downloads:
    post:
      tags:
        - CSV Downloads
      summary: Create a CSV download
      operationId: CreateCsvDownload
      parameters:
        - name: csv_format
          in: query
          description: >-
            Which format to use when generating the CSV file. The default for
            backwards compatibility is 'V1'
          required: false
          schema:
            type: string
            enum:
              - V1
              - V2
            example: V2
            default: V1
        - name: filter
          in: query
          style: deepObject
          explode: true
          description: >-
            Consolidated filter parameter (deepObject style). Originally:
            filter[has_bundle], filter[tag], filter[connection_id],
            filter[phone_number], filter[status], filter[voice.connection_name],
            filter[voice.usage_payment_method], filter[billing_group_id],
            filter[emergency_address_id], filter[customer_reference]
          schema:
            type: object
            properties:
              has_bundle:
                type: string
                description: Filter by phone number that have bundles.
              tag:
                type: string
                description: Filter by phone number tags.
              connection_id:
                type: string
                example: '1521916448077776306'
                description: Filter by connection_id.
              phone_number:
                type: string
                description: |-
                  Filter by phone number. Requires at least three digits.
                               Non-numerical characters will result in no values being returned.
              status:
                type: string
                enum:
                  - purchase-pending
                  - purchase-failed
                  - port-pending
                  - active
                  - deleted
                  - port-failed
                  - emergency-only
                  - ported-out
                  - port-out-pending
                example: active
                description: Filter by phone number status.
              voice.connection_name:
                type: object
                description: Filter by voice connection name pattern matching.
                properties:
                  contains:
                    type: string
                    example: test
                    description: >-
                      Filter contains connection name. Requires at least three
                      characters.
                  starts_with:
                    type: string
                    example: test
                    description: >-
                      Filter starts with connection name. Requires at least
                      three characters.
                  ends_with:
                    type: string
                    example: test
                    description: >-
                      Filter ends with connection name. Requires at least three
                      characters.
                  eq:
                    type: string
                    example: test
                    description: Filter by connection name.
                additionalProperties: false
              voice.usage_payment_method:
                type: string
                enum:
                  - pay-per-minute
                  - channel
                example: channel
                description: Filter by usage_payment_method.
              billing_group_id:
                type: string
                example: 62e4bf2e-c278-4282-b524-488d9c9c43b2
                description: >-
                  Filter by the billing_group_id associated with phone numbers.
                  To filter to only phone numbers that have no billing group
                  associated them, set the value of this filter to the string
                  'null'.
              emergency_address_id:
                type: string
                example: '9102160989215728032'
                description: >-
                  Filter by the emergency_address_id associated with phone
                  numbers. To filter only phone numbers that have no emergency
                  address associated with them, set the value of this filter to
                  the string 'null'.
              customer_reference:
                type: string
                description: Filter numbers via the customer_reference set.
      responses:
        '200':
          $ref: '#/components/responses/CsvDownloadResponse'
        '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 csvDownload = await client.phoneNumbers.csvDownloads.create();

            console.log(csvDownload.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
            )
            csv_download = client.phone_numbers.csv_downloads.create()
            print(csv_download.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\tcsvDownload, err := client.PhoneNumbers.CsvDownloads.New(context.TODO(), telnyx.PhoneNumberCsvDownloadNewParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", csvDownload.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.phonenumbers.csvdownloads.CsvDownloadCreateParams;

            import
            com.telnyx.sdk.models.phonenumbers.csvdownloads.CsvDownloadCreateResponse;


            public final class Main {
                private Main() {}

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

                    CsvDownloadCreateResponse csvDownload = client.phoneNumbers().csvDownloads().create();
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

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

            csv_download = telnyx.phone_numbers.csv_downloads.create

            puts(csv_download)
        - 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 {
              $csvDownload = $client->phoneNumbers->csvDownloads->create(
                csvFormat: 'V2',
                filter: [
                  'billingGroupID' => '62e4bf2e-c278-4282-b524-488d9c9c43b2',
                  'connectionID' => '1521916448077776306',
                  'customerReference' => 'customer_reference',
                  'emergencyAddressID' => '9102160989215728032',
                  'hasBundle' => 'has_bundle',
                  'phoneNumber' => 'phone_number',
                  'status' => 'active',
                  'tag' => 'tag',
                  'voiceConnectionName' => [
                    'contains' => 'test',
                    'endsWith' => 'test',
                    'eq' => 'test',
                    'startsWith' => 'test',
                  ],
                  'voiceUsagePaymentMethod' => 'channel',
                ],
              );

              var_dump($csvDownload);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx phone-numbers:csv-downloads create \
              --api-key 'My API Key'
components:
  responses:
    CsvDownloadResponse:
      description: Successful response with details about a CSV download.
      content:
        application/json:
          schema:
            type: object
            title: CSV Download Response
            properties:
              data:
                type: array
                items:
                  $ref: '#/components/schemas/CsvDownload'
    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:
    CsvDownload:
      type: object
      properties:
        id:
          type: string
          example: 42587e44-3a3e-46de-9255-0c9a7a1d1ec7
          description: Identifies the resource.
          readOnly: true
        record_type:
          type: string
          example: csv_download
          description: Identifies the type of the resource.
          readOnly: true
        url:
          type: string
          example: https://www.telnyx.com/sample/42587e44-3a3e-46de-9255-0c9a7a1d1ec7
          description: The URL at which the CSV file can be retrieved.
        status:
          type: string
          enum:
            - pending
            - complete
            - failed
            - expired
          default: pending
          example: pending
          description: >-
            Indicates the completion level of the CSV report. Only complete CSV
            download requests will be able to be retrieved.
      example:
        id: 42587e44-3a3e-46de-9255-0c9a7a1d1ec7
        record_type: csv_download
        url: https://www.telnyx.com/sample/42587e44-3a3e-46de-9255-0c9a7a1d1ec7
        status: pending
    numbers_Errors:
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/numbers_Error'
      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

````