> ## Documentation Index
> Fetch the complete documentation index at: https://pdfbase.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Merge PDFs

> Combine multiple PDFs into a single document.

## Phase

**Phase 2** — Ships after launch, only if there's customer demand.

## Request

<ParamField body="sources" type="array" required>
  Ordered list of PDFs to merge. Each source can be:

  * A PDFBase PDF ID: `{ "pdf_id": "pdf_abc123" }`
  * A URL to a PDF: `{ "url": "https://example.com/doc.pdf" }`
  * A base64-encoded PDF: `{ "base64": "JVBERi0x..." }`

  Min: 2 sources. Max: 50 sources.
</ParamField>

<ParamField body="page_ranges" type="array">
  Optional per-source page selection. Same length as `sources`. Each entry is a string like `"1-3,5,8-10"` or `null` for all pages.
</ParamField>

<ParamField body="output" type="string" default="url">
  `url` or `base64`.
</ParamField>

<ParamField body="compress" type="string" default="none">
  Compression for the merged output.
</ParamField>

<ParamField body="metadata" type="object">
  Metadata for the merged PDF.
</ParamField>

## Response

```json theme={null}
{
  "id": "pdf_merged1",
  "object": "pdf",
  "status": "completed",
  "url": "https://files.pdfbase.dev/pdf_merged1.pdf?token=sig_abc",
  "pages": 15,
  "bytes": 890000,
  "source_count": 3,
  "created_at": "2026-05-19T12:00:00Z",
  "expires_at": "2026-05-20T12:00:00Z",
  "render_time_ms": 420
}
```

## Example

```bash theme={null}
curl -X POST https://api.pdfbase.dev/v1/pdfs/merge \
  -H "Authorization: Bearer pk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "sources": [
      { "pdf_id": "pdf_cover" },
      { "pdf_id": "pdf_report" },
      { "url": "https://legal.example.com/terms.pdf" }
    ],
    "page_ranges": [null, "1-5", null],
    "compress": "medium",
    "output": "url"
  }'
```
