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

# How to Retrieve Export Job Items for Processing

export const WhatComesNext = ({children, href}) => <div className="mt-4">
    <a href={href} className="
        inline-flex items-center justify-center
        rounded-full
        bg-black text-white dark:bg-[#1f262b]
        px-5 py-2.5 text-sm font-medium
        no-underline border-0
        hover:bg-[#ffe6ea] dark:hover:bg-[#2b1f23]
        hover:text-black
        transition-colors
      ">
      {children} →
    </a>
  </div>;

export const RetrieveExportJobItemsDiagram = () => {
  const diagram = `
%%{init: {"themeVariables": {"fontSize": "22px"}}}%%
flowchart LR
    S1["1. Retrieve Export Items for Job"] --> S2["2. Handle Pagination"] --> S4["4. Store Items for Processing"] --> S5["5. Maintain Deterministic Processing Order"]
    S1 -.->|interrupted| S3["3. Handle Job Recovery"]
    S2 -.->|interrupted| S3
    S3 -.-> S4

click S1 "#1-retrieve-export-items-for-the-job"
click S2 "#2-handle-pagination"
click S3 "#3-handle-job-recovery"
click S4 "#4-store-items-for-processing"
click S5 "#5-maintain-deterministic-processing-order"

style S1 white-space:normal
style S2 white-space:normal
style S3 white-space:normal
style S4 white-space:normal
style S5 white-space:normal
`;
  return <Mermaid chart={diagram} />;
};

export const WorkflowDiagramTopNav = ({highlight}) => {
  const highlightStyle = highlight ? `style ${highlight} stroke:#f63b92,stroke-width:5px` : "";
  const diagram = `
%%{init: {"themeVariables": {"fontSize": "28px"}}}%%
flowchart LR

  WEBAPP["Queue Export Items in Pleo's Web App"]

subgraph Pleo["Pleo API's"]
    START1[" "]
    A["1.Detect & Start Export Jobs"] --> B["2.Perform Pre-Export Validation"]
    B --> C["3.Retrieve Export Job Items for Processing"]
    C --> D["4.Fetch Export Item Data for Processing"]
end

subgraph ERP["AS/ERP"]
    START2[" "]
    E["5.Process & Record Export Items"]
end

subgraph Pleo2["Pleo API's"]
    START3[" "]
    F["6.Update Export Items"] --> G["7.Update & Complete Export Job"]
end
WEBAPP --> A
D --> E
E --> F

click WEBAPP "/docs/current/how-tos/accounting-integrations/how-to-queue-export-items-in-ui"
click A "/docs/current/how-tos/accounting-integrations/how-to-detect-and-start-export-jobs-for-as-erp-processing"
click B "/docs/current/how-tos/accounting-integrations/how-to-perform-pre-export-validation-for-as-erp-processing"
click C "/docs/current/how-tos/accounting-integrations/how-to-retrieve-export-job-items-for-as-erp-processing"
click D "/docs/current/how-tos/accounting-integrations/how-to-fetch-export-item-data-for-as-erp-processing"
click E "/docs/current/how-tos/accounting-integrations/how-to-determine-the-bookkeeping-method-for-as-erp-processing"
click F "/docs/current/how-tos/accounting-integrations/how-to-update-export-items-for-as-erp-processing"
click G "/docs/current/how-tos/accounting-integrations/how-to-update-and-complete-export-job-for-as-erp-processing"

style WEBAPP white-space:normal
style Pleo white-space:normal
style ERP white-space:normal
style Pleo2 white-space:normal
style A white-space:normal
style B white-space:normal
style C white-space:normal
style D white-space:normal
style E white-space:normal
style F white-space:normal
style G white-space:normal

style START1 fill:transparent,stroke:transparent,color:transparent
style START2 fill:transparent,stroke:transparent,color:transparent
style START3 fill:transparent,stroke:transparent,color:transparent
style Pleo fill:none,stroke:#000000
style ERP fill:none,stroke:#000000
style Pleo2 fill:none,stroke:#000000

${highlightStyle}
`;
  return <Mermaid chart={diagram} />;
};

export const NoteCallout = ({title, children, icon = "💡"}) => <div style={{
  backgroundColor: 'var(--recommended-bg)',
  borderLeft: '4px solid #3beaf6',
  borderRadius: '10px',
  padding: '18px 22px',
  marginBottom: '20px',
  boxShadow: '1px 1px 3px rgba(0,0,0,0.06)'
}}>
    <div style={{
  display: 'flex',
  alignItems: 'flex-start',
  gap: '14px'
}}>
      <span style={{
  fontSize: '22px',
  lineHeight: '1',
  flexShrink: 0
}}>
        {icon}
      </span>
      <div>
        {title && <div style={{
  fontSize: '16px',
  fontWeight: 600,
  color: 'var(--recommended-title)',
  marginBottom: '6px'
}}>
            {title}
          </div>}
        <div style={{
  fontSize: '14px',
  lineHeight: 1.65
}}>
          {children}
        </div>
      </div>
    </div>
  </div>;

export const RememberCallout = ({title, children, icon = "🪢"}) => <div style={{
  backgroundColor: 'var(--recommended-bg)',
  borderLeft: '4px solid #f63b92',
  borderRadius: '10px',
  padding: '18px 22px',
  marginBottom: '20px',
  boxShadow: '1px 1px 3px rgba(0,0,0,0.06)'
}}>
    <div style={{
  display: 'flex',
  alignItems: 'flex-start',
  gap: '14px'
}}>
      <span style={{
  fontSize: '22px',
  lineHeight: '1',
  flexShrink: 0
}}>
        {icon}
      </span>
      <div>
        {title && <div style={{
  fontSize: '16px',
  fontWeight: 600,
  color: 'var(--recommended-title)',
  marginBottom: '6px'
}}>
            {title}
          </div>}
        <div style={{
  fontSize: '14px',
  lineHeight: 1.65
}}>
          {children}
        </div>
      </div>
    </div>
  </div>;

<WorkflowDiagramTopNav highlight="C" />

<div style={{ border: "2px solid #f63b92", borderRadius: "8px", padding: "16px", backgroundColor: "transparent" }}>
  <RetrieveExportJobItemsDiagram />
</div>

Retrieving Export Job Items is the first step in the export item processing phase.

This step determines which Export Items must be processed, but does not include the accounting data itself.

## Prerequisites

Before you begin:

* You're familiar with the [Export Lifecycle](/docs/current/platform/exports/lifecycle) and the [Integration Design for Fetching Export Job Items](/docs/current/integration-design/exports/integration-design-exports-fetch-export-items-control-layer)
* The [Export Job has been started](/docs/current/how-tos/accounting-integrations/how-to-detect-and-start-export-jobs-for-as-erp-processing) (`"event": "started"`, `"status": "in_progress"`)
* [Pre-export validation has completed](/docs/current/how-tos/accounting-integrations/how-to-perform-pre-export-validation-for-as-erp-processing) and the integration is ready to begin processing data
* The Export `jobId` is available

## Steps (Control Layer)

### 1. Retrieve Export Items for the Job

**API Endpoint**: GET [/v3/export-jobs/`{jobId}`/items](/reference/export-api/export-api-v3/get-export-job-items)

**Example parameters:** jobId: `8eb648ab-464b-42a0-BA17-eda703657e33`

Returns control data:

* accountingEntryId
* status (pending, in\_progress, etc.)
* export tracking fields

This endpoint is used to:

* determine processing scope
* track progress
* recover from interruptions

#### Example Request

<Tabs>
  <Tab title="OAuth 2.0">
    ```bash theme={null}
          curl --request GET \
          --url https://external.staging.pleo.io/v3/export-jobs/8eb648ab-464b-42a0-BA17-eda703657e33/items \
          --header 'Authorization: Bearer <token>'
    ```
  </Tab>

  <Tab title="API Key">
    ```bash theme={null}
      curl --request GET \
      -u "pls_1ab2cd3e4f5g6h7a89b012c34de56f78_gabc90:" \
      -H "Accept: application/json;charset=UTF-8" \
      "https://external.staging.pleo.io/v3/export-jobs/8eb648ab-464b-42a0-BA17-eda703657e33/items" \
      | jq
    ```
  </Tab>
</Tabs>

#### Example Response

Each Export Item represents a single accounting entry to be processed.

<RememberCallout title="Remember">
  The Export Job is `in_progress`, but each Export Item remains in `pending` until it has been processed by the integration.
</RememberCallout>

```json theme={null}
{
  "data": [
    {
      "exportJobId": "8eb648ab-464b-42a0-ba17-eda703657e33",
      "accountingEntryId": "59540ed2-0d68-4e36-9e31-58223975d9e9",
      "status": "pending",
      "externalId": null,
      "externalUrl": null,
      "failureReasonType": null,
      "failureReason": null,
      "exportedAt": null
    },
    {
      "exportJobId": "8eb648ab-464b-42a0-ba17-eda703657e33",
      "accountingEntryId": "6678bcee-c6a4-4b49-bb1e-8f9fd653d16c",
      "status": "pending",
      "externalId": null,
      "externalUrl": null,
      "failureReasonType": null,
      "failureReason": null,
      "exportedAt": null
    },
    {
      "exportJobId": "8eb648ab-464b-42a0-ba17-eda703657e33",
      "accountingEntryId": "9ea2ef81-4d73-460d-bbb4-ccf3da6f6f61",
      "status": "pending",
      "externalId": null,
      "externalUrl": null,
      "failureReasonType": null,
      "failureReason": null,
      "exportedAt": null
    },
    {
      "exportJobId": "8eb648ab-464b-42a0-ba17-eda703657e33",
      "accountingEntryId": "0c76ea71-aaaa-4ece-bb68-e1166ccaea04",
      "status": "pending",
      "externalId": null,
      "externalUrl": null,
      "failureReasonType": null,
      "failureReason": null,
      "exportedAt": null
    }
  ],
  "pagination": {
    "hasPreviousPage": false,
    "hasNextPage": false,
    "currentRequestPagination": {
      "sortingKeys": [],
      "sortingOrder": [],
      "parameters": {
        "jobId": [
          "8eb648ab-464b-42a0-ba17-eda703657e33"
        ]
      }
    },
    "startCursor": "AAAAAADJ3YT4YKWVVLYA=AFRDZIJCOBE2JLCIOQDPOKFVZY",
    "endCursor": "AAAAAADJ3YT4YKWTT6AA=4BWF5U5TLFGLNFMGIBLKZSXGGU",
    "total": 4
  }
}

```

### 2. Handle Pagination

Export Items may be returned across multiple pages.

<RememberCallout title="Remember">
  Always retrieve all pages before beginning processing to avoid partial exports.
</RememberCallout>

#### Example Response (Pagination)

```json theme={null}
"pagination": {
  "hasNextPage": true,
  "endCursor": "<string>"
}
```

**Example Pseudo:**

```pseudo theme={null}
items = []

do:
    response = fetchItems(cursor)
    items.append(response.data)
    cursor = response.pagination.endCursor
while response.pagination.hasNextPage
```

### 3. Handle Job Recovery

This step only applies if your integration is restarting after an interruption. In normal operation, skip to Step 4.

If your integration restarts or loses state, it must be able to resume processing safely.

#### 3.1. (Optional) Retrieve Export Job Metadata

This step is optional. If your integration already tracks job state, it can be skipped.

**API Endpoint**: GET [/v3/export-jobs/`{jobId}`](/reference/export-api/export-api-v3/get-an-export-job)

This endpoint can be used to rehydrate job-level context.

##### Example Request

<Tabs>
  <Tab title="OAuth 2.0">
    ```bash theme={null}
    curl -X GET " https://external.staging.pleo.io/v3/export-jobs/8eb648ab-464b-42a0-ba17-eda703657e33" \
      -H "Authorization: Bearer <access_token>"
    ```
  </Tab>

  <Tab title="API Key">
    ```bash theme={null}
      curl --request GET \
      -u "pls_1ab2cd3e4f5g6h7a89b012c34de56f78_gabc90:" \
      -H "Accept: application/json;charset=UTF-8" \
      "https://external.staging.pleo.io/v3/export-jobs/8eb648ab-464b-42a0-ba17-eda703657e33" \
      | jq
    ```
  </Tab>
</Tabs>

#### 3.2. Resume Processing from Export Items

If processing resumes after interruption:

* The Export Job is already `in_progress`
* Some Export Items may already have updated statuses

Your integration should:

1. Re-fetch all Export Items
2. Determine which items still require processing
3. Continue from the last known state

**Example Pseudo:**

```pseudo theme={null}
itemsToProcess = filter items where status == "pending"
```

This ensures the export workflow is resumable and idempotent.

### 4. Store Items for Processing

Persist Export Items for the processing phase.

Store only what is necessary:

* `accountingEntryId` (unique ID for the export item)
* `jobId` (unique job reference of the Export Job)
* `status` (status of the export item)

**Example Pseudo:**

```pseudo theme={null}
for item in items:
    queue.push(item)
```

### 5. Maintain Deterministic Processing Order

Process Export Items in a stable and predictable order.

Recommended strategies:

* chronological order (by transaction date)
* consistent ordering across retries

<NoteCallout title="Note">
  Deterministic ordering improves reconciliation and debugging.
</NoteCallout>

## Result

After completing these steps:

* All Export Items for the job have been retrieved
* Pagination has been fully resolved
* The workflow remains resumable and consistent
* The integration does not yet have the payload of each expense item

***

## What Comes Next?

Now that you have identified which items to process, retrieve their full accounting data.

<WhatComesNext href="/docs/current/how-tos/accounting-integrations/how-to-fetch-export-item-data-for-as-erp-processing">
  How to Fetch Export Item Data for Processing
</WhatComesNext>

***

<div className="text-xs uppercase" style={{ fontVariant: 'small-caps' }}>
  this how-to is part of:
</div>

<div className="mt-4 flex flex-wrap gap-2">
  <a
    href="/docs/current/guides/export-integration-workflow-guide"
    className="inline-flex items-center rounded-full border border-gray-300 dark:border-gray-600
px-3 py-1 text-xs font-medium
bg-white dark:bg-[#1f262b] text-black dark:text-white
hover:bg-gray-100 dark:hover:bg-[#2b2f33]
transition-colors"
  >
    Export Integration Workflow Guide
  </a>
</div>

***

## Related Reading

* [Export Lifecycle](/docs/current/platform/exports/lifecycle)
* [Connection and Authorisation Overview](/docs/current/integration-design/auth/integration-design-auth-overview)

***
