> ## 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 MDR Usage Report

> Submit request for new new messaging usage report. This endpoint will pull and aggregate messaging data in specified time period. 



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/account-billing/usage-reports.yml post /reports/mdr_usage_reports
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/mdr_usage_reports:
    post:
      tags:
        - MDR Usage Reports
      summary: Create MDR Usage Report
      description: >-
        Submit request for new new messaging usage report. This endpoint will
        pull and aggregate messaging data in specified time period. 
      operationId: SubmitUsageReport
      requestBody:
        description: Mdr usage report data
        content:
          '*/*':
            schema:
              $ref: '#/components/schemas/MdrPostUsageReportRequest'
        required: true
      responses:
        '200':
          description: Successful
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MdrPostUsageReportsResponse'
        '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 mdrUsageReport = await client.reports.mdrUsageReports.create({
              aggregation_type: 'NO_AGGREGATION',
              end_date: '2020-07-01T00:00:00-06:00',
              start_date: '2020-07-01T00:00:00-06:00',
            });

            console.log(mdrUsageReport.data);
        - lang: Python
          source: |-
            import os
            from datetime import datetime
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            mdr_usage_report = client.reports.mdr_usage_reports.create(
                aggregation_type="NO_AGGREGATION",
                end_date=datetime.fromisoformat("2020-07-01T00:00:00-06:00"),
                start_date=datetime.fromisoformat("2020-07-01T00:00:00-06:00"),
            )
            print(mdr_usage_report.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\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\tmdrUsageReport, err := client.Reports.MdrUsageReports.New(context.TODO(), telnyx.ReportMdrUsageReportNewParams{\n\t\tAggregationType: telnyx.ReportMdrUsageReportNewParamsAggregationTypeNoAggregation,\n\t\tEndDate:         time.Now(),\n\t\tStartDate:       time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", mdrUsageReport.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.mdrusagereports.MdrUsageReportCreateParams;

            import
            com.telnyx.sdk.models.reports.mdrusagereports.MdrUsageReportCreateResponse;

            import java.time.OffsetDateTime;


            public final class Main {
                private Main() {}

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

                    MdrUsageReportCreateParams params = MdrUsageReportCreateParams.builder()
                        .aggregationType(MdrUsageReportCreateParams.AggregationType.NO_AGGREGATION)
                        .endDate(OffsetDateTime.parse("2020-07-01T00:00:00-06:00"))
                        .startDate(OffsetDateTime.parse("2020-07-01T00:00:00-06:00"))
                        .build();
                    MdrUsageReportCreateResponse mdrUsageReport = client.reports().mdrUsageReports().create(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

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

            mdr_usage_report = telnyx.reports.mdr_usage_reports.create(
              aggregation_type: :NO_AGGREGATION,
              end_date: "2020-07-01T00:00:00-06:00",
              start_date: "2020-07-01T00:00:00-06:00"
            )

            puts(mdr_usage_report)
        - lang: CLI
          source: |-
            telnyx reports:mdr-usage-reports create \
              --api-key 'My API Key' \
              --aggregation-type NO_AGGREGATION \
              --end-date "'2020-07-01T00:00:00-06:00'" \
              --start-date "'2020-07-01T00:00:00-06:00'"
components:
  schemas:
    MdrPostUsageReportRequest:
      required:
        - aggregation_type
        - end_date
        - start_date
      type: object
      properties:
        start_date:
          type: string
          format: date-time
          example: '2020-07-01T00:00:00-06:00'
        end_date:
          type: string
          format: date-time
          example: '2020-07-01T00:00:00-06:00'
        aggregation_type:
          type: string
          enum:
            - NO_AGGREGATION
            - PROFILE
            - TAGS
        profiles:
          type: string
          example: My profile
    MdrPostUsageReportsResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/MdrUsageReportResponse'
    reporting_ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/reporting_Error'
    MdrUsageReportResponse:
      type: object
      properties:
        id:
          type: string
          description: Identifies the resource
          format: uuid
        start_date:
          type: string
          format: date-time
          example: '2020-07-01T00:00:00-06:00'
        end_date:
          type: string
          format: date-time
          example: '2020-07-01T00:00:00-06:00'
        connections:
          type: array
          items:
            type: integer
            format: int64
        aggregation_type:
          type: string
          enum:
            - NO_AGGREGATION
            - PROFILE
            - TAGS
        status:
          type: string
          enum:
            - PENDING
            - COMPLETE
            - FAILED
            - EXPIRED
        report_url:
          type: string
          example: http://portal.telnyx.com/downloads/report_name_8hvb45Gu.csv
        result:
          type: array
          items:
            $ref: '#/components/schemas/MdrUsageRecord'
        created_at:
          type: string
          format: date-time
          example: '2020-07-01T00:00:00-06:00'
        updated_at:
          type: string
          format: date-time
          example: '2020-07-01T00:00:00-06:00'
        profiles:
          type: string
          example: My profile
        record_type:
          type: string
          example: mdr_usage_report
    reporting_Error:
      type: object
      properties:
        code:
          type: string
          example: '10011'
        title:
          type: string
          example: Bad Request
        detail:
          type: string
          example: Invalid parameter value
    MdrUsageRecord:
      type: object
      properties:
        cost:
          type: string
          example: '0'
        direction:
          type: string
          example: outbound
        product:
          type: string
          example: outbound
        connection:
          type: string
          example: all
        received:
          type: string
          example: '0'
        delivered:
          type: string
          example: '0'
        currency:
          type: string
          example: USD
        parts:
          type: string
          example: '0'
        sent:
          type: string
          example: '0'
        profile_id:
          type: string
          example: All
        tags:
          type: string
          example: All
        message_type:
          type: string
          example: SMS
        tn_type:
          type: string
          example: TF
        carrier_passthrough_fee:
          type: string
          example: '0'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````