Metrics API
Examples

Examples

Response examples

The following is an example result in JSON format.

json
 
{
  "requestId": "D1ABDD934260284DAE68550826DACDF3",
  "status": "SUCCESS",
  "response": {
    "requestedPeriod": {
      "sentSince": "2024-04-04T00:00:00Z",
      "sentUntil": "2024-04-05T23:59:59Z"
    },
    "totalRows": 6,
    "columns": [
      {"columnName": "CHANNEL_CODE", "columnDataType": "STRING"},
      {"columnName": "HOUR", "columnDataType": "DATE_TIME"},
      {"columnName": "STATUS_GROUP", "columnDataType": "STRING"},
      {"columnName": "STATUS", "columnDataType": "STRING"},
      {"columnName": "COMMUNICATION", "columnDataType": "INTEGER"},
      {"columnName": "TOTAL_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "DELIVERED_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "FAILED_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "TOTAL_SENT_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "TOTAL_RECEIVED_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "TRAFFIC_DELIVERY_RATE", "columnDataType": "NUMBER"},
      {"columnName": "SEEN_OPENED_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "TRAFFIC_SEEN_OPEN_RATE", "columnDataType": "NUMBER"}
    ],
    "rows": [
      ["SMS", "2024-04-04T13:00:00.000+0000", "DELIVERED", "DELIVERED_TO_HANDSET", 200000022475266, 1, 1, 0, 1, 0, 1.0, "N/A", "N/A"],
      ["EMAIL", "2024-04-05T11:00:00.000+0000", "REJECTED", "REJECTED_VALIDATION_FAILED", "N/A", 3, 0, 3, 3, 0, 0.0, 0, 0.0],
      ["EMAIL", "2024-04-05T12:00:00.000+0000", "UNDELIVERABLE", "UNDELIVERABLE_REJECTED_OPERATOR", 200000023016143, 1, 0, 1, 0, 0, 0.0, 0, 0.0],
      ["EMAIL", "2024-04-05T12:00:00.000+0000", "DELIVERED", "DELIVERED_TO_HANDSET", "N/A", 1, 1, 0, 1, 0, 1.0, 0, 0.0],
      ["EMAIL", "2024-04-05T12:00:00.000+0000", "REJECTED", "REJECTED_VALIDATION_FAILED", "N/A", 1, 0, 1, 1, 0, 0.0, 0, 0.0],
      ["ZALOZNS", "2024-04-04T13:00:00.000+0000", "UNDELIVERABLE", "UNDELIVERABLE_REJECTED_OPERATOR", 200000022475266, 1, 0, 1, 1, "N/A", 0.0, "N/A", "N/A"]
    ]
  }
}

The JSON structure consists of a top-level object with three main keys: requestId, status, and response. The requestId key uniquely identifies the request. The status key indicates whether the request was successful or not. The response key contains the actual data returned by the query.

Within the response object, there are several key pieces of information. The requestedPeriod parameter specifies the time period for which the data was requested, typically denoted by a start and end timestamp. The totalRows parameter indicates the total number of rows returned in the response.

The columns array provides information about the structure of the data, including the names and data types of each column. Finally, the rows array contains the actual data returned by the query. Each row represents a single communication instance, with values corresponding to the columns specified in the columns array.

In the provided example, there are six rows of data, each representing a communication event. The data includes details such as the channel code, timestamp, status group, status, communication count, traffic counts, delivery rates, and open rates. Some values may be N/A, indicating unavailable data.

Sum of message counts

Query for the sum of SMS message counts over the last day aggregated per hour.

Request body:

json
 
{
    "callbackUrl": "https://example.com/receive",
    "request": {
        "filterBy": {
            "sentSince": "2024-03-19T00:00:00Z",
            "sentUntil": "2024-03-19T23:59:59Z",
            "includeSubaccounts": false,
            "channelCodes": [
                "SMS"
            ]
        },
        "aggregateBy": [
            "HOUR"
        ],
        "metrics": [
            "TOTAL_TRAFFIC_COUNT",
            "TOTAL_SENT_TRAFFIC_COUNT",
            "DELIVERED_TRAFFIC_COUNT",
            "FAILED_TRAFFIC_COUNT"
        ]
    }
}
 

Sample result:

json
 
{
  "requestId": "44AA99124DA4BE29AE518A3F82DCBD5D",
  "status": "SUCCESS",
  "response": {
    "requestedPeriod": {
      "sentSince": "2024-03-19T00:00:00Z",
      "sentUntil": "2024-03-19T23:59:59Z"
    },
    "totalRows": 1,
    "columns": [
      {"columnName": "CHANNEL_CODE", "columnDataType": "STRING"},
      {"columnName": "HOUR", "columnDataType": "DATE_TIME"},
      {"columnName": "TOTAL_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "TOTAL_SENT_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "DELIVERED_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "FAILED_TRAFFIC_COUNT", "columnDataType": "INTEGER"}
    ],
    "rows": [
      ["SMS", "2024-03-19T11:00:00.000+0000", 17, 17, 16, 1]
    ]
  }
}
 
MetricValue
CHANNEL_CODESMS
HOUR2024-03-19T11:00:00.000Z
TOTAL_TRAFFIC_COUNT17
TOTAL_SENT_TRAFFIC_COUNT17
DELIVERED_TRAFFIC_COUNT16
FAILED_TRAFFIC_COUNT1

Aggregating by applicationId and entityId

Request body:

json
 
{
    "callbackUrl": "https://example.com/receive",
    "request": {
        "filterBy": {
            "sentSince": "2024-04-01T00:00:00Z",
            "sentUntil": "2024-04-30T23:59:59Z",
            "includeSubaccounts": false,
            "directions": [
                "OUTBOUND",
                "INBOUND"
                ],
            "channelCodes": [
                "WHATSAPP",
                "VIBER",
                "SMS"
            ]
        },
        "aggregateBy": [
            "APPLICATION_ID",
            "ENTITY_ID"
        ],
        "metrics": [
            "TOTAL_TRAFFIC_COUNT",
            "TOTAL_SENT_TRAFFIC_COUNT",
            "DELIVERED_TRAFFIC_COUNT",
            "TRAFFIC_DELIVERY_RATE"
        ]
    }
}
 

Sample result:

json
 
{
  "requestId": "C127668A9BF7B564E8DEE1DE78CE0A94",
  "status": "SUCCESS",
  "response": {
    "requestedPeriod": {
      "sentSince": "2024-04-01T00:00:00Z",
      "sentUntil": "2024-04-30T23:59:59Z"
    },
    "totalRows": 7,
    "columns": [
      {"columnName": "CHANNEL_CODE", "columnDataType": "STRING"},
      {"columnName": "APPLICATION_ID", "columnDataType": "STRING"},
      {"columnName": "ENTITY_ID", "columnDataType": "STRING"},
      {"columnName": "TOTAL_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "TOTAL_SENT_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "DELIVERED_TRAFFIC_COUNT", "columnDataType": "INTEGER"},
      {"columnName": "TRAFFIC_DELIVERY_RATE", "columnDataType": "NUMBER"}
    ],
    "rows": [
      ["SMS", "PROMOTION", "BrandA", 250, 230, 210, 0.91304],
      ["SMS", "PROMOTION", "BrandB", 500, 480, 430, 0.89583],
      ["SMS", "NOTIFICATION", "BrandA", 100, 91, 85, 0.93407],
      ["SMS", "NOTIFICATION", "BrandB", 420, 390, 370, 0.94872],
      ["VIBER", "PROMOTION", "BrandA", 200, 191, 180, 0.94241],
      ["VIBER", "PROMOTION", "BrandB", 350, 299, 280, 0.93646],
      ["WHATSAPP", "PROMOTION", "BrandB", 800, 499, 450, 0.90281]
    ]
  }
}
 
CHANNEL_CODESMSSMSSMSSMSVIBERVIBERWHATSAPP
APPLICATION_IDPROMOTIONPROMOTIONNOTIFICATIONNOTIFICATIONPROMOTIONPROMOTIONPROMOTION
ENTITY_IDBrandABrandBBrandABrandBBrandABrandBBrandB
TOTAL_TRAFFIC_COUNT250500100420200350800
TOTAL_SENT_TRAFFIC_COUNT23048091390191299499
DELIVERED_TRAFFIC_COUNT21043085370180280450
TRAFFIC_DELIVERY_RATE (%)91.3089.5893.4194.8794.2493.6590.28

Need assistance

Explore Infobip Tutorials

Encountering issues

Contact our support

What's new? Check out

Release Notes

Unsure about a term? See

Glossary

Research panel

Help shape the future of our products
Service Terms & ConditionsPrivacy policyTerms of use