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

# Create PDF

> Renders a URL or HTML to PDF, with paper size, orientation, margins, page ranges and header/footer templates.
## Token Cost
Base cost: **1 token**

Additional costs:
- Anti-Bot Mode: +1 token



## OpenAPI

````yaml https://api.snapopa.com/specs post /pdf
openapi: 3.1.0
info:
  title: Snapopa API
  version: 1.0.0
  description: >-
    High-performance API for website screenshots, screen recording, PDFs, and
    metadata extraction. Built for developers, marketers, and enterprises who
    need reliable, scalable capture solutions.
  termsOfService: https://snapopa.com/terms
  contact:
    name: Snapopa Support
    url: https://snapopa.com
    email: hello@snapopa.com
  license:
    name: Proprietary
    url: https://snapopa.com/terms
servers:
  - url: https://api.snapopa.com
    description: Production API
security:
  - bearerAuth: []
tags:
  - name: Capture
    description: >-
      Create and manage website screenshots, PDFs, and screen recordings.
      Supports caching, persistence, and custom viewport configurations.
    externalDocs:
      description: Capture API Guide
      url: https://docs.snapopa.com/capture/overview
  - name: System
    description: Health checks and system status monitoring endpoints
externalDocs:
  description: Full API Documentation
  url: https://docs.snapopa.com
