Skip to main content

UC-018 — Export Delivery Reports and History

Real-world scenarios​

  • Banca Adriatica — Monthly billing report: On the first day of each month, the finance team exports all the delivery reports of the previous month to reconcile SMS and WhatsApp sending costs.
  • FashionOutlet — Campaign performance analysis: After the Black Friday campaign, marketing exports the reports to compute delivery, open and conversion rates per channel.
  • FarmaExpress — Compliance audit: For GDPR requirements, the DPO exports the history of the messages sent through the API in a quarter; in the file every recipient number has its last three digits masked.

Prerequisites​

Before you begin, make sure you have:

  • Active API Key → How to get one
  • Messages to export → messages sent in the period you want to report on, or a campaignId

Export flow​

Step-by-step guide​

Step 1 — Request the delivery-report export​

Export the delivery reports for a date range. Dates use the format yyyy-MM-dd HH:mm:ss.SSSZ:

curl -X POST "https://api.qlara.ai/api/partner-gateway/exports/delivery-reports" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"startDateTime": "2026-03-01 00:00:00.000+0100",
"endDateTime": "2026-03-31 23:59:59.000+0200",
"sendType": "API",
"exportFormat": "CSV"
}'

Response: 202 Accepted with an empty body -- the export job is queued, and no export id is returned.

You can also export a specific campaign instead of a date range:

curl -X POST "https://api.qlara.ai/api/partner-gateway/exports/delivery-reports" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"campaignId": 1584,
"exportFormat": "CSV"
}'
ParameterTypeDescription
startDateTimestringStart of the range (yyyy-MM-dd HH:mm:ss.SSSZ)
endDateTimestringEnd of the range
senderstringFilter by sender
recipientstringFilter by recipient
campaignIdintegerCampaign ID (alternative to the date range)
sendTypestringSend type: WEB (sent from the web platform, campaigns included), API (sent through the API) or WEB_API (both, the same as leaving it out of a date-range export). With campaignId, only WEB or no sendType
subAccountIdstringFilter by sub-account
exportFormatstringFormat: CSV (default) or EXCEL

recipient filters every message. sender filters the SMS sender of campaign and web-platform messages, leaving their RCS and WhatsApp messages in, and the SMS sender, RCS agent or WhatsApp number of the messages sent through the API. subAccountId applies only to the messages sent through the API.

The request is answered 400, and nothing is queued, when it has neither campaignId nor both startDateTime and endDateTime, only one of the two dates, campaignId together with the dates or with sendType API or WEB_API, or a malformed value such as a date in another format or an unknown sendType. data names the reason, for example Either 'campaignId' or 'startDateTime' and 'endDateTime' are required.

Step 2 — List the exports​

Poll the list of your exports until the new one appears. The list is paginated with page (0-based) and limit (default 10), newest first:

curl -X GET "https://api.qlara.ai/api/partner-gateway/exports?page=0&limit=10" \
-H "X-Api-Key: YOUR_API_KEY"

Response:

{
"data": [
{
"id": 42,
"type": "DELIVERY_REPORT",
"detail": {
"type": "DELIVERY_REPORT",
"exportFormat": "CSV",
"startDateTime": "2026-02-28T23:00:00Z",
"endDateTime": "2026-03-31T21:59:59Z",
"sendType": "API"
},
"createdAt": "2026-04-01 06:15:00.000+0000",
"expiresAt": "2026-04-08 06:15:00.000+0000",
"isAvailableForDownload": true
},
{
"id": 41,
"type": "CONTACTS",
"detail": {
"type": "CONTACT_LIST",
"exportFormat": "CSV",
"contactListIds": [10, 11],
"contactListNames": ["Newsletter", "Clienti VIP"],
"numberOfContacts": 1250
},
"createdAt": "2026-03-20 13:30:00.000+0000",
"expiresAt": "2026-03-27 13:30:00.000+0000",
"isAvailableForDownload": false
}
],
"page": 0,
"limit": 10,
"totalCount": 2,
"totalPages": 1
}

