---
title: "Extract pages from a PDF file"
method: POST
path: "/v1/pdf-operations/extract-pages"
tags: ["PDF Operations"]
---

# Extract pages from a PDF file

`POST /v1/pdf-operations/extract-pages`

Creates a task to extract specific pages from a PDF file into a new PDF file.

## Request body

- object
  - `input` string, required — The id of the file or task to operate on.
  - `name` string — The name of the file
  - `pages` string, required — Page range (e.g., 2-7), a comma-separated list (e.g., 2,3,7) of pages.
  - `callback_url` string, uri — The URL to call when the task is completed or failed. If you want to receive events, you probably prefer to use `webhooks` instead.

## Response `201`

Task created successfully. Returns the task details.

- union — The response of an extract task
  - object
    - `id` string, required — The unique identifier for the task.
    - `operation` 'extract-pages', required — The type of operation being performed by the task.
    - `parameters` object, required
      - `input` string, required — The id of the file or task to operate on.
      - `name` string — The name of the file
      - `pages` string, required — Page range (e.g., 2-7), a comma-separated list (e.g., 2,3,7) of pages.
      - `callback_url` string, uri — The URL to call when the task is completed or failed. If you want to receive events, you probably prefer to use `webhooks` instead.
    - `status` 'completed', required — The current status of the task.
    - `result` object, required
      - `generated_files` DocumentFromTaskResponse[], required
        - `id` string, required — The id of the file
        - `name` string, required — The name of the file
        - `task_id` string, required — The id of the task that generated this file
        - `created_at` string, required — The creation date of the file in ISO format
        - `type` 'application/pdf', required — The MIME type of the file
        - `properties` object, required
          - `size` number, required — The size of the document in bytes
          - `page_count` number, required — The number of pages in the document
    - `callback_url` string, nullable, required — The URL to which the task result will be sent upon completion or failure.
    - `created_at` string, required — The creation date of the task in ISO format.
    - `updated_at` string, required — The last update date of the task in ISO format.
  - object
    - `id` string, required — The unique identifier for the task.
    - `operation` 'extract-pages', required — The type of operation being performed by the task.
    - `parameters` object, required
      - `input` string, required — The id of the file or task to operate on.
      - `name` string — The name of the file
      - `pages` string, required — Page range (e.g., 2-7), a comma-separated list (e.g., 2,3,7) of pages.
      - `callback_url` string, uri — The URL to call when the task is completed or failed. If you want to receive events, you probably prefer to use `webhooks` instead.
    - `status` 'pending', required — The current status of the task.
    - `result` object, required
    - `callback_url` string, nullable, required — The URL to which the task result will be sent upon completion or failure.
    - `created_at` string, required — The creation date of the task in ISO format.
    - `updated_at` string, required — The last update date of the task in ISO format.
  - object
    - `id` string, required — The unique identifier for the task.
    - `operation` 'extract-pages', required — The type of operation being performed by the task.
    - `parameters` object, required
      - `input` string, required — The id of the file or task to operate on.
      - `name` string — The name of the file
      - `pages` string, required — Page range (e.g., 2-7), a comma-separated list (e.g., 2,3,7) of pages.
      - `callback_url` string, uri — The URL to call when the task is completed or failed. If you want to receive events, you probably prefer to use `webhooks` instead.
    - `status` 'processing', required — The current status of the task.
    - `result` object, required
    - `callback_url` string, nullable, required — The URL to which the task result will be sent upon completion or failure.
    - `created_at` string, required — The creation date of the task in ISO format.
    - `updated_at` string, required — The last update date of the task in ISO format.
  - object
    - `id` string, required — The unique identifier for the task.
    - `operation` 'extract-pages', required — The type of operation being performed by the task.
    - `parameters` object, required
      - `input` string, required — The id of the file or task to operate on.
      - `name` string — The name of the file
      - `pages` string, required — Page range (e.g., 2-7), a comma-separated list (e.g., 2,3,7) of pages.
      - `callback_url` string, uri — The URL to call when the task is completed or failed. If you want to receive events, you probably prefer to use `webhooks` instead.
    - `status` 'failed', required — The current status of the task.
    - `result` object, required
      - `error` string, required
      - `details` object, required
    - `callback_url` string, nullable, required — The URL to which the task result will be sent upon completion or failure.
    - `created_at` string, required — The creation date of the task in ISO format.
    - `updated_at` string, required — The last update date of the task in ISO format.

## Other responses

- `404` — File not found. The specified file does not exist.
- `422` — Validation Error. The request body is invalid.
- `429` — Rate Limit Exceeded.
- `5XX` — Internal Server Error.

## Changes

- **2025-06-24** `42f9aa9c3b27` — 4 breaking, 10 info
  - the `oneOf[subschema #1: Completed extract-pages Task Response]/parameters/name` response property's maxLength was increased from `30` to `50` for the response status `201`
  - the `oneOf[subschema #2: Pending extract-pages Task Response]/parameters/name` response property's maxLength was increased from `30` to `50` for the response status `201`
  - the `oneOf[subschema #3: Processing extract-pages Task Response]/parameters/name` response property's maxLength was increased from `30` to `50` for the response status `201`
  - the `oneOf[subschema #4: Failed extract-pages Task Response]/parameters/name` response property's maxLength was increased from `30` to `50` for the response status `201`
  - …10 more

[Change history](https://skmtc.dev/scan-documents/apis/scan-documents-api/changes/v1/pdf-operations/extract-pages/post.md)

---

[API](https://skmtc.dev/scan-documents/apis/scan-documents-api.md) · [All operations](https://skmtc.dev/scan-documents/apis/scan-documents-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/scan-documents/scan-documents-api/revisions/42f9aa9c3b27/schema)
