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

# Extract Document Pages

> Extract specific pages from a document (PDF, PowerPoint, or Word) as base64-encoded images or URLs.
When output_format="url", pages that fail URL generation fall back to base64 data URIs (mixed output possible).



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/morphik/openapi.documented.yml post /documents/pages
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security: []
paths:
  /documents/pages:
    post:
      tags:
        - Documents
      summary: Extract Document Pages
      description: >-
        Extract specific pages from a document (PDF, PowerPoint, or Word) as
        base64-encoded images or URLs.

        When output_format="url", pages that fail URL generation fall back to
        base64 data URIs (mixed output possible).
      operationId: extract_document_pages_documents_pages_post
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentPagesRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentPagesResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Morphik from 'morphik';

            const client = new Morphik({
              apiKey: process.env['MORPHIK_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.documents.pages({
              document_id: 'document_id',
              end_page: 1,
              start_page: 1,
            });

            console.log(response.document_id);
        - lang: cURL
          source: |-
            curl https://api.morphik.ai/documents/pages \
                -H 'Content-Type: application/json' \
                -H "Authorization: Bearer $MORPHIK_API_KEY" \
                -d '{
                      "document_id": "document_id",
                      "end_page": 1,
                      "start_page": 1
                    }'
components:
  schemas:
    DocumentPagesRequest:
      properties:
        document_id:
          type: string
          title: Document Id
          description: ID of the document to extract pages from
        start_page:
          type: integer
          minimum: 1
          title: Start Page
          description: Starting page number (1-indexed)
        end_page:
          type: integer
          minimum: 1
          title: End Page
          description: Ending page number (1-indexed)
        output_format:
          anyOf:
            - type: string
              enum:
                - base64
                - url
            - type: 'null'
          title: Output Format
          description: 'How to return page images: base64 (default) or url'
          default: base64
      type: object
      required:
        - document_id
        - start_page
        - end_page
      title: DocumentPagesRequest
      description: Request model for extracting pages from a document
    DocumentPagesResponse:
      properties:
        document_id:
          type: string
          title: Document Id
        pages:
          items:
            type: string
          type: array
          title: Pages
        start_page:
          type: integer
          title: Start Page
        end_page:
          type: integer
          title: End Page
        total_pages:
          type: integer
          title: Total Pages
      type: object
      required:
        - document_id
        - pages
        - start_page
        - end_page
        - total_pages
      title: DocumentPagesResponse
      description: Response for document pages extraction endpoint
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````