pending and has not yet been claimed by any integration.
Your integration must:
- Detect available Export Jobs
- Select the appropriate job to process
- Claim the job by marking it as
started
Prerequisites
Before you begin:- You’re familiar with the Export Lifecycle and the Integration Design for Detecting and Claiming Export Jobs
- Your integration is authenticated using one of the supported authentication methods
- Your integration can call Pleo’s Export API endpoints
- Webhooks or polling are configured
- Export Items have been queued in Pleo’s Web App
Steps
1. Detect Available Export Jobs
Detect new Export Jobs as they become available. Two discovery strategies are supported:Option A — Webhook Trigger (Recommended)
Subscribe to theexport-job.created webhook.
When the export-job.created event is received, proceed to step 2.
Option B — Polling
If webhooks are not supported, periodically request Export Jobs. Polling should run on a controlled schedule (for example, every few minutes). See step 2 for an example request.Option C — Ad Hoc Trigger (Optional)
If your integration supports user-initiated processing, expose a manual trigger that immediately runs the same polling logic as Option B. This option is used alongside scheduled polling — not instead of it. It allows users to check for pending Export Jobs on demand rather than waiting for the next scheduled interval. When the trigger fires, proceed to step 2.2. Filter Eligible Export Jobs
API Endpoint: GET /v3/export-jobs Example parameters: companyId:12abc3d4-e567-890e-1234-abc56e78fabc
Fetch Export Jobs from the API and filter for eligible statuses (pending and in_progress ) only.
Your integration must ignore:
failedjobscompletedjobscompleted_with_errorsjobs
Example Request
- OAuth 2.0
- API Key
Example Response
3. Select the Oldest Export Job
From the filtered results, always select the oldest eligible job. Never process jobs in parallel. Maintain a single export worker to guarantee sequential execution. Example Pseudo:4. Verify the Job Is Not Already Being Processed
API Endpoint: GET/v3/export-jobs/{jobId}
Example parameters: jobId: 8eb648ab-464b-42a0-ba17-eda703657e33
Before claiming the job, confirm another worker or integration instance has not already started processing it.
Example:
Example Request
- OAuth 2.0
- API Key
Example Response
5. Claim the Export Job
API Endpoint: POST/v3/export-job-events
Once verified, mark the Export Job event as started.
This signals to Pleo that your integration has taken responsibility for processing.
Example:
Example Request
- OAuth 2.0
- API Key
Example Response
If the request succeeds, rerunning the Step 4 curl command will return an updated job status ofin_progress.
6. Handle Claim Conflicts Safely
In distributed systems, multiple workers may attempt to claim the same job. If the API returns a422 INVALID_EXPORT_JOB_STATUS_CHANGE response, the job has already been claimed by another worker.
- Treat the response as expected behaviour
- Do not retry aggressively
- Fetch jobs again and continue normally
7. Process the Job in a Timely Manner
Export jobs expire afterexpiresIn seconds (e.g., 3600) since the last state-changing update (lastUpdatedAt).
To avoid expiration:
- Begin processing immediately after claiming the job
- Ensure progress is made before the expiry window elapses
- Update the job status as work progresses to refresh
lastUpdatedAt(e.g., move frompendingtoin_progress)
- The status moves to
expired - The job must be resubmitted from Pleo’s Web App
- A new job with a new
jobIdis added to the queue
Result
After completing these steps:- An Export Job has been safely detected
- The oldest eligible job has been selected
- Your integration has claimed responsibility for processing
- The export workflow can proceed
What Comes Next?
this how-to is part of: