Open SidemenuDocs
Docs
Close Sidemenu

Filter and Search Message Detail Records with Telnyxfilter-and-search-message-detail-records-with-telnyxbeta

Note: This feature is currently in beta.

Once a send message API request goes through, your SMS or MMS will be put into a queue to be sent to its destination. A Message Detail Record (MDR) describes a specific message request and includes those that are active, pending and completed. Telnyx stores the most recent version of the MDR.

Starting 6/21/2021, you will be able to query your Message Detail Records for the last 30 days. Going forward, you will be able to query your data for a rolling 3 month period. Below is an example of retrieving an MDR, and filtering based on time.

Retrieving an MDRretrieving-an-mdr

Note: You will have to acquire an API Key to run this code in your terminal.

curl -X GET \
  --header "Content-Type: application/json" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer YOUR_API_KEY" \
"https://api.telnyx.com/v2/message_detail_records?start_date=2021-06-10T00:00:00Z&end_date=2021-06-10T17:00:00Z"

Response Payload

{
  "data": [
        {
            "id": "403179f6-ddbd-4404-8913-d30c884d6809",
            "created_at": "2021-06-10T16:59:57Z",
            "outbound_profile_name": "My Telnyx Messaging Profile",
            "outbound_profile_id": "40017980-7d67-4a2f-bf9e-f3a3762c0fa3",
            "direction": "OUTBOUND",
            "parts": 1,
            "status": "DELIVERED",
            "cld": "+13176040939",
            "cli": "+16155761289",
            "rate": {
                "amount": 0.0045,
                "currency": "USD"
            },
            "cost": {
                "amount": 0.0045,
                "currency": "USD"
            },
            "country_iso": "US",
            "message_type": "SMS",
            "errors": [
                ""
            ],
            "normalized_carrier": "AT&T",
            "pass_through_fee": {
                "amount": 0.002,
                "currency": "USD"
            },
            "tags": "",
            "mcc": "",
            "mnc": "",
            "product": "LONG_CODE",
            "record_type": "message_detail_record"
        }
    ],
    "meta": {
        "total_pages": -1,
        "total_results": -1,
        "page_number": 1,
        "page_size": 1
  }
}

In the example above, we’re filtering for a span of time, but you have the option to filter on many other values (see Full API ReferenceTelnyx Developers for more details):

  • start_date
  • end_date
  • id
  • direction
  • profile
  • cld
  • cli
  • status
  • message_type
  • currency
  • country_iso
  • error
  • normalized_carrier
  • tag
  • mcc
  • mnc
  • product

MDR Schema and Status Descriptionsmdr-schema-and-status-descriptions

A Message Detail Record (MDR) describes a specific message request and includes those that are active, pending and completed. Telnyx stores the most recent version of the MDR.

MDR Schema

id

ID of the message request, which is a UUID.

It is included as a string in the POST /messages response payload for outbound messages, or the payload of an incoming webhook for inbound messages.

e.g., "c51c89d9-68ad-4db2-a471-cf622d21c40d"

created_at

Message sent time.

string (date-time)

e.g., 2020-07-01T00:00:00-06:00

direction

Direction of message - inbound or outbound.

string

e.g., outbound

parts

Number of parts this message has. If the message contains more than the maximum number of characters, 160, then it will be broken down into multiple parts.

number

e.g., 2

status

Message status.

string

Possible values: GW_TIMEOUT, DELIVERED, DLR_UNCONFIRMED, DLR_TIMEOUT, RECEIVED, GW_REJECT, FAILED

cld

Destination number for a call, or the callee.

string

e.g., +1555123456

cli Number associated with the person initiating the call, or the caller.

string

e.g., +1555123456

rate

Rate applied to the message.

number

e.g., 0.05

cost

Final cost, which is calculated as rate * parts.

number

e.g.,

user_id

The user id.

string (uuid)

e.g., 2a4d6979-546e-4890-8147-0549a3d340c4

currency

Currency of the rate and cost.

string

Possible Values: AUD, CAD, EUR, GBP, USD

country_iso

ISO country code for the cld number.

string

e.g., US

messageType

Type of message.

string

Possible Values: SMS, MMS

errors

Error returned by the gateway in the case of a message send failure.

e.g., 40001

normalized_carrier

Cld carrier.

string

e.g., T-Mobile

pass_through_fee

Normalized carrier pass through fee

number

e.g., 0.10

tags

user tag

string

e.g., tag1

mcc

Mobile country code

string

e.g., 0.1

mnc

Mobile network code

string

e.g., 01

product

Message product used.

string

Possible Values: LONG_CODE, SHORT_CODE, SHORT_CODE_FTEU, TOLL_FREE, ALPHANUMERIC_ID, RCS

record_type

Record type

string

e.g., message_detail_record

vendor

Underlying vendor

string

e.g., infobip-sms

Was this page helpful?