Create report asynchronously

This code snippet shows you how to generate a report asynchronously, using a date range.

This is an asynchronous call and so will return immediately. You can check the current status of report generation with Get Report Status. Once completed, you can obtain the report with Get Report. Alternatively, you can set a callback URL and receive a notification when report generation is complete.

Date range is limited to 13 months for this call.


Key Description
VONAGE_API_KEY Your Vonage API key (see it on your dashboard).
VONAGE_API_SECRET Your Vonage API secret (also available on your dashboard).
ACCOUNT_ID The account ID (same as VONAGE_API_KEY) for the account you want to generate reports, or retrieve records for.
REPORT_DIRECTION Either inbound or outbound
REPORT_PRODUCT Specifies the product for which reports and records are obtained. Can be one of SMS, VOICE-CALL, WEBSOCKET-CALL, VERIFY-API, NUMBER-INSIGHT, MESSAGES, CONVERSATIONS, or ASR.
REQUEST_ID The request ID returned when a report was created
DATE_START Date of time window from when you want to start gathering records in ISO-8601 format.
DATE_END Date of time window from when you want to stop gathering records in ISO-8601 format.
STATUS Status of message or call.

Write the code

Add the following to

curl -X POST "" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -d $'{
  "product": "$REPORT_PRODUCT",
  "account_id": "$ACCOUNT_ID",
  "direction": "$REPORT_DIRECTION",
  "status": "$STATUS",
  "date_start": "$DATE_START",
  "date_end": "$DATE_END"

View full source

Run your code

Save this file to your machine and run it:


Try it out

  1. Set the replaceable variables for your account.

  2. For this example, set REPORT_PRODUCT to one of SMS, VOICE or MESSAGES.

  3. Using the table as a guide set values for the remaining variables.

  4. Run the script and you receive a response similar to the following:

  "request_id": "ri3p58f-42d57cfd-1234-5678-9abc-67580d95f54a",
  "request_status": "PENDING",
  "direction": "outbound",
  "product": "SMS",
  "account_id": "abcd1234",
  "date_start": "2020-05-21T13:27:00+0000",
  "date_end": "2020-05-21T13:57:00+0000",
  "include_subaccounts": false,
  "include_message": false,
  "receive_time": "2020-06-04T10:53:32+0000",
  "_links": {
    "self": {
      "href": ""

If you set a callback URL, you will receive a callback on that URL with the same content as shown in the previous step.

See also