Merge PDFs

Learn how to merge multiple PDF files into a single document.

Combining multiple PDF files into a single document is a common requirement in many business processes. The Scan Documents API provides a simple way to merge multiple PDFs into one.

Business Problem

Imagine you are a sales representative preparing a proposal for a client. You have several documents in PDF format: a cover letter, a project proposal, a pricing sheet, and a master services agreement. You want to combine all of these documents into a single, professional-looking PDF to send to the client.

Solution

We can solve this problem byusing the merge operation in the Scan Documents API. Here’s how:

  1. Upload the PDFs: First, you'll upload all the individual PDF files to the API.
  2. Merge the PDFs: Then, you'll use the merge operation to combine the uploaded PDFs into a single file.

Let's get started!

Step 1: Upload the PDFs

First, you need to upload each PDF file to the Scan Documents API.

Upload a File

Creates a new file

# Upload the cover letter
curl -X POST "https://api.scan-documents.com/v1/files" \
  -H "x-api-key: YOUR_API_KEY" \
  -F name="Cover Letter" \
  -F file="@/path/to/your/cover-letter.pdf"

The API will respond with a file object. Here is an example:

{
  "id": "file_euyrvozb9302uwhq",
  "name": "Cover Letter",
  "type": "application/pdf",
  "properties": {
    "size": 120000,
    "page_count": 1
  },
  "task_id": null,
  "created_at": "2025-08-20T10:20:00.000Z"
}

You'll need to upload all other documents similarly. Take note of the file IDs from each response, as you'll need them for the next step.

Step 2: Merge the PDFs

Now that you have uploaded all your PDFs, you can use the merge operation to combine them into a single file. You will need to provide the file IDs of the PDFs in the order you want them to appear in the final document.

Merge PDFs

Creates a task to merge multiple PDF files into a single document.

curl -X POST "https://api.scan-documents.com/v1/pdf-operations/merge" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Client Proposal.pdf",
    "input": [
      "file_euyrvozb9302uwhq",
      "file_euyrvozb9302uwhr",
      "file_euyrvozb9302uwhs",
      "file_euyrvozb9302uwht"
    ]
  }'

The result of this task will be a new PDF file containing all the merged documents.

{
  "id": "task_euyrvozb9302uwhu",
  "operation": "merge",
  "status": "completed",
  "parameters": {
    "name": "Client Proposal.pdf",
    "input": [
      "file_euyrvozb9302uwhq",
      "file_euyrvozb9302uwhr",
      "file_euyrvozb9302uwhs",
      "file_euyrvozb9302uwht"
    ]
  },
  "result": {
    "generated_files": [
      {
        "id": "file_euyrvozb9302uwhv",
        "name": "Client Proposal.pdf",
        "type": "application/pdf",
        "properties": {
          "size": 1536000,
          "page_count": 10
        },
        "task_id": "task_euyrvozb9302uwhu",
        "created_at": "2025-08-20T10:25:00.000Z"
      }
    ]
  },
  "callback_url": null,
  "created_at": "2025-08-20T10:24:00.000Z",
  "updated_at": "2025-08-20T10:25:00.000Z"
}

You can now download the final, merged PDF using the /v1/files/{id}/download endpoint. This single, organized document is now ready to be sent to your client.