> ## 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 MDR detailed report request

> Creates a new MDR detailed 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/batch_detail_records/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/batch_detail_records/messaging:
    post:
      tags:
        - MDR Detailed Reports
      summary: Create a new MDR detailed report request
      description: Creates a new MDR detailed report request with the specified filters
      operationId: submitMdrRequest
      parameters: []
      requestBody:
        description: MDR detailed report request data
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MdrDetailedRequest'
        required: true
      responses:
        '200':
          description: MDR detailed report request created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MdrPostDetailReportResponse'
        '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.batchDetailRecords.messaging.create({
              end_time: '2024-02-12T23:59:59Z',
              start_time: '2024-02-01T00:00:00Z',
            });


            console.log(messaging.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
            )

            messaging =
            client.legacy.reporting.batch_detail_records.messaging.create(
                end_time=datetime.fromisoformat("2024-02-12T23:59:59"),
                start_time=datetime.fromisoformat("2024-02-01T00:00:00"),
            )

            print(messaging.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\tmessaging, err := client.Legacy.Reporting.BatchDetailRecords.Messaging.New(context.TODO(), telnyx.LegacyReportingBatchDetailRecordMessagingNewParams{\n\t\tEndTime:   time.Now(),\n\t\tStartTime: time.Now(),\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.batchdetailrecords.messaging.MessagingCreateParams;

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

            import java.time.OffsetDateTime;


            public final class Main {
                private Main() {}

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

                    MessagingCreateParams params = MessagingCreateParams.builder()
                        .endTime(OffsetDateTime.parse("2024-02-12T23:59:59Z"))
                        .startTime(OffsetDateTime.parse("2024-02-01T00:00:00Z"))
                        .build();
                    MessagingCreateResponse messaging = client.legacy().reporting().batchDetailRecords().messaging().create(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


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


            messaging =
            telnyx.legacy.reporting.batch_detail_records.messaging.create(
              end_time: "2024-02-12T23:59:59Z",
              start_time: "2024-02-01T00:00:00Z"
            )


            puts(messaging)
        - lang: CLI
          source: |-
            telnyx legacy:reporting:batch-detail-records:messaging create \
              --api-key 'My API Key' \
              --end-time "'2024-02-12T23:59:59Z'" \
              --start-time "'2024-02-01T00:00:00Z'"
components:
  schemas:
    MdrDetailedRequest:
      required:
        - start_time
        - end_time
      type: object
      properties:
        start_time:
          type: string
          description: Start time in ISO format
          format: date-time
          example: '2024-02-01T00:00:00Z'
        end_time:
          type: string
          description: >-
            End time in ISO format. Note: If end time includes the last 4 hours,
            some MDRs might not appear in this report, due to wait time for
            downstream message delivery confirmation
          format: date-time
          example: '2024-02-12T23:59:59Z'
        timezone:
          type: string
          description: Timezone for the report
          example: UTC
        directions:
          type: array
          description: List of directions to filter by (Inbound = 1, Outbound = 2)
          items:
            type: integer
            format: int32
          example:
            - 1
            - 2
        record_types:
          type: array
          description: >-
            List of record types to filter by (Complete = 1, Incomplete = 2,
            Errors = 3)
          items:
            type: integer
            format: int32
          example:
            - 1
            - 2
        connections:
          type: array
          description: List of connections to filter by
          items:
            type: integer
            format: int64
          example:
            - 123
            - 456
        report_name:
          type: string
          description: Name of the report
          example: My MDR Report
        include_message_body:
          type: boolean
          description: Whether to include message body in the report
          example: true
        filters:
          type: array
          description: List of filters to apply
          items:
            $ref: '#/components/schemas/Filter'
        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
        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
        select_all_managed_accounts:
          type: boolean
          description: Whether to select all managed accounts
          example: false
      description: Request object for MDR detailed report
    MdrPostDetailReportResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/MdrDetailReportResponse'
    Filter:
      type: object
      description: >-
        Query filter criteria. Note: The first filter object must specify
        filter_type as 'and'. You cannot follow an 'or' with another 'and'.
      properties:
        filter_type:
          type: string
          description: Logical operator for combining filters
          enum:
            - and
            - or
        cli:
          type: string
          description: Calling line identification (caller ID)
          example: '+13129457420'
        cli_filter:
          type: string
          description: Filter type for CLI matching
          enum:
            - contains
            - starts_with
            - ends_with
        cld:
          type: string
          description: Called line identification (destination number)
          example: '+13129457420'
        cld_filter:
          type: string
          description: Filter type for CLD matching
          enum:
            - contains
            - starts_with
            - ends_with
        tags_list:
          type: string
          description: Tag name to filter by
          example: tag1
        billing_group:
          type: string
          description: Billing group UUID to filter by
          example: adfaa016-f921-4b6c-97bb-e4c1dad231c5
    MdrDetailReportResponse:
      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'
        directions:
          type: array
          items:
            type: string
            enum:
              - INBOUND
              - OUTBOUND
        record_types:
          type: array
          items:
            type: string
            enum:
              - INCOMPLETE
              - COMPLETED
              - ERRORS
        connections:
          type: array
          items:
            type: integer
            format: int64
        report_name:
          type: string
          example: report_name_8hvb45Gu
        status:
          type: string
          enum:
            - PENDING
            - COMPLETE
            - FAILED
            - EXPIRED
        report_url:
          type: string
          example: http://portal.telnyx.com/downloads/report_name_8hvb45Gu.csv
        filters:
          type: array
          items:
            $ref: '#/components/schemas/Filter'
        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: 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_report
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````