UC-018 — Export Delivery Reports and History
- Goal
- Export delivery reports, message history and contacts as CSV
- Channel
- SMS, RCS, WhatsApp
- Estimated time
- 15 minutes
- APIs involved
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"
}'
| Parameter | Type | Description |
|---|---|---|
startDateTime | string | Start of the range (yyyy-MM-dd HH:mm:ss.SSSZ) |
endDateTime | string | End of the range |
sender | string | Filter by sender |
recipient | string | Filter by recipient |
campaignId | integer | Campaign ID (alternative to the date range) |
sendType | string | Send 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 |
subAccountId | string | Filter by sub-account |
exportFormat | string | Format: 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.
| Field | Meaning |
|---|---|
type | DELIVERY_REPORT or CONTACTS |
detail | The 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 / expiresAt | When the file was generated, and when it stops being downloadable, 7 days later |
isAvailableForDownload | true 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.
| Parameter | Type | Description |
|---|---|---|
listIds | array[int] | IDs of the lists to export (alternative to contactIds) |
contactIds | array[int] | IDs of the specific contacts to export |
excludeContactIds | array[int] | IDs of contacts to exclude (with listIds, or when exporting all contacts; not with contactIds) |
exportFormat | string | Format: CSV (default) or EXCEL |
A request with listIds together with contactIds, or with contactIds together with excludeContactIds, is answered 400.
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
| Action | Method | Endpoint |
|---|---|---|
| Export delivery reports | POST | /exports/delivery-reports |
| Export contacts | POST | /exports/contacts |
| Export message history | POST | /messages/history/export |
| List exports | GET | /exports |
| Download URL | GET | /exports/{exportId} |
| Regenerate an expired export | POST | /exports/{exportId} |
| Browse history | GET | /messages/history |
Behind the scenes
Exports are designed to handle large data volumes without blocking the API:
- Queueing -- The
POSTrequest creates an asynchronous job and answers202 Acceptedwithin milliseconds, with an empty body and so without an export id. - Processing -- A background worker collects the data, formats it as CSV/EXCEL and uploads the file to secure storage.
- Listing -- Only then is the export written to the list: it appears in
GET /exportsalready downloadable. A job that fails is never written there, so poll with a timeout. - 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. - Retention -- Exports stay available until
expiresAt, 7 days after the file was generated, and stay in the list for 90 days. AfterexpiresAtthe file is removed;POST /exports/{exportId}then queues a new export from the stored parameters, which keep every delivery-report filter but notexcludeContactIds, nor thecontactIdsof a contact export.
Expected result
| Aspect | Detail |
|---|---|
| Action completed | Delivery reports, message history or contacts exported as a CSV/Excel file |
| Channel used | All (SMS, RCS, WhatsApp) |
| Delivery confirmation | A new entry appears in GET /exports with isAvailableForDownload: true; download URL available |
Common errors
| Problem | Probable cause | Solution |
|---|---|---|
HTTP 401 | Missing or invalid API Key | Check X-Api-Key header |
HTTP 400 on the export request | Neither 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 body | Pass 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 wait | The export failed in the background: a failed export is never listed and reports no error | Request 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 true | The pre-signed URL has expired, not the export | Call GET /exports/{exportId} again for a fresh URL |
HTTP 500 Remote server error. on POST /exports/{exportId} | The export has not expired yet | Download it with GET /exports/{exportId} |
HTTP 404 on /exports/{exportId} | Wrong exportId, an export of another account, or one requested from the web dashboard | Take the id from GET /exports |
| Empty CSV | No messages found for the specified filters | Verify the date range, campaignId, sender and recipient filters |
Next steps
- Exports Guide -- Complete overview of the export system
- Contacts and Lists Guide -- Manage contacts and lists
- Webhooks Guide -- Configure webhooks for real-time tracking
- UC-002: Complete Campaign Report -- From the campaign to its statistics and its export