---
title: "Move or rearrange PDF page server-side | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/document-engine/editor/page-manipulation/move-or-rearrange/"
md_url: "https://www.nutrient.io/guides/document-engine/editor/page-manipulation/move-or-rearrange.md"
last_updated: "2026-05-25T07:44:41.316Z"
description: "Learn how to move and reorder PDF pages using the Document Engine API. Follow our guide for simple instructions and examples."
---

# Move or rearrange PDF pages

Document Engine can move existing pages of a document. You can achieve this by sending a multipart request to the `/api/build` endpoint and attaching the input file(s) and the `instructions` JSON.

This guide shows examples of moving or rearranging PDF pages.

- 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.









## Reordering pages of a file on disk

You can rearrange pages of the same file, as well as pages from different files.

### Reordering pages of the same file

To switch places of the third page with the sixth page, send a multipart request with these inputs to the [`/api/build` endpoint](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Document-Editing/operation/build-document):

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F document=@/path/to/document.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "document",
      "pages": {
        "start": 0,
        "end": 1
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 5,
        "end": 5
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 3,
        "end": 4
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 2,
        "end": 2
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 6,
        "end": 7
      }
    }
  ]
}' \
  -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="document"; filename="document.pdf"
Content-Type: application/pdf

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

{
  "parts": [
    {
      "file": "document",
      "pages": {
        "start": 0,
        "end": 1
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 5,
        "end": 5
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 3,
        "end": 4
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 2,
        "end": 2
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 6,
        "end": 7
      }
    }
  ]
}
--customboundary--

```

### Reordering pages of different files

Use the code example below to create a new PDF document with the following content from two other documents, each with eight pages:

- First four pages of the first document

- Last four pages of the second document

- First four pages of the second document

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F document1=@/path/to/document1.pdf \
  -F document2=@/path/to/document2.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "document1",
      "pages": {
        "start": 0,
        "end": 3
      }
    },
    {
      "file": "document2",
      "pages": {
        "start": 4,
        "end": 7
      }
    },
    {
      "file": "document2",
      "pages": {
        "start": 0,
        "end": 3
      }
    }
  ]
}' \
  -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="document1"; filename="document1.pdf"
Content-Type: application/pdf

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

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

{
  "parts": [
    {
      "file": "document1",
      "pages": {
        "start": 0,
        "end": 3
      }
    },
    {
      "file": "document2",
      "pages": {
        "start": 4,
        "end": 7
      }
    },
    {
      "file": "document2",
      "pages": {
        "start": 0,
        "end": 3
      }
    }
  ]
}
--customboundary--

```

## Reordering pages of a file from a URL

To specify the file input with a URL, use the following code:

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F instructions='{
  "parts": [
    {
      "file": {
        "url": "http://pspdfkit.com/guides/processor/files/8-page-example-document.pdf"
      },
      "pages": {
        "start": 0,
        "end": 1
      }
    },
    {
      "file": {
        "url": "http://pspdfkit.com/guides/processor/files/8-page-example-document.pdf"
      },
      "pages": {
        "start": 5,
        "end": 5
      }
    },
    {
      "file": {
        "url": "http://pspdfkit.com/guides/processor/files/8-page-example-document.pdf"
      },
      "pages": {
        "start": 3,
        "end": 4
      }
    },
    {
      "file": {
        "url": "http://pspdfkit.com/guides/processor/files/8-page-example-document.pdf"
      },
      "pages": {
        "start": 2,
        "end": 2
      }
    },
    {
      "file": {
        "url": "http://pspdfkit.com/guides/processor/files/8-page-example-document.pdf"
      },
      "pages": {
        "start": 6,
        "end": 7
      }
    }
  ]
}' \
  -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="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "file": {
        "url": "http://pspdfkit.com/guides/processor/files/8-page-example-document.pdf"
      },
      "pages": {
        "start": 0,
        "end": 1
      }
    },
    {
      "file": {
        "url": "http://pspdfkit.com/guides/processor/files/8-page-example-document.pdf"
      },
      "pages": {
        "start": 5,
        "end": 5
      }
    },
    {
      "file": {
        "url": "http://pspdfkit.com/guides/processor/files/8-page-example-document.pdf"
      },
      "pages": {
        "start": 3,
        "end": 4
      }
    },
    {
      "file": {
        "url": "http://pspdfkit.com/guides/processor/files/8-page-example-document.pdf"
      },
      "pages": {
        "start": 2,
        "end": 2
      }
    },
    {
      "file": {
        "url": "http://pspdfkit.com/guides/processor/files/8-page-example-document.pdf"
      },
      "pages": {
        "start": 6,
        "end": 7
      }
    }
  ]
}
--customboundary--

```
---

## Related pages

- [Rotate PDF pages](/guides/document-engine/editor/page-manipulation/rotate.md)
- [Remove pages from PDFs](/guides/document-engine/editor/page-manipulation/remove.md)
- [Duplicate PDF pages](/guides/document-engine/editor/page-manipulation/duplicate.md)

