> ## 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 new legacy usage V2 MDR report request

> Creates a new legacy usage V2 MDR report request with the specified filters



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/account-billing/usage-reports.yml post /legacy_reporting/usage_reports/messaging
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:
  /legacy_reporting/usage_reports/messaging:
    post:
      tags:
        - MDR Usage Reports
      summary: Create a new legacy usage V2 MDR report request
      description: >-
        Creates a new legacy usage V2 MDR report request with the specified
        filters
      operationId: submitMdrUsageReport
      requestBody:
        description: MDR detail request data
        content:
          '*/*':
            schema:
              $ref: '#/components/schemas/MdrUsageRequestLegacy'
        required: true
      responses:
        '200':
          description: V2 legacy MDR usage report request created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MdrPostUsageReportResponse'
        '400':
          description: Invalid request parameters
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '500':
          description: Internal server error
      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 messaging = await
            client.legacy.reporting.usageReports.messaging.create({
              aggregation_type: 0,
            });


            console.log(messaging.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
            )
            messaging = client.legacy.reporting.usage_reports.messaging.create(
                aggregation_type=0,
            )
            print(messaging.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\tmessaging, err := client.Legacy.Reporting.UsageReports.Messaging.New(context.TODO(), telnyx.LegacyReportingUsageReportMessagingNewParams{\n\t\tAggregationType: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", messaging.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.legacy.reporting.usagereports.messaging.MessagingCreateParams;

            import
            com.telnyx.sdk.models.legacy.reporting.usagereports.messaging.MessagingCreateResponse;


            public final class Main {
                private Main() {}

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

                    MessagingCreateParams params = MessagingCreateParams.builder()
                        .aggregationType(0)
                        .build();
                    MessagingCreateResponse messaging = client.legacy().reporting().usageReports().messaging().create(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


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


            messaging =
            telnyx.legacy.reporting.usage_reports.messaging.create(aggregation_type:
            0)


            puts(messaging)
        - lang: CLI
          source: |-
            telnyx legacy:reporting:usage-reports:messaging create \
              --api-key 'My API Key' \
              --aggregation-type 0
components:
  schemas:
    MdrUsageRequestLegacy:
      required:
        - aggregation_type
      type: object
      properties:
        start_time:
          type: string
          format: date-time
          example: '2020-01-01T00:00:00Z'
        end_time:
          type: string
          format: date-time
          example: '2020-01-02T00:00:00Z'
        aggregation_type:
          type: integer
          description: >-
            Aggregation type: No aggregation = 0, By Messaging Profile = 1, By
            Tags = 2
          format: int32
          example: 0
        profiles:
          type: array
          description: List of messaging profile IDs to filter by
          items:
            type: string
            format: uuid
          example:
            - 3fa85f64-5717-4562-b3fc-2c963f66afa6
            - 7d4e3f8a-9b2c-4e1d-8f5a-1a2b3c4d5e6f
        select_all_managed_accounts:
          type: boolean
          example: true
        managed_accounts:
          type: array
          description: List of managed accounts to include
          items:
            type: string
            format: uuid
          example:
            - f47ac10b-58cc-4372-a567-0e02b2c3d479
            - 6ba7b810-9dad-11d1-80b4-00c04fd430c8
      description: MDR usage request parameters
    MdrPostUsageReportResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/MdrUsageReportResponseLegacy'
    MdrUsageReportResponseLegacy:
      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:
          uniqueItems: true
          type: array
          example:
            - '1234567890'
            - '9876543210'
          items:
            type: string
        aggregation_type:
          type: integer
          description: >-
            Aggregation type: No aggregation = 0, By Messaging Profile = 1, By
            Tags = 2
          format: int32
        status:
          type: integer
          description: >-
            Status of the report (Pending = 1, Complete = 2, Failed = 3, Expired
            = 4)
          format: int32
        report_url:
          type: string
          example: http://portal.telnyx.com/downloads/report_name_8hvb45Gu.csv
        result:
          type: object
        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'
        profiles:
          type: array
          description: List of messaging profile IDs
          items:
            type: string
            format: uuid
          example:
            - 3fa85f64-5717-4562-b3fc-2c963f66afa6
            - 7d4e3f8a-9b2c-4e1d-8f5a-1a2b3c4d5e6f
        record_type:
          type: string
          example: mdr_usage_report_v2_legacy
      description: Legacy V2 MDR usage report response
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````