An export is listed only once its file has been generated, already with isAvailableForDownload: true. A queued or running export is not listed yet, and an export whose generation fails is never listed and reports no error. Since the POST returned no id, recognize your export as the new entry whose detail matches your request and whose createdAt is later than the request. Poll every 5-10 seconds, and if nothing shows up within a reasonable time, request the export again. The list covers the last 90 days and holds the exports requested through the API with any key of your account, not those requested from the web dashboard.

FieldMeaning
typeDELIVERY_REPORT or CONTACTS
detailThe parameters of the export, as stored when the file was generated. detail.type is DELIVERY_REPORT, or CONTACT_LIST, CONTACTS or ALL_CONTACTS for a contact export. A list export stores contactListIds, contactListNames and numberOfContacts, not the listIds of the request; dates are in UTC
createdAt / expiresAtWhen the file was generated, and when it stops being downloadable, 7 days later
isAvailableForDownloadtrue from the moment the entry is listed, false once expiresAt has passed

Step 3 — Check availability​

Before downloading, check that isAvailableForDownload is true. Once expiresAt has passed (isAvailableForDownload: false, like export 41 above), the file can no longer be downloaded: regenerate the export:

curl -X POST "https://api.qlara.ai/api/partner-gateway/exports/41" \
-H "X-Api-Key: YOUR_API_KEY"

Response: 202 Accepted with an empty body -- a new export is queued, built from the data as it is now. When its file is ready it appears in GET /exports under a new id: find it as in Step 2 and use that id in Step 4. Export 41 keeps its id and stays expired, and every further call queues one more export. A delivery-report export keeps all of its filters; a contact export does not: excludeContactIds is not applied again, and an export of specific contactIds comes back as an export of all your contacts (detail.type ALL_CONTACTS), so request such an export again with POST /exports/contacts instead.

Decide from isAvailableForDownload and expiresAt, not from the status code: this call on an export that has not expired yet is currently answered 500 (Remote server error.), the same as a real fault; an unknown exportId, or one requested from the web dashboard, is answered 404.

Step 4 — Download the file​

When the entry is listed with isAvailableForDownload: true:

curl -X GET "https://api.qlara.ai/api/partner-gateway/exports/42" \
-H "X-Api-Key: YOUR_API_KEY"

Response:

{
"url": "https://storage.example.com/exports/42.csv?token=abc123def456&expires=1712570100"
}

Use the returned URL to download the CSV file:

curl -o delivery-report-2026-03.csv "https://storage.example.com/exports/42.csv?token=abc123def456&expires=1712570100"

The URL expires after a limited time, which is not the expiry of the export: until expiresAt, call GET /exports/{exportId} again whenever you need a fresh one. In a delivery-report file, the last three characters of every destination are replaced by ***.

Export contacts​

You can also export contact lists:

curl -X POST "https://api.qlara.ai/api/partner-gateway/exports/contacts" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"listIds": [10, 11],
"exportFormat": "CSV"
}'

Response: 202 Accepted with an empty body. The export appears in GET /exports like the others, with type CONTACTS and, for a list export, detail.type CONTACT_LIST.

ParameterTypeDescription
listIdsarray[int]IDs of the lists to export (alternative to contactIds)
contactIdsarray[int]IDs of the specific contacts to export
excludeContactIdsarray[int]IDs of contacts to exclude (with listIds, or when exporting all contacts; not with contactIds)
exportFormatstringFormat: CSV (default) or EXCEL

A request with listIds together with contactIds, or with contactIds together with excludeContactIds, is answered 400.

Export everything

If you specify neither listIds nor contactIds, all the contacts of your account are exported. Send at least an empty object {}: a request without a body is answered 400.

Message history​

Browse the history​

To browse your sending history without exporting it, use pagination. channel, from and to are required:

curl -X GET "https://api.qlara.ai/api/partner-gateway/messages/history?channel=SMS&from=2026-03-01T00:00:00%2B01:00&to=2026-03-31T23:59:59%2B02:00&page=0&limit=50" \
-H "X-Api-Key: YOUR_API_KEY"

Export the history as CSV​

