openapi: 3.0.0
servers:
  - description: Global endpoint (default).
    url: https://api.pdfblocks.com
  - description: European-only endpoint.
    url: https://eu.api.pdfblocks.com
info:
  contact:
    email: support@pdfblocks.com
    name: PDF Blocks Support
    url: https://www.pdfblocks.com/support
  description: "PDF Blocks is a secure, reliable, and fast API to work with PDF documents. Actions include: Merge PDF documents, add or remove passwords, add watermarks, remove, extract, reverse, and rotate pages, and more."
  termsOfService: https://www.pdfblocks.com/terms
  title: PDF Blocks API
  version: 1.5.0
  x-apisguru-categories:
    - text
  x-logo:
    url: https://www.pdfblocks.com/assets/images/pdfblocks-logo.svg
  x-origin:
    - format: openapi
      url: https://www.pdfblocks.com/assets/specs/pdfblocks.openapi.yaml
      version: "3.0"
  x-providerName: pdfblocks.com
externalDocs:
  description: Documentation and examples
  url: https://www.pdfblocks.com/docs/api/v1
security:
  - apiKey: []
paths:
  /v1/add_password:
    post:
      description: Protect a PDF document with a password. Encrypt the PDF document to prevent unauthorized access.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/add-password
      operationId: addPasswordV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                encryption_algorithm:
                  default: AES-128
                  description: The algorithm used to encrypt the PDF document.
                  enum:
                    - AES-128
                    - AES-256
                  example: AES-128
                  type: string
                file:
                  description: The input PDF document
                  format: binary
                  type: string
                password:
                  description: The password required to open the file.
                  example: pa$$word
                  maxLength: 32
                  minLength: 4
                  pattern: ^[\x20-\x7e]{4,32}$
                  type: string
              required:
                - file
                - password
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Add a password to a PDF
  /v1/add_restrictions:
    post:
      description: Add restrictions to prevent copying, printing, and modifying a PDF document.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/add-restrictions
      operationId: addRestrictionsV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                allow_accessibility:
                  default: true
                  description: If false, accessibility programs can't read the text or images of the document.
                  type: boolean
                allow_assemble_document:
                  default: true
                  description: If false, the user can't assemble or manipulate the document.
                  type: boolean
                allow_change_content:
                  default: true
                  description: If false, the user can't change the content of the document.
                  type: boolean
                allow_comment_and_fill_form:
                  default: true
                  description: If false, the user can't add, edit or modify annotations or fill form fields.
                  type: boolean
                allow_copy_content:
                  default: true
                  description: If false, the user can't copy text and images to the clipboard.
                  type: boolean
                allow_fill_form:
                  default: true
                  description: If false, the user can't fill forms fields.
                  type: boolean
                allow_print:
                  default: true
                  description: If false, the user can't print the document.
                  type: boolean
                allow_print_high_resolution:
                  default: true
                  description: If false, the user can't print the document in high resolution.
                  type: boolean
                encryption_algorithm:
                  default: AES-128
                  description: The algorithm used to encrypt the PDF document.
                  enum:
                    - AES-128
                    - AES-256
                  example: AES-128
                  type: string
                file:
                  description: The input PDF document
                  format: binary
                  type: string
                owner_password:
                  description: The password required to open and change permissions of the PDF document.
                  example: pa$$word
                  maxLength: 32
                  minLength: 4
                  pattern: ^[\x20-\x7e]{4,32}$
                  type: string
                user_password:
                  description: The password required to open the PDF document. If the `user_password` is not set, the user will be able to open the document without a password.
                  example: pa$$word
                  maxLength: 32
                  minLength: 4
                  pattern: ^[\x20-\x7e]{4,32}$
                  type: string
              required:
                - file
                - owner_password
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Add restrictions to a PDF
  /v1/add_watermark/image:
    post:
      description: Add an image watermark to each page of a PDF document.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/add-watermark-image
      operationId: addImageWatermarkV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: The input PDF document
                  format: binary
                  type: string
                image:
                  description: The image to add as a watermark. The format of the image can be either PNG or JPEG.
                  format: binary
                  type: string
                margin:
                  default: 1
                  description: The distance in inches from the border of the page to the image watermark.
                  example: 1
                  format: float
                  minimum: 0
                  type: number
                transparency:
                  default: 50
                  description: The transparency level for the image watermark from 0 (opaque) to 100 (transparent).
                  example: 50
                  format: int32
                  maximum: 100
                  minimum: 0
                  type: integer
              required:
                - file
                - image
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Add an image watermark to a PDF
  /v1/add_watermark/text:
    post:
      description: Add a text watermark to each page of a PDF document. Choose from several watermark templates.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/add-watermark-text
      operationId: addTextWatermarkV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                color:
                  default: Gray
                  description: The color of the text watermark.
                  enum:
                    - Red
                    - Blue
                    - Gray
                    - Black
                  example: Gray
                  type: string
                file:
                  description: The input PDF document
                  format: binary
                  type: string
                line_1:
                  description: The first line of text of the watermark.
                  example: Jane Doe
                  maxLength: 32
                  type: string
                line_2:
                  description: The second line of text of the watermark.
                  example: ACME, Inc
                  maxLength: 32
                  type: string
                line_3:
                  description: The third line of text of the watermark.
                  example: Confidential
                  maxLength: 32
                  type: string
                margin:
                  default: 1
                  description: The distance in inches from the border of the page to the text watermark.
                  example: 1
                  format: float
                  minimum: 0
                  type: number
                template:
                  default: 1001
                  description: The [id of the text watermark template](https://www.pdfblocks.com/docs/api/v1/text-watermark-templates.pdf).
                  example: 1001
                  format: int32
                  maximum: 66537
                  minimum: 1001
                  type: integer
                transparency:
                  default: 75
                  description: The transparency level for the text watermark from 0 (opaque) to 100 (transparent).
                  example: 75
                  format: int32
                  maximum: 100
                  minimum: 0
                  type: integer
              required:
                - file
                - line_1
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Add a text watermark to a PDF
  /v1/extract_pages:
    post:
      description: Extract one or more pages from a PDF document.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/extract-pages
      operationId: extractPagesV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: The input PDF document
                  format: binary
                  type: string
                first_page:
                  description: The first page of the range to extract. If empty, it defaults to the first page of the PDF document.
                  format: int32
                  minimum: 1
                  type: integer
                last_page:
                  description: The last page of the range to extract. If empty, it defaults to the last page of the PDF document.
                  format: int32
                  minimum: 1
                  type: integer
              required:
                - file
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Extract pages from a PDF
  /v1/merge_documents:
    post:
      description: Combine multiple PDF documents into a single PDF document.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/merge-documents
      operationId: mergeDocumentsV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: The array of PDF documents. PDF documents will be merged in the same order they are inserted into this array.
                  items:
                    description: An input PDF document.
                    format: binary
                    type: string
                  type: array
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Merge PDF documents
  /v1/remove_pages:
    post:
      description: Remove one or more pages from a PDF document.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/remove-pages
      operationId: removePagesV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: The input PDF document
                  format: binary
                  type: string
                first_page:
                  description: The first page of the range to remove from the PDF document. If empty, it defaults to the first page of the document.
                  format: int32
                  minimum: 1
                  type: integer
                last_page:
                  description: The last page of the range to remove from the PDF document. If empty, it defaults to the last page of the document.
                  format: int32
                  minimum: 1
                  type: integer
              required:
                - file
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Remove pages from a PDF
  /v1/remove_password:
    post:
      description: Remove the password from an encrypted PDF document. The PDF document will no longer require a password to open.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/remove-password
      operationId: removePasswordV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: The input PDF document
                  format: binary
                  type: string
                password:
                  description: The password required to open the file.
                  example: pa$$word
                  maxLength: 256
                  type: string
              required:
                - file
                - password
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Remove the password from a PDF
  /v1/remove_restrictions:
    post:
      description: Remove all the restrictions from a PDF document.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/remove-restrictions
      operationId: removeRestrictionsV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: The input PDF document
                  format: binary
                  type: string
              required:
                - file
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Remove the restrictions from a PDF
  /v1/remove_signatures:
    post:
      description: Remove the cryptographic signatures and timestamps from a PDF document.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/remove-signatures
      operationId: removeSignaturesV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: The input PDF document
                  format: binary
                  type: string
              required:
                - file
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Remove the signatures from a PDF
  /v1/reverse_pages:
    post:
      description: Reverse the order of the pages of a PDF document.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/reverse-pages
      operationId: reversePagesV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: The input PDF document
                  format: binary
                  type: string
              required:
                - file
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Reverse the pages of a PDF
  /v1/rotate_pages:
    post:
      description: Rotate one or more pages in a PDF document.
      externalDocs:
        description: Documentation and examples
        url: https://www.pdfblocks.com/docs/api/v1/rotate-pages
      operationId: rotatePagesV1
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                angle:
                  description: The angle of rotation of the pages. Positive angles rotate the pages clockwise. Negative angles rotate the pages counter-clockwise.
                  enum:
                    - 0
                    - 90
                    - 180
                    - 270
                    - -90
                    - -180
                    - -270
                  example: 90
                  format: int32
                  type: integer
                file:
                  description: The input PDF document
                  format: binary
                  type: string
                first_page:
                  description: The first page of the range to rotate in the PDF document. If empty, it defaults to the first page of the document.
                  format: int32
                  minimum: 1
                  type: integer
                last_page:
                  description: The last page of the range to rotate in the PDF document. If empty, it defaults to the last page of the document.
                  format: int32
                  minimum: 1
                  type: integer
              required:
                - file
                - angle
              type: object
        required: true
      responses:
        "200":
          $ref: "#/components/responses/success"
        4XX:
          $ref: "#/components/responses/error"
      summary: Rotate pages in a PDF
components:
  responses:
    error:
      content:
        application/problem+json:
          example:
            errors:
              file:
                - Could not parse the PDF document. The file may be invalid or corrupt.
            status: 400
            title: One or more validation errors occurred.
            type: https://www.pdfblocks.com/docs/api/v1/error/400
          schema:
            properties:
              errors:
                type: object
              status:
                type: integer
              title:
                type: string
              type:
                format: url
                type: string
            type: object
      description: Error
    success:
      content:
        application/pdf:
          schema:
            description: The output PDF document
            format: binary
            type: string
      description: The document was processed succesfully.
  securitySchemes:
    apiKey:
      description: Find your API key in [your dashboard](https://dashboard.pdfblocks.com/users/sign_in), or [get a free API key](https://www.pdfblocks.com/try-free).
      in: header
      name: X-Api-Key
      type: apiKey