paths:
  /pdf:
    post:
      tags:
        - Capture
      summary: Create PDF
      description: >-
        Renders a URL or HTML to PDF, with paper size, orientation, margins,
        page ranges and header/footer templates.

        ## Token Cost

        Base cost: **1 token**


        Additional costs:

        - Anti-Bot Mode: +1 token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  maxLength: 2048
                  format: uri
                  description: URL to capture
                html:
                  type: string
                  maxLength: 1048576
                  description: >-
                    Raw or base64-encoded HTML to render. Mutually exclusive
                    with url.
                responseType:
                  type: string
                  enum:
                    - json
                    - file
                  default: json
                  description: Return JSON metadata or the raw file.
                responseCache:
                  type: object
                  properties:
                    enabled:
                      type: boolean
                      default: false
                      description: >-
                        Return a cached result if available instead of
                        generating a fresh capture.
                    ttl:
                      type: integer
                      minimum: 60
                      exclusiveMinimum: true
                      maximum: 2592000
                      default: 86400
                      description: Cache lifetime in seconds.
                    nonce:
                      type: string
                      maxLength: 32
                      default: ''
                      description: >-
                        Random string to bust the cache key when stale results
                        should be skipped.
                  default:
                    enabled: false
                    ttl: 86400
                    nonce: ''
                  description: Reuse cached results to avoid duplicate captures.
                colorScheme:
                  type: string
                  enum:
                    - light
                    - dark
                    - no-preference
                  default: light
                  description: Browser prefers-color-scheme value.
                cdnTtl:
                  type: integer
                  minimum: 60
                  exclusiveMinimum: true
                  maximum: 2592000
                  default: 86400
                  description: >-
                    CDN storage lifetime in seconds. Ignored when persistence is
                    enabled.
                async:
                  type: boolean
                  default: false
                  description: Process in the background and return immediately.
                timeout:
                  type: integer
                  minimum: 5000
                  maximum: 120000
                  default: 30000
                  description: Navigation timeout in milliseconds.
                waitUntil:
                  type: string
                  enum:
                    - load
                    - domcontentloaded
                    - networkidle
                    - commit
                  default: load
                  description: Page load state to wait for before capturing.
                imageLoadTimeout:
                  type: integer
                  minimum: 0
                  maximum: 15000
                  default: 5000
                  description: >-
                    Max time in milliseconds to wait for images to load. Returns
                    early if all images load sooner.
                delay:
                  type: integer
                  minimum: 0
                  maximum: 15000
                  default: 0
                  description: >-
                    Extra wait in milliseconds after page load before capturing.
                    Useful for animations or delayed content.
                antiBot:
                  type: boolean
                  default: false
                  description: Use stealth providers to bypass bot detection.
                block:
                  type: object
                  properties:
                    ads:
                      type: boolean
                      default: true
                      description: Block ad networks and ad-related requests.
                    trackers:
                      type: boolean
                      default: true
                      description: Block analytics and tracking scripts.
                    cookies:
                      type: boolean
                      default: true
                      description: Hide cookie consent and GDPR banners (CSS-only).
                    popups:
                      type: boolean
                      default: false
                      description: Hide newsletter and promo popups (CSS-only).
                    media:
                      type: boolean
                      default: false
                      description: >-
                        Block images, videos, and fonts. Will affect screenshot
                        visuals.
                  default:
                    ads: true
                    trackers: true
                    cookies: true
                    popups: false
                    media: false
                  description: Block ads, trackers, and media to speed up captures.
                paper:
                  type: string
                  enum:
                    - A3
                    - A4
                    - A5
                    - Letter
                    - Legal
                    - Tabloid
                  default: A4
                  description: 'Paper size. One of: A3, A4, A5, Letter, Legal, Tabloid.'
                landscape:
                  type: boolean
                  default: false
                  description: Landscape orientation.
                printBackground:
                  type: boolean
                  default: true
                  description: Print background colors and images.
                scale:
                  type: number
                  minimum: 0.1
                  maximum: 2
                  default: 1
                  description: Rendering scale of the page content.
                margin:
                  type: object
                  properties:
                    top:
                      type: string
                      pattern: ^(0|\d+(\.\d+)?(px|in|cm|mm))$
                      default: '0'
                      description: Top margin as a CSS length (px, in, cm, mm).
                    right:
                      type: string
                      pattern: ^(0|\d+(\.\d+)?(px|in|cm|mm))$
                      default: '0'
                      description: Right margin as a CSS length (px, in, cm, mm).
                    bottom:
                      type: string
                      pattern: ^(0|\d+(\.\d+)?(px|in|cm|mm))$
                      default: '0'
                      description: Bottom margin as a CSS length (px, in, cm, mm).
                    left:
                      type: string
                      pattern: ^(0|\d+(\.\d+)?(px|in|cm|mm))$
                      default: '0'
                      description: Left margin as a CSS length (px, in, cm, mm).
                  default:
                    top: '0'
                    right: '0'
                    bottom: '0'
                    left: '0'
                  description: Page margins.
                pageRanges:
                  type: string
                  maxLength: 100
                  pattern: ^\s*\d+(\s*-\s*\d+)?(\s*,\s*\d+(\s*-\s*\d+)?)*\s*$
                  description: Pages to include, e.g. "1-5, 8". Defaults to all pages.
                headerTemplate:
                  type: string
                  maxLength: 8192
                  description: >-
                    HTML for the page header. Supports the classes date, title,
                    url, pageNumber and totalPages.
                footerTemplate:
                  type: string
                  maxLength: 8192
                  description: >-
                    HTML for the page footer. Supports the classes date, title,
                    url, pageNumber and totalPages.
              additionalProperties: false
            examples:
              basic:
                summary: A4 PDF
                value:
                  url: https://example.com
              letterWithFooter:
                summary: Letter, landscape, page numbers in the footer
                value:
                  url: https://example.com
                  paper: Letter
                  landscape: true
                  margin:
                    top: 15mm
                    bottom: 15mm
                    left: 10mm
                    right: 10mm
                  footerTemplate: >-
                    <div
                    style="font-size:9px;width:100%;text-align:center"><span
                    class="pageNumber"></span> / <span
                    class="totalPages"></span></div>
      responses:
        '200':
          description: Capture created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  error:
                    nullable: true
                  data:
                    type: object
                    properties:
                      uuid:
                        type: string
                        format: uuid
                      fileUrl:
                        type: string
                        format: uri
                        description: URL of the final capture file
                      fromCache:
                        type: boolean
                        description: Whether the response was served from cache
                      tokenCost:
                        type: integer
                        description: >-
                          Number of tokens consumed (0 for cache hits, 1+ for
                          fresh captures)
                      processingTimeMs:
                        type: integer
                        description: Time taken to process the capture in milliseconds
                      metadata:
                        type: object
                        properties:
                          url:
                            type: string
                            description: The original URL that was captured
                          capturedAt:
                            type: string
                            format: date-time
                            description: ISO 8601 timestamp when the capture was created
                          format:
                            type: string
                            description: File format (png, jpeg, webp, pdf)
                          mimeType:
                            type: string
                            description: MIME type of the capture file
                          fileSizeBytes:
                            type: integer
                            description: Size of the capture file in bytes
                          viewport:
                            type: object
                            properties:
                              width:
                                type: integer
                                description: Viewport width used for capture
                              height:
                                type: integer
                                description: Viewport height used for capture
                            required:
                              - width
                              - height
                            description: Viewport dimensions used for capture
                          fullPage:
                            type: boolean
                            description: Whether full page screenshot was captured
                          expiresAt:
                            type: string
                            format: date-time
                            description: >-
                              ISO 8601 timestamp when CDN storage expires (temp
                              captures only)
                        required:
                          - url
                          - capturedAt
                          - format
                          - mimeType
                          - fileSizeBytes
                          - viewport
                          - fullPage
                    required:
                      - uuid
                      - fileUrl
                      - fromCache
                      - tokenCost
                      - processingTimeMs
                      - metadata
                required:
                  - success
                  - error
                  - data
            application/pdf:
              schema:
                type: string
                format: binary
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                  data:
                    nullable: true
                required:
                  - success
                  - error
                  - data
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                  data:
                    nullable: true
                required:
                  - success
                  - error
                  - data
        '402':
          description: Payment Required - Quota exceeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                  data:
                    nullable: true
                required:
                  - success
                  - error
                  - data
        '429':
          description: Too Many Requests - Rate limit exceeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                  data:
                    nullable: true
                required:
                  - success
                  - error
                  - data
        '500':
          description: Internal Server Error - Capture failed
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                  data:
                    nullable: true
                required:
                  - success
                  - error
                  - data
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication. Get your API key at
        https://snapopa.com/dashboard
      bearerFormat: API Key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.