For large volumes, export the history asynchronously. Dates are ISO 8601 with an offset; sender and recipient are optional filters:

curl -X POST "https://api.qlara.ai/api/partner-gateway/messages/history/export" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"startDateTime": "2026-03-01T00:00:00+01:00",
"endDateTime": "2026-03-31T23:59:59+02:00",
"sender": "TechStore",
"recipient": "+393471234567"
}'

Response: 202 Accepted with an empty body.

The export covers every channel (SMS, RCS, WhatsApp) and only the messages sent through the API, not those of campaigns; it has no channel or status filter. Both dates are required: a missing one, or a startDateTime later than endDateTime, is answered 400. The job follows the same flow: the export appears in GET /exports as a DELIVERY_REPORT export with sendType API, and you download it with GET /exports/{exportId}.

The file has one row per message, one per part for an SMS split into several parts, with these columns: Row number, DateTime (the send date), Originator, Destination, Delivery status, IP address, ID SubAccount, SMS cost, Customer ID (the messageId given at send time, or the one generated when none was given), Sent type (SMS-API, RCS-API or WHATSAPP-API), Part number, Total parts and Delivery result. The last three characters of every destination are replaced by ***, and the file has no delivery-date column and no message text.

Endpoint summary​

ActionMethodEndpoint
Export delivery reportsPOST/exports/delivery-reports
Export contactsPOST/exports/contacts
Export message historyPOST/messages/history/export
List exportsGET/exports
Download URLGET/exports/{exportId}
Regenerate an expired exportPOST/exports/{exportId}
Browse historyGET/messages/history
Behind the scenes

Exports are designed to handle large data volumes without blocking the API:

  1. Queueing -- The POST request creates an asynchronous job and answers 202 Accepted within milliseconds, with an empty body and so without an export id.
  2. Processing -- A background worker collects the data, formats it as CSV/EXCEL and uploads the file to secure storage.
  3. Listing -- Only then is the export written to the list: it appears in GET /exports already downloadable. A job that fails is never written there, so poll with a timeout.
  4. Download -- The download URL is a pre-signed link with its own, shorter expiry; GET /exports/{exportId} signs a fresh one at every call until the export expires.
  5. Retention -- Exports stay available until expiresAt, 7 days after the file was generated, and stay in the list for 90 days. After expiresAt the file is removed; POST /exports/{exportId} then queues a new export from the stored parameters, which keep every delivery-report filter but not excludeContactIds, nor the contactIds of a contact export.

Expected result​

AspectDetail
Action completedDelivery reports, message history or contacts exported as a CSV/Excel file
Channel usedAll (SMS, RCS, WhatsApp)
Delivery confirmationA new entry appears in GET /exports with isAvailableForDownload: true; download URL available

Common errors​

ProblemProbable causeSolution
HTTP 401Missing or invalid API KeyCheck X-Api-Key header
HTTP 400 on the export requestNeither campaignId nor both dates, only one date, campaignId with the dates or with sendType API/WEB_API, or a malformed value; for contacts, a request without a bodyPass campaignId or both startDateTime and endDateTime (yyyy-MM-dd HH:mm:ss.SSSZ for delivery reports, ISO 8601 with offset for the history export); send {} to export all contacts
No new entry in GET /exports after a long waitThe export failed in the background: a failed export is never listed and reports no errorRequest the export again; if it never shows up, contact support quoting the X-Request-Id of the request
isAvailableForDownload: false, or HTTP 500 Remote server error. on GET /exports/{exportId}The export has expired (expiresAt has passed)Regenerate it with POST /exports/{exportId}, then take the new id from GET /exports
The download URL no longer works while isAvailableForDownload is trueThe pre-signed URL has expired, not the exportCall GET /exports/{exportId} again for a fresh URL
HTTP 500 Remote server error. on POST /exports/{exportId}The export has not expired yetDownload it with GET /exports/{exportId}
HTTP 404 on /exports/{exportId}Wrong exportId, an export of another account, or one requested from the web dashboardTake the id from GET /exports
Empty CSVNo messages found for the specified filtersVerify the date range, campaignId, sender and recipient filters

Next steps​