---
title: "Merge documents"
url: "https://docs.signnow.com/docs/document/operations/document-merge"
type: "endpoint"
section: "document"
slug: "document/operations/document-merge"
method: "POST"
path: "/document/merge"
operation_id: "document-merge"
authorization: "bearer"
---

# Merge documents

`POST /document/merge`

This endpoint allows API users to merge existing documents into one.

## Authorization

bearer

## Request Body

**Schema**

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "the name of the merged document"
    },
    "document_ids": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "IDs of the documents to be merged"
    },
    "upload_document": {
      "type": "boolean",
      "default": false,
      "description": "If false returns the merged document without further uploading into documents list.\nIf true returns the merged document id with further uploading into documents list."
    }
  }
}
```

**Example** (`application/json`)

```json
{
  "name": "the merged doc",
  "document_ids": [
    "b69005888401f96c005c8e99da236adbad846ce2",
    "83ef79b710c27fbfd9b529a5e1efd89ac908af6c"
  ],
  "upload_document": false
}
```

## Responses

### 200

If `upload_document` is `true`, the ID of the merged document. If `upload_document` is `false` or not set, the merged PDF file.

**Example** (`Successful response`)

```json
{
  "document_id": "9b4e36781745eb345d3148f33e6ff021a1a0a81b"
}
```

### 400

* Wrong, expired, or missing token.
* `document_ids` is missing or empty.
* `document_ids` has more than `50` IDs.
* One or more documents don't exist.
* One or more documents belong to another user.
* `name` is longer than `255` characters.
* `upload_document` isn't `true` or `false`.

**Example** (`Wrong token`)

```json
{
  "code": 1537,
  "error": "invalid_token"
}
```

**Example** (`No documents`)

```json
{
  "errors": [
    {
      "code": 65536,
      "message": "Required at least one document"
    }
  ]
}
```

**Example** (`Name too long`)

```json
{
  "errors": [
    {
      "code": 65582,
      "message": "Document name too long. Max size is 255 symbols"
    }
  ]
}
```

**Example** (`Not the owner`)

```json
{
  "errors": [
    {
      "code": 65610,
      "message": "Access denied for 83ef79b710c27fbfd9b529a5e1efd89ac908af6c"
    }
  ]
}
```

**Example** (`Document not found`)

```json
{
  "errors": [
    {
      "code": 65582,
      "message": "Some documents not found"
    }
  ]
}
```

**Example** (`Too many documents`)

```json
{
  "errors": [
    {
      "code": 65536,
      "message": "Max limit of documents - 50"
    }
  ]
}
```

**Example** (`Wrong upload_document`)

```json
{
  "errors": [
    {
      "code": 65582,
      "message": "The upload document field must be true or false."
    }
  ]
}
```

## Code Examples

> Replace `$SIGNNOW_ACCESS_TOKEN` and any `{placeholder}` values before running.

### cURL

```bash
curl -X POST \
  "https://api.signnow.com/document/merge" \
  -H "Authorization: Bearer $SIGNNOW_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "the merged doc", "document_ids": ["b69005888401f96c005c8e99da236adbad846ce2", "83ef79b710c27fbfd9b529a5e1efd89ac908af6c"], "upload_document": false}'
```

---
*Full reference: https://docs.signnow.com/docs/document/operations/document-merge*
