Skip to main content

Get links to output PDF files in the response when running in async mode

Get links to output PDF files in the response when running in async mode

For endpoints that generate multiple files, such as /v1/pdf/split, the initial async response contains a jobId and a url pointing to a JSON file that lists the output files.

To include the output links directly in the completed job response, set both "async": true and "inline": true in the initial request.

1. Start the async request

Send a POST request to https://api.pdf.co/v1/pdf/split. Include your API key in the x-api-key header and set Content-Type to application/json.

{
  "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-split/sample.pdf",
  "pages": "1-2,3-",
  "name": "result.pdf",
  "async": true,
  "inline": true
}

The response includes a job ID. Save it for the next step. The following response examples are illustrative; actual URLs and additional fields vary.

{
  "error": false,
  "jobId": "YOUR_JOB_ID",
  "url": "https://example.com/results/result.json"
}

2. Check the job status

Send a POST request to https://api.pdf.co/v1/job/check using the same API key and JSON content type. Pass the returned jobId in the lowercase jobid field:

{
  "jobid": "YOUR_JOB_ID"
}
  • working: Wait a few seconds, then check the same job again. Use a finite polling limit in your workflow.

  • success: Processing has finished. Retrieve the output links.

  • failed or aborted: Stop polling and review the response message.

3. Retrieve the output files

With inline: true in the initial split request, the completed job response includes the output URLs in body:

{
  "status": "success",
  "message": "Success",
  "jobId": "YOUR_JOB_ID",
  "body": [
    "https://example.com/results/result_page1-2.pdf",
    "https://example.com/results/result_page3-4.pdf"
  ]
}

Download each PDF from its URL. You can also read the JSON file at the original url after the job succeeds. An HTTP 200 from Job Check only means the status check succeeded; wait for the job status to be success before accessing the output.

Did this answer your question?