> ## Documentation Index
> Fetch the complete documentation index at: https://developers.pleo.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate to the Accounting Entries API

> Migration guide from the legacy Receipt API to the Accounting Entries API. Use it to get receipts outside an Export Job, for one Accounting Entry or many. To get receipts during an export, see Migrate to the Export API (v3) in the Receipt API guides.

This guide is for partners who used the [Receipt API](https://developers.pleo.io/reference/pleo-deprecated/receipts/get-expense-receipts.md) to retrieve receipts outside an export, for example to sync receipts to another system or to show them in a dashboard. If you fetch receipts while booking expenses in an Accounting System, see [Migrate to the Export API (v3)](https://developers.pleo.io/deprecation/legacy-receipt-api/migrate-to-export-api.md) instead.

> **Use this page to answer:**

### Which API replaces the legacy Receipt API?

It depends on whether you run an export.

* If you book expenses in an Accounting System, use the Export API (v3). It provides receipts as attachments on Export Items.
* To get receipts outside an Export Job, use the Accounting Entries API.

The Export API (v3) is not a standalone receipt lookup. To choose, see the [Legacy Receipt API Overview](https://developers.pleo.io/deprecation/legacy-receipt-api/overview.md).

### How do I get receipts outside an Export Job?

* Use `GET /v1/accounting-entries/{accountingEntryId}/receipts`. Pass the legacy `expenseId` as the `accountingEntryId`, because both identify the same record.
* To search the receipts of many Accounting Entries in one request, use `POST /v1/accounting-entries/receipts:search`.
* The endpoints return the `ORIGINAL` file by default. For `THUMBNAIL` or `PREVIEW`, set the `file_type` query parameter on the GET endpoint, or `fileType` in the body of the search.
* The receipt `url` expires after 24 hours.

> **Sources for the Accounting Entries API:**
>
> * OpenAPI reference: the endpoint pages under the [Accounting Entries API Overview](https://developers.pleo.io/reference/accounting-entries/accounting-entry-overview.md). Use them for paths, parameters and required fields.
> * How-tos: none yet.

> This page is the canonical source for reading receipts outside an export, using the Accounting Entries API. Related pages cover different concerns:
>
> * [Migrate to the Export API (v3)](https://developers.pleo.io/deprecation/legacy-receipt-api/migrate-to-export-api.md): receipts attached to Export Items during an export.
> * [Legacy Receipt API Overview](https://developers.pleo.io/deprecation/legacy-receipt-api/overview.md): helps you choose between the two.

Terminology: Expenses vs. Accounting Entries

Accounting Entries were previously called `Expenses` in Pleo. The legacy Receipt API takes an `expenseId`, and the Accounting Entries API takes the `accountingEntryId` of the same record.

## New to the Accounting Entries API?

> [card] [API Overview](https://developers.pleo.io/reference/accounting-entries/accounting-entry-overview.md)
>
> What an Accounting Entry is and how the API is structured.

> [card] [API Scopes](https://developers.pleo.io/reference/accounting-entries/scopes.md)
>
> Required scope: `accounting-entries:read`.

> [card] [Generate API Keys](https://developers.pleo.io/docs/current/how-tos/api-keys/how-to-generate-standalone-api-keys.md)
>
> How to generate standalone API keys for authenticating your integration.

> [card] [Standalone API Key Guide](https://developers.pleo.io/docs/current/guides/standalone-api-keys-workflow-guide.md)
>
> End-to-end guide for authenticating with standalone API keys.

> [card] [Standalone API Keys with Postman](https://developers.pleo.io/docs/current/how-tos/api-keys/how-to-make-an-api-call-using-standalone-api-keys-postman.md)
>
> How to make API calls using standalone API keys in Postman.

## Getting Started

You need API credentials with at least the [`accounting-entries:read`](https://developers.pleo.io/reference/accounting-entries/scopes) scope. Once authenticated, you can use these endpoints.

[Search Receipts →](https://developers.pleo.io/reference/accounting-entries/v1/search-receipts-by-post.md)

[Get All Receipts of an Accounting Entry →](https://developers.pleo.io/reference/accounting-entries/v1/get-all-receipts.md)

[Get a Receipt of an Accounting Entry →](https://developers.pleo.io/reference/accounting-entries/v1/get-receipt-file.md)

## Key Differences

| Legacy endpoint | Replacement |
| :- | :- |
| `GET /expenses/{expenseId}/receipts` | `GET /v1/accounting-entries/{accountingEntryId}/receipts` |
| `GET /expenses/{expenseId}/receipts/{receiptId}` | `GET /v1/accounting-entries/{accountingEntryId}/receipts/{receiptId}` |
| Not available | `POST /v1/accounting-entries/receipts:search` |

* Pass the legacy `expenseId` as the `accountingEntryId`, because both identify the same record.
* The search endpoint is new. It returns receipts across Accounting Entries, so you no longer list the receipts of each Accounting Entry one by one.
* The request body must include `includeDeleted` (set it to `true` to include deleted receipts). You can also filter by `accountingEntryIds`, `employeeIds`, `fileType`, `mimeType` and `source`.
* The search endpoint needs one of the `company_id`, `partner_id` or `organization_id` query parameters.
* The receipt endpoints return the `ORIGINAL` file by default. To get `THUMBNAIL` or `PREVIEW`, set the `file_type` query parameter on the GET endpoint, or `fileType` in the body of the search.
* The list and search endpoints use cursor-based pagination. Use `limit` to set the page size. To read the next page, send the `endCursor` from the response as `after`, until `hasNextPage` is `false`. Use `sorting_keys` and `sorting_order` to sort the results.
* The `url` of a receipt expires after 24 hours. Request the receipt again to get a new `url`.

Note

Do not use the Export API (v3) for receipt lookups. It only returns attachments on Export Items, and only while the Export Job is `pending` or `in_progress`.

## Field Mapping

The table below maps fields from the legacy `Receipt` model to their equivalents in the receipt object that the Accounting Entries API returns.

* `—` : field is not available in the Accounting Entries API receipt
* `*` : data is the same but represented differently

| `Receipt` field | Accounting Entries API receipt field | Description |
| :- | :- | :- |
| id | id | The unique ID of the receipt. |
| name | — | The legacy file name. The Accounting Entries API does not return one. |
| url | url **\*** | Where to download the file. The `url` now stays valid for 24 hours instead of 15 hours. |
| mimeType | mimeType | The file type, such as `application/pdf` or `image/jpeg`. It is `unknown` when Pleo cannot tell the type. |
| size | sizeInBytes **\*** | The file size. It is now in bytes instead of kilobytes. |

[Accounting Entries API Overview →](https://developers.pleo.io/reference/accounting-entries/accounting-entry-overview.md)

## New Fields in the Accounting Entries API Receipt

The following fields are available on the Accounting Entries API receipt with no equivalent in the legacy Receipt API.

| Field | Description |
| :- | :- |
| accountingEntryId | The Accounting Entry that the receipt belongs to |
| createdAt | When the receipt was uploaded |
| fileType | The representation of the file, one of `ORIGINAL`, `THUMBNAIL`, `PREVIEW` or `EMBED` |
| source | How the receipt was uploaded, for example `USER`, `EMAIL_FORWARDING` or `CAMERA` |
| ocrDocumentId | The OCR document linked to the receipt, if there is one |
