This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dws-processor/tools-and-api/pdf-merge-api.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. PDF merge API

Use the PDF merge API to combine multiple PDF documents into a single output file. The /build endpoint handles the merge operation. Add each input PDF as a parts item, and Nutrient DWS Processor API assembles the output in the same order.

For signup, pricing, and task-level examples, refer to the merge PDF API task page.

Merge multiple PDFs

The following example merges two PDF files, first_half.pdf and second_half.pdf, into a single result.pdf. The order of the parts array controls the order of the documents in the merged PDF:

curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer your_api_key_here" \
-o result.pdf \
--fail \
-F first_half=@first_half.pdf \
-F second_half=@second_half.pdf \
-F instructions='{
"parts": [
{
"file": "first_half"
},
{
"file": "second_half"
}
]
}'

Merge PDFs from URLs

For remotely hosted source files, send a JSON request and pass each file URL in parts[].file.url. Use this instructions object:

{
"parts": [
{
"file": {
"url": "https://example.com/cover.pdf"
}
},
{
"file": {
"url": "https://example.com/body.pdf"
}
},
{
"file": {
"url": "https://example.com/appendix.pdf"
}
}
]
}

Shell

Run this request to merge PDFs from URLs:

Terminal window
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"parts": [
{ "file": { "url": "https://example.com/cover.pdf" } },
{ "file": { "url": "https://example.com/body.pdf" } },
{ "file": { "url": "https://example.com/appendix.pdf" } }
]
}' \
-o result.pdf

Merge selected page ranges

You can merge selected pages from one or more source PDFs by adding a pages object to a part. Page indexes are zero-based, and negative numbers count from the end of the document. For example, 0 is the first page, and -1 is the last page.

The following example creates a packet from the first three pages of document.pdf, followed by the full appendix.pdf file:

{
"parts": [
{
"file": "document",
"pages": {
"start": 0,
"end": 2
}
},
{
"file": "appendix"
}
]
}

Reorder pages while merging

You can reference the same input file more than once to reorder or duplicate page ranges in the output. The following example places the last page first, followed by the rest of the document:

{
"parts": [
{
"file": "document",
"pages": {
"start": -1,
"end": -1
}
},
{
"file": "document",
"pages": {
"start": 0,
"end": -2
}
}
]
}

Merge password-protected PDFs

If an input PDF is password-protected, include the password on the corresponding part. Use this instructions object:

{
"parts": [
{
"file": "protected_document",
"password": "document-password"
},
{
"file": "appendix"
}
]
}

Nutrient DWS Processor API uses passwords only to open source documents for processing. To set a password on the merged output, configure output.user_password, output.owner_password, and output.user_permissions.

Combine merging with other actions

The /build endpoint can merge documents and then apply additional actions to the assembled PDF. Actions run after Nutrient DWS Processor API combines the parts.

The following example merges two PDFs and then adds a watermark to the merged output:

{
"parts": [
{ "file": "first_half" },
{ "file": "second_half" }
],
"actions": [
{
"type": "watermark",
"text": "CONFIDENTIAL",
"width": "50%",
"height": "20%",
"opacity": 0.3,
"rotation": 45
}
]
}

For workflows that include signing, apply all merge, page-range, rotation, watermarking, and flattening operations before signing the final PDF.

Reference

A PDF merge request uses the Build API parts array. Each part represents an input document or a selected page range from an input document:

type FilePart = {
// Multipart field name, or a remote URL object.
file: string | { url: string },
// Optional password for encrypted input PDFs.
password?: string,
// Optional page range. Page indexes are zero-based.
// Negative values count from the end of the document.
pages?: {
start?: number,
end?: number,
},
};
type BuildInstructions = {
parts: FilePart[],
actions?: BuildAction[],
output?: {
type?: "pdf",
},
};
  • Refer to the build document endpoint API reference for merging PDFs, selecting page ranges, and applying follow-up actions in a single request.