PlatformXeDocs
Get API Key

Data Exports

API reference for creating and retrieving data exports.

The Data Exports service lets you export platform data as CSV or JSON files. Exports run asynchronously -- you create an export request and then poll for completion or wait for a webhook notification.

In CSV files, a cell that begins with =, +, -, @, a tab or a carriage return is prefixed with an apostrophe (') so spreadsheets never run it as a formula.

Create an export

POST /api/v1/exports

Scope: exports:create

Request body

FieldTypeRequiredDescription
dataTypestringYesWhat to export: messages, usage, webhooks, or invoices
formatstringNoOutput format: CSV or JSON. Default: CSV
filters.dateFromstringNoISO 8601 start date for the export window
filters.dateTostringNoISO 8601 end date for the export window
filters.servicestringNoNarrow by service. usage: the metered service (e.g. email, sms, storage). messages: the channel it names (email, sms or whatsapp); any other service exports no messages. Ignored for webhooks and invoices

Response

{
  "success": true,
  "data": {
    "id": "exp_abc123",
    "organizationId": "org_xyz",
    "dataType": "usage",
    "format": "CSV",
    "status": "PENDING",
    "downloadUrl": null,
    "fileSize": null,
    "recordCount": null,
    "completedAt": null,
    "expiresAt": null,
    "createdAt": "2026-04-05T10:00:00.000Z"
  }
}
FieldTypeDescription
idstringExport ID for polling
dataTypestringThe data type being exported
formatstringOutput format
statusstringPENDING, PROCESSING, COMPLETED, or FAILED
downloadUrlstring or nullPre-signed download URL (available when COMPLETED)
fileSizenumber or nullFile size in bytes (available when COMPLETED)
recordCountnumber or nullNumber of records exported (available when COMPLETED)
completedAtstring or nullISO 8601 completion timestamp
expiresAtstring or nullISO 8601 expiry timestamp for the download URL

A repeat of the same request returns an earlier export of your organisation instead of running a new one only when the request has a dateTo that had already passed when the earlier export was made, and that export was created within 15 minutes of the repeat, with the same dataType and format, exactly the same filters and window (dateFrom, dateTo and service as sent), COMPLETED, and a link that has not expired (the newest such export among your 20 most recent completed exports of that type and format). This absorbs a request sent twice. A request without dateTo, or with one still to come, always runs a new export (newer rows may exist), and so does any request more than 15 minutes later, because exported rows keep changing after their window ends (an invoice is paid, a queued message is sent, a delivery is retried). A record always reads back the filters you sent (null when you sent none, {} when you sent {}). An export created before exports were scoped by organisation is never returned this way: a new export runs. filters.service is matched without regard to case.

Get an export

GET /api/v1/exports/:exportId

Scope: exports:create

Returns the export record. Poll this endpoint to check when status transitions to COMPLETED, then use the downloadUrl to retrieve the file.

An export created before exports were scoped by organisation (each export records the scoping it was made under) is treated as expired: it comes back with downloadUrl set to null, and the portal no longer lists it. Create a new export for the same data.

Download URLs are pre-signed and expire based on your exports processor's retentionDays setting (default: 30 days). After expiry, the export file is permanently deleted.

Export statuses

StatusDescription
PENDINGExport has been queued
PROCESSINGExport is being generated
COMPLETEDExport is ready for download
FAILEDExport generation failed (check error details)

Processor configuration

The exports processor controls format restrictions, row limits, and file retention. See Exports Processor Config for the full reference.

SettingDefaultDescription
allowedFormats["csv", "json"]Which formats tenants can request
maxRowsPerExport100000Maximum rows per export file
retentionDays30Days before completed export files are auto-deleted

Examples

Export usage data as CSV

curl

# Create the export
curl -X POST https://api.platformxe.com/api/v1/exports \
  -H "Content-Type: application/json" \
  -H "x-api-key: pxk_live_your_api_key_here" \
  -d '{
    "dataType": "usage",
    "format": "CSV",
    "filters": {
      "dateFrom": "2026-03-01T00:00:00.000Z",
      "dateTo": "2026-03-31T23:59:59.999Z",
      "service": "email"
    }
  }'

# Poll for completion
curl https://api.platformxe.com/api/v1/exports/exp_abc123 \
  -H "x-api-key: pxk_live_your_api_key_here"

TypeScript SDK

import { PlatformXeClient } from '@caldera/platformxe-sdk';

const px = new PlatformXeClient({ apiKey: 'pxk_live_your_api_key_here' });

// Create export
const exp = await px.exports.create({
  dataType: 'usage',
  format: 'CSV',
  filters: {
    dateFrom: '2026-03-01T00:00:00.000Z',
    dateTo: '2026-03-31T23:59:59.999Z',
    service: 'email',
  },
});

console.log(exp.id, exp.status);
// "exp_abc123" "PENDING"

// Poll for completion
const completed = await px.exports.get(exp.id);
if (completed.status === 'COMPLETED') {
  console.log('Download:', completed.downloadUrl);
}

Python SDK

from platformxe import PlatformXeClient

px = PlatformXeClient(api_key="pxk_live_your_api_key_here")

exp = px.exports.create({
    "dataType": "usage",
    "format": "CSV",
    "filters": {
        "dateFrom": "2026-03-01T00:00:00.000Z",
        "dateTo": "2026-03-31T23:59:59.999Z",
        "service": "email"
    }
})

# Poll for completion
result = px.exports.get(exp["id"])
if result["status"] == "COMPLETED":
    print("Download:", result["downloadUrl"])

Export invoices as JSON

An invoices export carries billing money, so the key needs billing:read as well as exports:create: without it the create is refused with 403 FORBIDDEN, and GET /api/v1/exports/{id} of an invoices export answers 404 NOT_FOUND.

const invoiceExport = await px.exports.create({
  dataType: 'invoices',
  format: 'JSON',
  filters: {
    dateFrom: '2026-01-01T00:00:00.000Z',
  },
});

Error responses

CodeDescription
BAD_REQUESTInvalid dataType, format, or filter values
FORBIDDENAPI key does not have the exports:create scope, or (an invoices export) does not have billing:read
SERVICE_DISABLEDExports processor is disabled for this organization
RATE_LIMITEDRate limit exceeded