### Request Example for post/v1/process (Shell Curl) Source: https://mostlypdf.com/docs This is the request example for the /v1/process endpoint, shown in the Shell Curl client. It uses the merge-pdf tool and includes placeholder file data. The Authorization header uses YOUR_SECRET_TOKEN. ```shell curl https://mostly-pdf.web.app/v1/process \ --request POST \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \ --data '{ "tool": "merge-pdf", "options": { "additionalProperty": "anything" }, "files": [ "" ] }' ``` -------------------------------- ### Python requests example for compress-pdf Source: https://mostlypdf.com/docs Python example using the requests library. Reads a PDF, base64-encodes it, and sends a POST request with tool 'compress-pdf'. Raises an exception on HTTP error and writes the first output file to out.pdf. ```python import base64, os, requests with open("in.pdf", "rb") as f: payload = base64.b64encode(f.read()).decode() r = requests.post( "https://mostly-pdf.web.app/v1/process", headers={"Authorization": f"Bearer {os.environ['MOSTLYPDF_KEY']}"}, json={"tool": "compress-pdf", "files": [payload]}, timeout=120, ) r.raise_for_status() with open("out.pdf", "wb") as f: f.write(base64.b64decode(r.json()["outputs"][0])) ``` -------------------------------- ### JavaScript (Node) fetch example for rotate-pdf Source: https://mostlypdf.com/docs Node.js example using fetch to call the API. Reads a PDF file, base64-encodes it, and sends a request with tool 'rotate-pdf' and options {degrees: 90}. Writes the first output file to out.pdf. ```javascript const res = await fetch("https://mostly-pdf.web.app/v1/process", { method: "POST", headers: { "Authorization": `Bearer ${process.env.MOSTLYPDF_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ tool: "rotate-pdf", options: { degrees: 90 }, files: [Buffer.from(await fs.readFile("in.pdf")).toString("base64")], }), }); const { outputs } = await res.json(); await fs.writeFile("out.pdf", Buffer.from(outputs[0], "base64")); ``` -------------------------------- ### Quickstart: Call /v1/process with curl Source: https://mostlypdf.com/docs Use this curl command to call the MostlyPDF API with your Bearer token. The request sends a base64-encoded PDF file and options for the rotate-pdf tool. The response contains base64-encoded output files. ```shell curl https://mostly-pdf.web.app/v1/process \ -H "Authorization: Bearer sk_live_your_key" \ -H "Content-Type: application/json" \ -d '{ "tool": "rotate-pdf", "options": { "degrees": 90 }, "files": ["JVBERi0xLjQK..."] }' ``` -------------------------------- ### Authentication header with Bearer token Source: https://mostlypdf.com/docs Shows the Authorization header format using a Bearer token. Keys start with sk_ and are created in the dashboard. The x-api-key header is accepted as an alternative for clients that cannot set Authorization. ```http Authorization: Bearer sk_live_your_key ``` -------------------------------- ### curl request to POST /v1/process with merge-pdf Source: https://mostlypdf.com/docs Example curl command to call the MostlyPDF API. Sends a POST request with a JSON body containing the tool 'merge-pdf' and two base64-encoded files. Requires a Bearer token and Content-Type application/json. ```bash curl -X POST https://mostly-pdf.web.app/v1/process \ -H "Authorization: Bearer sk_live_your_key" \ -H "Content-Type: application/json" \ -d '{ "tool": "merge-pdf", "files": ["", ""] }' ``` -------------------------------- ### POST /v1/process Source: https://mostlypdf.com/docs Run any MostlyPDF tool programmatically. One flat, metered per-operation rate. Authenticate with your `sk_` API key. ```APIDOC ## [POST] /v1/process ### Description Run one tool over the supplied file(s) and return the result(s). Metered: one billable operation per call. ### Method POST ### Endpoint /v1/process ### Parameters #### Request Body - **files** (array of string, byte) - Required - Input file(s), base-64 encoded. Multi-file tools (merge, jpg-to-pdf) accept several. - **tool** (string) - Required - The tool to run. Enum: merge-pdf, split-pdf, remove-pages, extract-pages, organize-pdf, rotate-pdf, page-numbers, watermark-pdf, crop-pdf, fill-pdf-form, jpg-to-pdf, compress-pdf, pdf-to-word, pdf-to-jpg, word-to-pdf, ocr-pdf, excel-to-pdf, powerpoint-to-pdf, pdf-to-excel, pdf-to-powerpoint, pdf-to-pdfa, repair-pdf, compare-pdf, redact-pdf, txt-to-pdf, rtf-to-pdf, odt-to-pdf, html-to-pdf, url-to-pdf, markdown-to-pdf, email-to-pdf, protect-pdf, unlock-pdf, sign-pdf, sign-pdf-certified, request-signature, chat-with-pdf, summarize-pdf. - **options** (object) - Optional - Tool-specific options (e.g. `{ "degrees": 90 }`, `{ "ranges": ["1-3","5"] }`, `{ "text": "DRAFT", "opacity": 0.2 }`). ### Request Example ``` curl https://mostly-pdf.web.app/v1/process \\ --request POST \\ --header 'Content-Type: application/json' \\ --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \\ --data '{ "tool": "merge-pdf", "options": { "additionalProperty": "anything" }, "files": [ "" ] }' ``` ### Response #### Success Response (200) - **outputs** (array of string) - Description not provided. - **filenames** (array of string) - Description not provided. - **contentType** (string) - Description not provided. #### Response Example ``` { "outputs": [ "string" ], "filenames": [ "string" ], "contentType": "application/pdf" } ``` ``` -------------------------------- ### POST /v1/process Source: https://mostlypdf.com/docs Process PDF operations by calling a single endpoint. It accepts a tool name, base64-encoded files, and optional operation-specific options, and returns base64-encoded outputs. This operation covers all 38 PDF tools. ```APIDOC ## POST /v1/process ### Description Processes PDF files by sending a base64-encoded file to a specific operation toolley. One billable operation per call. ### Method POST ### Endpoint /v1/process ### Parameters #### Request Body - **tool** (string) - Required - The operation to run, identified by its slug. - **files** (string[]) - Required - Input file(s), base64-encoded. Multi-file operations take several. - **options** (object) - Optional - Operation-specific settings, e.g. `{"degrees":90}` or `{"ranges":["1-3","5"]}`. ### Request Example ```json { "tool": "merge-pdf", "files": ["", ""] } ``` ### Response #### Success Response (200) - **outputs** (string[]) - Array of base64 result files, in the same order the operation produces them. #### Response Example ```json { "outputs": [""] } ``` ``` -------------------------------- ### Response Schema for post/v1/process Source: https://mostlypdf.com/docs The response body for a successful 200 request to /v1/process. It contains an array of base64-encoded output files, filenames, and the content type. ```json { "outputs": [ "string" ], "filenames": [ "string" ], "contentType": "application/pdf" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.