Payhawk’s Export History API gives you full control over managing and tracking the export status of expenses, their related payments, and payment fees. Each expense can have export history for three items:
Expense (for example, a vendor bill)
Payment (for example, a vendor payment)
Payment fee (for example, a journal entry)
You can export them together or manage each one individually—for instance, mark only payments as exported while keeping the expense unexported.
Through the API, you can:
Retrieve export records and statuses
Mark expenses, payments, or fees as exported or failed
Add messages and external record links
Filter expenses by export destination or export status
Combined with export filters, these features allow you to build flexible integrations that ensure only unexported items are sent to external systems.
Export filters
You can use filters in the Developer API to refine data related to export status and destination. For the full list of filter definitions, see the page.
Supported filters include:
export.into:$equal,$notEqual,$in(any value)payment.export.into:$equal,$notEqual,$in(any value)export.status:$equal(not-exported,succeeded,failed)payment.export.status:$equal(not-exported,succeeded,failed)
These filters help identify expenses and payments by whether they’ve been exported, and into which system.
Use cases
The following examples showcase how you can use Payhawk’s Export History API in various scenarios.
Getting all expenses or payments not exported into a specific system
You can filter all expenses or payments that haven’t been exported into your system (for example, My application).
Endpoint: Get expenses
Example request:
/api/v3/accounts/{{accountId}}/expenses?$filter={"$or":[{"payment.export.into":{"$notEqual":"My Application"}},{"export.into":{"$notEqual":"My Application"}}]}Filter structure:
```json
{
"$or": [
{ "payment.export.into": { "$notEqual": "My Application" } },
{ "export.into": { "$notEqual": "My Application" } }
]
}
```Getting all expenses or payments with a specific export status
To find expenses or payments that failed to export, use:
/api/v3/accounts/{{accountId}}/expenses?$filter={"$or":[{"payment.export.status":{"$equal":"failed"}},{"export.status":{"$equal":"failed"}}]}Filter structure:
```json
{
"$or": [
{ "payment.export.status": { "$equal": "failed" } },
{ "export.status": { "$equal": "failed" } }
]
}
```Retrieving export history
Use this endpoint to view detailed export history for a specific expense.
GET /accounts/:accountId/expenses/:expenseId/export-history
Creating export history
This endpoint allows you to record the export outcome for an expense and its related items.
POST /accounts/:accountId/expenses/:expenseId/export-history
Example request:
```json
{
"expense": {
"exportedInto": "My Application",
"exportStatus": "succeeded",
"exportMessage": "Expense exported into My Application successfully",
"externalRecord": {
"id": "1363",
"url": "https://my.application/entries/expense-82"
},
"exportedAt": "2025-12-20T00:00:00.000Z"
}
}
```This data appears in the Export section of the expense in the UI.
Developer reference
Endpoint:
POST /accounts/:accountId/expenses/:expenseId/export-historyTypeScript Interfaces:
```tsx
export interface IExternalRecord {
id: string;
url?: string;
}
export interface IExportHistoryItem {
exportedAt?: Date;
exportedInto?: string;
externalRecord: IExternalRecord;
exportMessage?: string;
exportStatus: ExportStatus;
}
export interface IExpenseExportHistoryItem extends IExportHistoryItem {}
export interface IPaymentExportHistoryItem extends IExportHistoryItem {
paymentId: string;
}
export interface IExpenseExportHistoryItemAggregate {
expense?: IExportHistoryItem;
payments?: IPaymentExportHistoryItem[];
fees?: IPaymentExportHistoryItem[];
}
```Example payload
```json
{
"expense": {
"exportedInto": "SAP Concur",
"exportStatus": "succeeded",
"exportMessage": "Great success for the expense",
"externalRecord": {
"id": "1363",
"url": "https://erp.integrations/entries/1363"
},
"exportedAt": "2025-04-29T00:00:00.000Z"
},
"payments": [
{
"paymentId": "5142",
"exportedInto": "SAP Concur",
"exportMessage": "Great success for the payment",
"exportStatus": "succeeded",
"externalRecord": {
"id": "2415",
"url": "https://erp.integrations/entries/2415"
},
"exportedAt": "2025-04-29T00:00:00.000Z"
}
],
"fees": [
{
"paymentId": "5142",
"exportedInto": "SAP Concur",
"exportMessage": "Great success for the fee",
"exportStatus": "succeeded",
"externalRecord": {
"id": "2415-fee",
"url": "https://erp.integrations/entries/2415-fee"
},
"exportedAt": "2025-04-29T00:00:00.000Z"
}
]
}
```