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

# Generates and fetches CDR Usage Reports

> Generate and fetch voice usage report synchronously. This endpoint will both generate and fetch the voice report over a specified time period. No polling is necessary but the response may take up to a couple of minutes. 



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/account-billing/usage-reports.yml get /reports/cdr_usage_reports/sync
openapi: 3.1.0
info:
  title: Telnyx Usage Reports API
  version: 2.0.0
  description: API for Usage reports.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /reports/cdr_usage_reports/sync:
    get:
      tags:
        - CDR Usage Reports
      summary: Generates and fetches CDR Usage Reports
      description: >-
        Generate and fetch voice usage report synchronously. This endpoint will
        both generate and fetch the voice report over a specified time period.
        No polling is necessary but the response may take up to a couple of
        minutes. 
      operationId: GetCDRUsageReportSync
      parameters:
        - name: start_date
          in: query
          schema:
            type: string
            format: date-time
            example: '2020-07-01T00:00:00-06:00'
        - name: end_date
          in: query
          schema:
            type: string
            format: date-time
            example: '2020-07-01T00:00:00-06:00'
        - name: aggregation_type
          in: query
          required: true
          schema:
            type: string
            example: NO_AGGREGATION
            enum:
              - NO_AGGREGATION
              - CONNECTION
              - TAG
              - BILLING_GROUP
        - name: product_breakdown
          in: query
          required: true
          schema:
            type: string
            example: NO_BREAKDOWN
            enum:
              - NO_BREAKDOWN
              - DID_VS_TOLL_FREE
              - COUNTRY
              - DID_VS_TOLL_FREE_PER_COUNTRY
        - name: connections
          in: query
          schema:
            type: array
            example:
              - 1234567890123
            items:
              type: number
              example: 1234567890123
      responses:
        '200':
          description: Successful
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CdrGetSyncUsageReportResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/reporting_ErrorResponse'
      security:
        - bearerAuth: []
      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 response = await client.reports.cdrUsageReports.fetchSync({
              aggregation_type: 'NO_AGGREGATION',
              product_breakdown: 'NO_BREAKDOWN',
            });

            console.log(response.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
            )
            response = client.reports.cdr_usage_reports.fetch_sync(
                aggregation_type="NO_AGGREGATION",
                product_breakdown="NO_BREAKDOWN",
            )
            print(response.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\tresponse, err := client.Reports.CdrUsageReports.FetchSync(context.TODO(), telnyx.ReportCdrUsageReportFetchSyncParams{\n\t\tAggregationType:  telnyx.ReportCdrUsageReportFetchSyncParamsAggregationTypeNoAggregation,\n\t\tProductBreakdown: telnyx.ReportCdrUsageReportFetchSyncParamsProductBreakdownNoBreakdown,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.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.reports.cdrusagereports.CdrUsageReportFetchSyncParams;

            import
            com.telnyx.sdk.models.reports.cdrusagereports.CdrUsageReportFetchSyncResponse;


            public final class Main {
                private Main() {}

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

                    CdrUsageReportFetchSyncParams params = CdrUsageReportFetchSyncParams.builder()
                        .aggregationType(CdrUsageReportFetchSyncParams.AggregationType.NO_AGGREGATION)
                        .productBreakdown(CdrUsageReportFetchSyncParams.ProductBreakdown.NO_BREAKDOWN)
                        .build();
                    CdrUsageReportFetchSyncResponse response = client.reports().cdrUsageReports().fetchSync(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

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

            response = telnyx.reports.cdr_usage_reports.fetch_sync(
              aggregation_type: :NO_AGGREGATION,
              product_breakdown: :NO_BREAKDOWN
            )

            puts(response)
        - 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 {
              $response = $client->reports->cdrUsageReports->fetchSync(
                aggregationType: 'NO_AGGREGATION',
                productBreakdown: 'NO_BREAKDOWN',
                connections: [1234567890123],
                endDate: new \DateTimeImmutable('2020-07-01T00:00:00-06:00'),
                startDate: new \DateTimeImmutable('2020-07-01T00:00:00-06:00'),
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx reports:cdr-usage-reports fetch-sync \
              --api-key 'My API Key' \
              --aggregation-type NO_AGGREGATION \
              --product-breakdown NO_BREAKDOWN
components:
  schemas:
    CdrGetSyncUsageReportResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/CdrUsageReportResponse'
    reporting_ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/reporting_Error'
    CdrUsageReportResponse:
      type: object
      properties:
        id:
          type: string
          description: Identifies the resource
          format: uuid
        start_time:
          type: string
          format: date-time
          example: '2018-02-02T22:25:27.521Z'
        end_time:
          type: string
          format: date-time
          example: '2018-02-02T22:25:27.521Z'
        connections:
          type: array
          example:
            - 1234567890
            - 9876543210
          items:
            type: integer
            format: int64
        aggregation_type:
          type: string
          enum:
            - NO_AGGREGATION
            - CONNECTION
            - TAG
            - BILLING_GROUP
        status:
          type: string
          enum:
            - PENDING
            - COMPLETE
            - FAILED
            - EXPIRED
        report_url:
          type: string
          example: http://portal.telnyx.com/downloads/report_name_8hvb45Gu.csv
        result:
          type: object
          additionalProperties: true
        created_at:
          type: string
          format: date-time
          example: '2018-02-02T22:25:27.521Z'
        updated_at:
          type: string
          format: date-time
          example: '2018-02-02T22:25:27.521Z'
        record_type:
          type: string
          example: cdr_usage_report
        product_breakdown:
          type: string
          enum:
            - NO_BREAKDOWN
            - DID_VS_TOLL_FREE
            - COUNTRY
            - DID_VS_TOLL_FREE_PER_COUNTRY
    reporting_Error:
      type: object
      properties:
        code:
          type: string
          example: '10011'
        title:
          type: string
          example: Bad Request
        detail:
          type: string
          example: Invalid parameter value
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````