---
title: "Merge PDF server-side — Combine multiple PDFs | Nutrient"
canonical_url: "https://www.nutrient.io/guides/document-engine/editor/merge-or-combine/"
md_url: "https://www.nutrient.io/guides/document-engine/editor/merge-or-combine.md"
last_updated: "2026-05-15T19:10:04.960Z"
description: "Learn how to merge multiple files using the Document Engine's /api/build endpoint to create comprehensive documents with cover pages."
---

# Merge multiple PDF files

Document Engine lets you merge multiple files together by sending requests to the `/api/build` endpoint. This is useful when you want to concatenate multiple documents and create a large document or add cover pages to an existing document.

- Ensure [Document Engine is up and running](https://www.nutrient.io/sdk/document-engine/getting-started.md).

- Send a [multipart POST request](https://www.baeldung.com/postman-form-data-raw-x-www-form-urlencoded) with [instructions](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API) to Document Engine’s `/api/build` endpoint.

For more information, refer to the [API reference](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API) to learn about the `/api/build` endpoint and all the actions you can perform on PDFs with Document Engine.

For an overview of multipart requests, refer to the [brief tour of multipart requests](https://www.nutrient.io/blog/a-brief-tour-of-multipart-requests/) blog post.









## Merging a Document into a File on Disk

Send a multipart request to the [`/api/build` endpoint](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Document-Editing/operation/build-document), attaching an input file and the `instructions` JSON. This example will add a cover page to the document in the request by merging both documents together. Note that the order of the `parts` in the `instructions` corresponds to the order each part of the document will appear in in the final combined PDF after merging is complete.

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -F document=@/path/to/document.pdf \
  -F cover=@/path/to/cover.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "cover"
    },
    {
      "file": "document"
    }
  ]
}' \
  -o result.pdf

```

### HTTP

```http

POST /api/build HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="document"; filename="document.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="cover"; filename="cover.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "file": "cover"
    },
    {
      "file": "document"
    }
  ]
}
--customboundary--

```

## Merging a Document into a File from a URL

Send a request to the [`/api/build` endpoint](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Document-Editing/operation/build-document), attaching a URL pointing to an input file and the `instructions` JSON:

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F cover=@/path/to/cover.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "cover"
    },
    {
      "file": {
        "url": "https://pspdfkit.com/downloads/examples/paper.pdf"
      }
    }
  ]
}' \
  -o result.pdf

```

### HTTP

```http

POST /api/build HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token=<API token>

--customboundary
Content-Disposition: form-data; name="cover"; filename="cover.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "file": "cover"
    },
    {
      "file": {
        "url": "https://pspdfkit.com/downloads/examples/paper.pdf"
      }
    }
  ]
}
--customboundary--

```

The code above adds a cover page to the document downloaded from the URL.
---

## Related pages

- [Add pages to PDFs](/guides/document-engine/editor/add-page.md)
- [Changing PDF page numbers or labels](/guides/document-engine/editor/page-label.md)
- [Document processing and editing server](/guides/document-engine/editor.md)
- [Architecture diagram](/guides/document-engine/editor/architecture-diagram.md)
- [Add watermarks to PDFs](/guides/document-engine/editor/watermark.md)
- [Password protect PDFs](/guides/document-engine/editor/password-pdfs.md)

