> ## 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.

# Export API Workflow

> This topic explains the Export API workflow:

export const NoteCallout = ({title, children}) => <div className="callout-box callout-note">
    <div className="callout-row">
      <span className="callout-icon">
        <svg width="22" height="22" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M208,104a79.86,79.86,0,0,1-30.59,62.92A24.29,24.29,0,0,0,168,186v6a8,8,0,0,1-8,8H96a8,8,0,0,1-8-8v-6a24.11,24.11,0,0,0-9.3-19A79.87,79.87,0,0,1,48,104.45C47.76,61.09,82.72,25,126.07,24A80,80,0,0,1,208,104Z" opacity="0.2" /><path d="M176,232a8,8,0,0,1-8,8H88a8,8,0,0,1,0-16h80A8,8,0,0,1,176,232Zm40-128a87.55,87.55,0,0,1-33.64,69.21A16.24,16.24,0,0,0,176,186v6a16,16,0,0,1-16,16H96a16,16,0,0,1-16-16v-6a16,16,0,0,0-6.23-12.66A87.59,87.59,0,0,1,40,104.49C39.74,56.83,78.26,17.14,125.88,16A88,88,0,0,1,216,104Zm-16,0a72,72,0,0,0-73.74-72c-39,.92-70.47,33.39-70.26,72.39a71.65,71.65,0,0,0,27.64,56.3A32,32,0,0,1,96,186v6h64v-6a32.15,32.15,0,0,1,12.47-25.35A71.65,71.65,0,0,0,200,104Zm-16.11-9.34a57.6,57.6,0,0,0-46.56-46.55,8,8,0,0,0-2.66,15.78c16.57,2.79,30.63,16.85,33.44,33.45A8,8,0,0,0,176,104a9,9,0,0,0,1.35-.11A8,8,0,0,0,183.89,94.66Z" /></svg>
      </span>
      <div>
        {title && <div className="callout-title">
            {title}
          </div>}
        <div className="callout-body">
          {children}
        </div>
      </div>
    </div>
  </div>;

<NoteCallout title="Note">
  This workflow explains a usual course of export functionality and does not include exceptional scenarios.
</NoteCallout>

1. A user selects specific accounting entries for export from Pleo to an external ERP/accounting system.

2. The accounting entries are transformed to exportable data items and packaged as **export items**.

3. At this stage, an export job is initiated in the `pending` status.

4. If the external ERP/accounting system sends a request to the `GET Get a list of Export Jobs` with `company_id` and `pending` status in the query parameters, the endpoint response sends a list of export jobs awaiting in the `pending` status; the endpoint response also contains the corresponding export job IDs. If no export job is available in the `pending` status, no response is sent.

5. The export job now begins to transfer the **export items** from Pleo to the ERP/accounting system.

6. Simultaneously, the external ERP/accounting system sends a request to the `POST Create Export Job Event` endpoint with `started` as the value for `event` parameter.

   This changes the state of the `pending` export job to `in_progress` state.

7. At the end of the export, the export job could have either of the following status:

   * `failed`: The export items could not be transferred to the ERP/accounting system. If the export job has `failed`, `failureReason` and `failureReasonType` are additional parameters that the ERP/accounting system specify while sending a request to the `POST Create Export Job Event` endpoint to update the status of the corresponding export job.

   * `completed`: The export job is successfully completed and all the export items have been transferred to the ERP/accounting system.

   * `completed_with_errors`: Some export items have been exported, while some could not.

     <NoteCallout title="Note">
       If the export job has `completed` status, each accounting entry is assigned an `exportedAt`, `externalId`, and `externalUrl` - this information is returned in the `GET Get Export Job Items` endpoint response.
     </NoteCallout>

The Pleo application also accordingly updates the export workflow status:

* All successfully exported accounting entries are moved to the **Exported** tab.
* The accounting entries that could not be exported remain in the **Export queue**.

<NoteCallout title="Note">
  - If the external ERP/accounting system sends a request to the `GET Get Export Items` endpoint, specifying a certain export job ID, it returns a list of accounting entries that have been selected for export in a specific export job. The endpoint response informs you about the accounting entries that are selected for export in an export job.

  - Send a request to the `PUT Update Export Job Items` to modify details of accounting entries that either have been successfully exported to the ERP/accounting system (for `successful` status), not yet exported (for `pending` and `in_progress` status), or not exported (for `failed` and `abandoned` status).
</NoteCallout>
