{
  "openapi": "3.1.0",
  "info": {
    "title": "NexPDF Cloud API",
    "version": "1.1.0",
    "description": "Convert, build, sign, split, OCR, extract and view documents, on the NexPDF engine. Every request but health sends `Authorization: Bearer <API key>`. Successful answers carry `x-nexpdf-units` (units billed) and `x-request-id`. Errors are JSON: `{\"error\": {\"code\", \"message\"}, \"request_id\"}`.",
    "contact": {
      "name": "NexPDF",
      "url": "https://nexpdf.dev/docs/cloud"
    }
  },
  "servers": [
    {
      "url": "https://api.nexpdf.dev"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "tags": [
    {
      "name": "Documents",
      "description": "Convert, build, OCR, merge, split, extract and edit."
    },
    {
      "name": "Signatures",
      "description": "Sign (in a build, or in two steps with a key you hold) and verify digital signatures, ICP-Brasil included."
    },
    {
      "name": "Jobs",
      "description": "Cost estimates, background jobs and batches."
    },
    {
      "name": "Viewer",
      "description": "Links that show a document in any browser."
    },
    {
      "name": "AI",
      "description": "Extraction and classification with Claude."
    },
    {
      "name": "Service",
      "description": "Health and this specification."
    }
  ],
  "paths": {
    "/v1/health": {
      "get": {
        "operationId": "health",
        "summary": "Health",
        "tags": [
          "Service"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Up.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "version": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "ok",
                    "version"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/build": {
      "post": {
        "operationId": "build",
        "summary": "Build a document",
        "description": "Combines parts (files and HTML), applies actions in order and writes one output. Every other conversion endpoint is a shortcut for a build. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Documents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "instructions": {
                    "type": "string",
                    "description": "The build instructions, as JSON text (schema `Instructions`).",
                    "contentMediaType": "application/json",
                    "contentSchema": {
                      "$ref": "#/components/schemas/Instructions"
                    }
                  }
                },
                "required": [
                  "instructions"
                ],
                "additionalProperties": {
                  "description": "A file named in the instructions (or `<name>_url`).",
                  "oneOf": [
                    {
                      "type": "string",
                      "format": "binary"
                    },
                    {
                      "type": "string",
                      "format": "uri"
                    }
                  ]
                }
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "The output, typed by `output.type`.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              },
              "x-request-id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "text/markdown": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/convert/pdf": {
      "post": {
        "operationId": "convertToPdf",
        "summary": "Convert to PDF",
        "description": "Any supported file to PDF. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Documents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  }
                },
                "required": []
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "The PDF.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              },
              "x-request-id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/ocr": {
      "post": {
        "operationId": "ocr",
        "summary": "OCR",
        "description": "Adds a searchable text layer to scanned pages. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Documents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  },
                  "languages": {
                    "type": "string",
                    "description": "Tesseract language codes joined with `+`, e.g. `eng+por`."
                  }
                },
                "required": []
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "The searchable PDF.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              },
              "x-request-id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/merge": {
      "post": {
        "operationId": "merge",
        "summary": "Merge",
        "description": "Joins `file1`, `file2`, … in that order (2 to 20). Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Documents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file1": {
                    "type": "string",
                    "format": "binary"
                  },
                  "file2": {
                    "type": "string",
                    "format": "binary"
                  }
                },
                "required": [],
                "additionalProperties": {
                  "description": "A file named in the instructions (or `<name>_url`).",
                  "oneOf": [
                    {
                      "type": "string",
                      "format": "binary"
                    },
                    {
                      "type": "string",
                      "format": "uri"
                    }
                  ]
                }
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "The merged PDF.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              },
              "x-request-id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/extract/markdown": {
      "post": {
        "operationId": "extractMarkdown",
        "summary": "Extract Markdown",
        "description": "The document's text as Markdown, with headings, lists and tables. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Documents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  }
                },
                "required": []
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "Markdown.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              },
              "x-request-id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/xlsx/edit": {
      "post": {
        "operationId": "editXlsx",
        "summary": "Edit a spreadsheet",
        "description": "Sets cells and formulas in an .xlsx. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Documents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  },
                  "edits": {
                    "type": "string",
                    "description": "JSON text: `{\"sheet\": \"Budget\", \"edits\": [{\"cell\": \"C2\", \"value\": 6.5}]}`."
                  }
                },
                "required": [
                  "edits"
                ]
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "The edited workbook.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              },
              "x-request-id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/docx/edit": {
      "post": {
        "operationId": "editDocx",
        "summary": "Edit a Word document",
        "description": "Applies operations (replace text, fill fields, …) to a .docx. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Documents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  },
                  "ops": {
                    "type": "string",
                    "description": "JSON text: a list of operations."
                  }
                },
                "required": [
                  "ops"
                ]
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "The edited document.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              },
              "x-request-id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/split": {
      "post": {
        "operationId": "split",
        "summary": "Split",
        "description": "Splits a PDF every N pages or by ranges; a ZIP of `part-1.pdf`, `part-2.pdf`, … Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Documents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  },
                  "every": {
                    "type": "integer",
                    "description": "Pages per file."
                  },
                  "ranges": {
                    "type": "string",
                    "description": "JSON text: a list of `{start, end}` (0-based, inclusive; negative counts from the end)."
                  }
                },
                "required": []
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "A ZIP of PDFs.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              },
              "x-request-id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/verify": {
      "post": {
        "operationId": "verifySignatures",
        "summary": "Verify signatures",
        "description": "Checks every digital signature in a PDF. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Signatures"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  }
                },
                "required": []
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "One report per signature (an empty list when unsigned).",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SignatureReport"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/sign/prepare": {
      "post": {
        "operationId": "prepareSignature",
        "summary": "Prepare a signature (step 1)",
        "description": "Step 1 of signing with a key you hold (a smart card or token such as an ICP-Brasil A3, an HSM, a cloud KMS or a signing service): the key never reaches the API. Answers the bytes to sign; send the signature to `/v1/sign/complete` before `expires_at`. Free (a document that has to be converted costs the conversion). Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Signatures"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  },
                  "certificate": {
                    "type": "string",
                    "format": "binary",
                    "description": "The signer certificate, PEM or DER; a PEM may carry its chain after it."
                  },
                  "options": {
                    "type": "string",
                    "description": "JSON text of a `SignOptions` object: name, reason, location, contact, field, appearance, level, policy."
                  },
                  "expires_in": {
                    "type": "integer",
                    "description": "Seconds, 60 to 86400 (default 3600)."
                  }
                },
                "required": [
                  "certificate"
                ]
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "201": {
            "description": "Created.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreparedSignature"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/sign/complete": {
      "post": {
        "operationId": "completeSignature",
        "summary": "Complete a signature (step 2)",
        "description": "Embeds the signature over `to_be_signed` and answers the signed PDF, with the time-stamp and validation data its level asks for. A signature that does not verify against the certificate is refused (422) and the prepared document is kept, so the call can be repeated; once it succeeds, the prepared document is deleted. Costs what a `sign` action costs.",
        "tags": [
          "Signatures"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "From `/v1/sign/prepare`."
                  },
                  "signature": {
                    "type": "string",
                    "format": "byte",
                    "description": "Base64 of the signature: RSA PKCS#1 v1.5, or ECDSA (DER or raw r‖s), both over SHA-256 of `to_be_signed`."
                  }
                },
                "required": [
                  "id",
                  "signature"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The signed PDF.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/sign/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "delete": {
        "operationId": "deleteSignature",
        "summary": "Drop a prepared signature",
        "tags": [
          "Signatures"
        ],
        "responses": {
          "204": {
            "description": "The prepared document is deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/estimate": {
      "post": {
        "operationId": "estimate",
        "summary": "Estimate the cost",
        "description": "Takes exactly what `/v1/build` takes and answers what it would cost, without running it. Free: costs no units. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Jobs"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "instructions": {
                    "type": "string",
                    "description": "The build instructions, as JSON text (schema `Instructions`).",
                    "contentMediaType": "application/json",
                    "contentSchema": {
                      "$ref": "#/components/schemas/Instructions"
                    }
                  }
                },
                "required": [
                  "instructions"
                ],
                "additionalProperties": {
                  "description": "A file named in the instructions (or `<name>_url`).",
                  "oneOf": [
                    {
                      "type": "string",
                      "format": "binary"
                    },
                    {
                      "type": "string",
                      "format": "uri"
                    }
                  ]
                }
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "The estimate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Estimate"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/jobs": {
      "post": {
        "operationId": "createJob",
        "summary": "Start a background job",
        "description": "Takes exactly what `/v1/build` takes and answers `202` at once; poll `GET /v1/jobs/{id}`. For large files and long builds (up to 15 minutes). Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Jobs"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "instructions": {
                    "type": "string",
                    "description": "The build instructions, as JSON text (schema `Instructions`).",
                    "contentMediaType": "application/json",
                    "contentSchema": {
                      "$ref": "#/components/schemas/Instructions"
                    }
                  }
                },
                "required": [
                  "instructions"
                ],
                "additionalProperties": {
                  "description": "A file named in the instructions (or `<name>_url`).",
                  "oneOf": [
                    {
                      "type": "string",
                      "format": "binary"
                    },
                    {
                      "type": "string",
                      "format": "uri"
                    }
                  ]
                }
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "202": {
            "description": "Accepted.",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                },
                "description": "`/v1/jobs/{id}`"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/batch": {
      "post": {
        "operationId": "batch",
        "summary": "Start a batch",
        "description": "The same instructions over many documents (2 to 50): the instructions take the document from the file `document`; send them as `document1`, `document2`, … (or `document1_url`, …). Other files the instructions name are shared. The result is a ZIP with one file per document that succeeded, named after its field.",
        "tags": [
          "Jobs"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "instructions": {
                    "type": "string",
                    "description": "The build instructions, as JSON text (schema `Instructions`).",
                    "contentMediaType": "application/json",
                    "contentSchema": {
                      "$ref": "#/components/schemas/Instructions"
                    }
                  },
                  "document1": {
                    "type": "string",
                    "format": "binary"
                  },
                  "document2": {
                    "type": "string",
                    "format": "binary"
                  }
                },
                "required": [
                  "instructions"
                ],
                "additionalProperties": {
                  "description": "A file named in the instructions (or `<name>_url`).",
                  "oneOf": [
                    {
                      "type": "string",
                      "format": "binary"
                    },
                    {
                      "type": "string",
                      "format": "uri"
                    }
                  ]
                }
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "202": {
            "description": "Accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/jobs/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getJob",
        "summary": "Job status",
        "tags": [
          "Jobs"
        ],
        "responses": {
          "200": {
            "description": "The job.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "operationId": "deleteJob",
        "summary": "Cancel a job or delete its result",
        "tags": [
          "Jobs"
        ],
        "responses": {
          "204": {
            "description": "Done."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/jobs/{id}/result": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getJobResult",
        "summary": "Job result",
        "description": "The file once the job has succeeded. `409 not_ready` (with `Retry-After`) before that; `409 job_failed` when it failed.",
        "tags": [
          "Jobs"
        ],
        "responses": {
          "200": {
            "description": "The output.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              },
              "x-request-id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "text/markdown": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/v1/viewer": {
      "post": {
        "operationId": "createViewer",
        "summary": "Create a viewer link",
        "description": "A link that shows the document in any browser, with nothing to install and no key in the page. Anyone with the link sees the document until it expires. Can be embedded in an `<iframe>`. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "Viewer"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  },
                  "expires_in": {
                    "type": "integer",
                    "description": "Seconds, 300 to 604800 (default 86400)."
                  },
                  "download": {
                    "type": "string",
                    "description": "`false` hides the download button and the PDF.",
                    "enum": [
                      "true",
                      "false"
                    ]
                  }
                },
                "required": []
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "201": {
            "description": "Created.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Viewer"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/viewer/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "delete": {
        "operationId": "deleteViewer",
        "summary": "End a viewer link",
        "tags": [
          "Viewer"
        ],
        "responses": {
          "204": {
            "description": "The link no longer works."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/ai/extract": {
      "post": {
        "operationId": "aiExtract",
        "summary": "Extract data with AI",
        "description": "Reads the document's text and returns the data your JSON Schema describes. The text is sent to Anthropic's Claude API to answer; nothing is kept. At most 300,000 characters of text. Cost: 1 unit per 4,000 characters (2 at least), plus conversion to PDF when needed. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "AI"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  },
                  "schema": {
                    "type": "string",
                    "description": "JSON text: a JSON Schema whose top level is `{\"type\": \"object\"}`. Objects are closed (`additionalProperties: false`); `minimum`, `maximum`, `minLength` and `maxLength` are ignored."
                  },
                  "prompt": {
                    "type": "string",
                    "description": "Extra instructions (at most 4000 characters)."
                  }
                },
                "required": [
                  "schema"
                ]
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "The data.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "description": "Follows your schema."
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/ai/classify": {
      "post": {
        "operationId": "aiClassify",
        "summary": "Classify with AI",
        "description": "Picks one of your labels for the document, with the reason. The text is sent to Anthropic's Claude API; nothing is kept. Same limits and cost as `/v1/ai/extract`. Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit).",
        "tags": [
          "AI"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "document": {
                    "description": "The file (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, image, EPUB…). Or `document_url`.",
                    "type": "string",
                    "format": "binary"
                  },
                  "document_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Instead of `document`: a public URL to download it from."
                  },
                  "labels": {
                    "type": "string",
                    "description": "JSON text: 2 to 100 labels, each a name or `{\"name\", \"description\"}`."
                  },
                  "prompt": {
                    "type": "string",
                    "description": "Extra instructions (at most 4000 characters)."
                  }
                },
                "required": [
                  "labels"
                ]
              }
            }
          },
          "description": "Any file field may instead be sent as `<field>_url`: a public `http`/`https` URL the server downloads (ports 80 and 443, at most 5 redirects, the key's file size limit)."
        },
        "responses": {
          "200": {
            "description": "The label.",
            "headers": {
              "x-nexpdf-units": {
                "$ref": "#/components/headers/Units"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "label",
                    "reason"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/openapi.json": {
      "get": {
        "operationId": "openapi",
        "summary": "This specification",
        "tags": [
          "Service"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1.",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key: `nxp_live_…` or `nxp_test_…` (test keys watermark their output)."
      }
    },
    "headers": {
      "Units": {
        "description": "Units billed for this request.",
        "schema": {
          "type": "integer"
        }
      },
      "RequestId": {
        "description": "Quote it when asking for help.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request is malformed. Codes: `invalid_request`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "No key, or a key that is not valid. Codes: `unauthorized`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found, or not this key's. Codes: `not_found`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "The job is not done, or failed. Codes: `not_ready`, `job_failed`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooLarge": {
        "description": "A file is over the key's limit, or the text is too long for AI. Codes: `file_too_large`, `document_too_long`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unprocessable": {
        "description": "The file could not be processed or downloaded, or the AI declined. Codes: `processing_failed`, `fetch_failed`, `ai_refused`, `ai_incomplete`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooMany": {
        "description": "Rate, concurrency or quota limits. Retry after `Retry-After` except for `quota_exceeded`. Codes: `rate_limited`, `concurrency_limited`, `quota_exceeded`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unavailable": {
        "description": "Busy, or a service it depends on did not answer; retry after `Retry-After`. Codes: `busy`, `unavailable`, `ai_unavailable`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          },
          "request_id": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "PageRange": {
        "type": "object",
        "additionalProperties": false,
        "description": "0-based and inclusive; negative values count from the end (-1 is the last page).",
        "properties": {
          "start": {
            "type": "integer"
          },
          "end": {
            "type": "integer"
          }
        },
        "required": [
          "start",
          "end"
        ]
      },
      "Part": {
        "type": "object",
        "additionalProperties": false,
        "description": "One part: a file field or an HTML field.",
        "properties": {
          "file": {
            "type": "string",
            "description": "A multipart field holding a file."
          },
          "html": {
            "type": "string",
            "description": "A multipart field holding HTML."
          },
          "password": {
            "type": "string"
          },
          "pages": {
            "$ref": "#/components/schemas/PageRange"
          }
        }
      },
      "Action": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "title": "ocr",
            "properties": {
              "type": {
                "const": "ocr"
              },
              "languages": {
                "type": "string"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "watermark",
            "properties": {
              "type": {
                "const": "watermark"
              },
              "text": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "text"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "rotate",
            "properties": {
              "type": {
                "const": "rotate"
              },
              "degrees": {
                "type": "integer",
                "enum": [
                  90,
                  180,
                  270,
                  -90,
                  -180,
                  -270
                ]
              },
              "pages": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              }
            },
            "required": [
              "type",
              "degrees"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "delete_pages",
            "properties": {
              "type": {
                "const": "delete_pages"
              },
              "pages": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              }
            },
            "required": [
              "type",
              "pages"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "flatten_annotations",
            "properties": {
              "type": {
                "const": "flatten_annotations"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "flatten_forms",
            "properties": {
              "type": {
                "const": "flatten_forms"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "fill_form",
            "properties": {
              "type": {
                "const": "fill_form"
              },
              "values": {
                "type": "object"
              }
            },
            "required": [
              "type",
              "values"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "redact",
            "properties": {
              "type": {
                "const": "redact"
              },
              "query": {
                "type": "string"
              },
              "mode": {
                "type": "string",
                "enum": [
                  "text",
                  "regex",
                  "pattern"
                ]
              },
              "fill_white": {
                "type": "boolean"
              }
            },
            "required": [
              "type",
              "query"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "pdfa",
            "properties": {
              "type": {
                "const": "pdfa"
              },
              "level": {
                "type": "string",
                "enum": [
                  "1a",
                  "1b",
                  "2a",
                  "2b",
                  "2u",
                  "3a",
                  "3b",
                  "3u"
                ]
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "pdfua",
            "properties": {
              "type": {
                "const": "pdfua"
              },
              "part": {
                "type": "integer",
                "enum": [
                  1,
                  2
                ]
              },
              "lang": {
                "type": "string"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "optimize",
            "properties": {
              "type": {
                "const": "optimize"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "encrypt",
            "properties": {
              "type": {
                "const": "encrypt"
              },
              "owner_password": {
                "type": "string"
              },
              "user_password": {
                "type": "string"
              },
              "permissions": {
                "type": "integer"
              }
            },
            "required": [
              "type",
              "owner_password"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "sign",
            "properties": {
              "type": {
                "const": "sign"
              },
              "certificate": {
                "type": "string",
                "description": "A field holding a PKCS#12 file; without it, a self-signed certificate."
              },
              "password": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              },
              "location": {
                "type": "string"
              },
              "contact": {
                "type": "string"
              },
              "field": {
                "type": "string"
              },
              "appearance": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "page": {
                    "type": "integer"
                  },
                  "rect": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    },
                    "minItems": 4,
                    "maxItems": 4
                  },
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "rect"
                ]
              },
              "level": {
                "type": "string",
                "enum": [
                  "B-B",
                  "B-T",
                  "B-LT",
                  "B-LTA"
                ],
                "default": "B-B",
                "description": "PAdES level. B-T adds a time-stamp (1 unit), B-LT validation data (1 more), B-LTA a document time-stamp (1 more)."
              },
              "policy": {
                "type": "string",
                "enum": [
                  "icp-brasil"
                ],
                "description": "Signature policy. `icp-brasil`: ICP-Brasil (DOC-ICP-15.03) AD-RB at level B-B, AD-RT at B-T and above (the time-stamp comes from your ACT in `timestamp_authority`, or from the server's; with neither, B-T and above are refused with `not_available`). The certificate must chain to an AC Raiz of ICP-Brasil for the signature to be valid in Brazil."
              },
              "timestamp_authority": {
                "$ref": "#/components/schemas/TimestampAuthority"
              }
            },
            "required": [
              "type"
            ]
          }
        ],
        "discriminator": {
          "propertyName": "type"
        }
      },
      "Output": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "title": "pdf",
            "properties": {
              "type": {
                "const": "pdf"
              },
              "linearize": {
                "type": "boolean"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "png",
            "properties": {
              "type": {
                "const": "png"
              },
              "page": {
                "type": "integer"
              },
              "dpi": {
                "type": "number",
                "default": 150
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "markdown",
            "properties": {
              "type": {
                "const": "markdown"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "html",
            "properties": {
              "type": {
                "const": "html"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "json",
            "properties": {
              "type": {
                "const": "json"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "docx",
            "properties": {
              "type": {
                "const": "docx"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "xlsx",
            "properties": {
              "type": {
                "const": "xlsx"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "title": "split",
            "properties": {
              "type": {
                "const": "split"
              },
              "every": {
                "type": "integer"
              },
              "ranges": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PageRange"
                }
              }
            },
            "required": [
              "type"
            ]
          }
        ],
        "discriminator": {
          "propertyName": "type"
        }
      },
      "Instructions": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "parts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Part"
            },
            "minItems": 1,
            "maxItems": 20
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Action"
            },
            "maxItems": 50
          },
          "output": {
            "$ref": "#/components/schemas/Output"
          }
        },
        "required": [
          "parts"
        ],
        "example": {
          "parts": [
            {
              "file": "doc"
            }
          ],
          "actions": [
            {
              "type": "watermark",
              "text": "DRAFT"
            }
          ],
          "output": {
            "type": "pdf"
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "op": {
            "type": "string"
          },
          "units": {
            "type": "integer"
          }
        },
        "required": [
          "op",
          "units"
        ]
      },
      "Estimate": {
        "type": "object",
        "properties": {
          "units": {
            "type": "integer"
          },
          "pages": {
            "type": "integer"
          },
          "operations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Usage"
            }
          }
        },
        "required": [
          "units",
          "pages",
          "operations"
        ]
      },
      "JobError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ]
          },
          "created_at": {
            "type": "integer",
            "description": "Unix seconds."
          },
          "started_at": {
            "type": [
              "integer",
              "null"
            ]
          },
          "finished_at": {
            "type": [
              "integer",
              "null"
            ]
          },
          "units": {
            "type": "integer"
          },
          "error": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/JobError"
              },
              {
                "type": "null"
              }
            ]
          },
          "content_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "result_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "`/v1/jobs/{id}/result` once it succeeded."
          },
          "expires_at": {
            "type": [
              "integer",
              "null"
            ],
            "description": "When the result is deleted."
          },
          "items": {
            "type": "array",
            "description": "Batches only: one per document.",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "units": {
                  "type": "integer"
                },
                "error": {
                  "$ref": "#/components/schemas/JobError"
                }
              },
              "required": [
                "name",
                "status",
                "units"
              ]
            }
          }
        },
        "required": [
          "id",
          "status",
          "created_at",
          "units"
        ]
      },
      "Viewer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The link; it holds a 256-bit secret."
          },
          "expires_at": {
            "type": "integer"
          },
          "pages": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "url",
          "expires_at",
          "pages"
        ]
      },
      "SignatureReport": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string"
          },
          "signer": {
            "type": "string"
          },
          "digest_ok": {
            "type": "boolean"
          },
          "signature_ok": {
            "type": "boolean"
          },
          "covers_whole_document": {
            "type": "boolean"
          },
          "self_signed": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          },
          "sub_filter": {
            "type": "string",
            "description": "`ETSI.CAdES.detached`, `PBAD.PAdES` (ICP-Brasil), …"
          },
          "policy": {
            "type": [
              "object",
              "null"
            ],
            "description": "The signature policy the signature names, and for ICP-Brasil policies whether it meets them (null: no policy). ICP-Brasil signatures are checked against the AC Raiz v5, v10, v11 and v12.",
            "properties": {
              "oid": {
                "type": "string"
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "e.g. `ICP-Brasil AD-RB v1.3`."
              },
              "hash_ok": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "icp_brasil": {
                "type": "boolean",
                "description": "Every ICP-Brasil requirement checked holds, the chain to an AC Raiz included."
              },
              "problems": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "additionalProperties": true
      },
      "SignOptions": {
        "type": "object",
        "additionalProperties": false,
        "description": "The options of a signature made with a key the caller holds: the `sign` action without `certificate` and `password`.",
        "properties": {
          "name": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "location": {
            "type": "string"
          },
          "contact": {
            "type": "string"
          },
          "field": {
            "type": "string"
          },
          "appearance": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "page": {
                "type": "integer"
              },
              "rect": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 4,
                "maxItems": 4
              },
              "text": {
                "type": "string"
              }
            },
            "required": [
              "rect"
            ]
          },
          "level": {
            "type": "string",
            "enum": [
              "B-B",
              "B-T",
              "B-LT",
              "B-LTA"
            ],
            "default": "B-B",
            "description": "PAdES level. B-T adds a time-stamp (1 unit), B-LT validation data (1 more), B-LTA a document time-stamp (1 more)."
          },
          "policy": {
            "type": "string",
            "enum": [
              "icp-brasil"
            ],
            "description": "Signature policy. `icp-brasil`: ICP-Brasil (DOC-ICP-15.03) AD-RB at level B-B, AD-RT at B-T and above (the time-stamp comes from your ACT in `timestamp_authority`, or from the server's; with neither, B-T and above are refused with `not_available`). The certificate must chain to an AC Raiz of ICP-Brasil for the signature to be valid in Brazil."
          },
          "timestamp_authority": {
            "$ref": "#/components/schemas/TimestampAuthority"
          }
        }
      },
      "PreparedSignature": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Starts with `sig_`."
          },
          "to_be_signed": {
            "type": "string",
            "format": "byte",
            "description": "Base64 of the bytes to sign (the DER CMS signed attributes). Sign them with RSA PKCS#1 v1.5 or ECDSA, both with SHA-256."
          },
          "to_be_signed_sha256": {
            "type": "string",
            "description": "Hex SHA-256 of `to_be_signed`, for devices that sign a digest."
          },
          "expires_at": {
            "type": "integer"
          },
          "level": {
            "type": "string",
            "enum": [
              "B-B",
              "B-T",
              "B-LT",
              "B-LTA"
            ]
          },
          "policy": {
            "type": [
              "string",
              "null"
            ],
            "description": "`icp-brasil-ad-rb`, `icp-brasil-ad-rt`, or null."
          }
        },
        "required": [
          "id",
          "to_be_signed",
          "to_be_signed_sha256",
          "expires_at",
          "level",
          "policy"
        ]
      },
      "TimestampAuthority": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "url"
        ],
        "description": "Your own RFC 3161 time-stamp authority for levels B-T and above, used instead of the server's: for ICP-Brasil AD-RT, an ACT accredited in ICP-Brasil that you have a contract with. Credentials go with each time-stamp request as HTTP Basic (`username`, `password`) or a bearer `token`, only over https, and are kept only while the request (or the prepared signature) lives. When it fails, the answer is 422 `fetch_failed` with the authority's host and HTTP status.",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048,
            "description": "http or https; ports 80 and 443; a public address."
          },
          "username": {
            "type": "string",
            "maxLength": 256,
            "description": "HTTP Basic user name (no ':')."
          },
          "password": {
            "type": "string",
            "maxLength": 256,
            "description": "HTTP Basic password; needs `username`."
          },
          "token": {
            "type": "string",
            "maxLength": 4096,
            "description": "Bearer token, instead of `username` and `password`."
          }
        }
      }
    }
  }
}
