CSV Exports
Two paths for exporting log data: (1) synchronous email-log CSV stream via signed token; (2) async API-request-log CSV emailed as an attachment because the table is too large to stream live.
Posthawk has two export pipelines depending on data size: ## Email logs (synchronous stream) For `email_logs` (sent + received emails), the export is a streamed CSV download. You first request a signed token, then redirect the browser to the worker's CSV endpoint with that token. The browser receives the CSV as a file download. This is what the dashboard's "Export CSV" button on the Logs page does. Token TTL is 5 minutes and consumed on first use. Date range is capped at 31 days. ## API request logs (async, emailed) The `request_logs` table records every authenticated HTTP request to the worker. It can hold tens of millions of rows for a busy workspace, so synchronous streaming would time out. Instead, the export is queued as a BullMQ job — the worker compiles the CSV and emails it to you as an attachment when ready (typically within a minute). This is what the dashboard's "Export CSV" button on the Logs API tab does.
POST
/export/tokenJWTRequest a signed token for an email-log CSV export. Token is valid for 5 minutes and consumed on first use.
| Parameter | Type | In | Description |
|---|---|---|---|
typerequired | string | body | "sent" | "received" | "both" |
dateFromrequired | string | body | ISO 8601 datetime (max 31 days back) |
dateTorequired | string | body | ISO 8601 datetime |
statuses | string[] | body | Filter by email_logs.status: queued, processing, sent, delivered, bounced, complained, failed |
apiKeyId | string | body | Filter sent emails to a specific API key (sent type only) |
domainId | string | body | Filter received emails to a specific domain (received type only) |
Response
json
{ "token": "signed.jwt.string" }GET
/export/csv?token=...NoneDownload the CSV. Browser-redirected from the dashboard with the token from the previous step. Streams the CSV with Content-Disposition: attachment.
| Parameter | Type | In | Description |
|---|---|---|---|
tokenrequired | string | query | Signed token from POST /export/token (5min TTL, consumed on first use) |
POST
/export/request-logsJWTQueue an async request-logs export. The worker compiles the CSV and emails it to you as an attachment when ready. Date range capped at 31 days.
| Parameter | Type | In | Description |
|---|---|---|---|
dateFromrequired | string | body | ISO 8601 datetime |
dateTorequired | string | body | ISO 8601 datetime (max 31 days from dateFrom) |
method | string | body | HTTP method filter (GET, POST, PATCH, PUT, DELETE) |
statusRange | string | body | "2xx" | "4xx" | "5xx" |
Response
json
{
"success": true,
"message": "Export queued. You will receive an email with the CSV attached when ready."
}