# API2PDF — how to use (mcp.ai)

Connect your API2PDF account and use 10 tools for documents straight from your AI agent. Connect with your own API key. Api2Pdf is a REST API that enables developers to generate PDFs from HTML, URLs, and various document formats using engines like wkhtmltopdf, Headless Chrome, and LibreOffice.

## Option A — via MCP (recommended)
Remote MCP endpoint (HTTP, streamable): `https://api.mcp.ai/p_api2pdf?ms=1787291460000`
Add it as a custom/remote MCP connector in your client (Claude, Cursor, VS Code…), then authenticate when prompted. Once connected, ask the agent to use the server's tools (e.g. `api2pdf_add_header_footer`).

## Option B — via direct REST API
Base URL: `https://api.mcp.ai/api/api2pdf`
Auth: `Authorization: Bearer sk_live_…` — create a workspace API key at https://mcp.ai/settings/api-keys
Discover endpoints: `GET https://api.mcp.ai/api/api2pdf/_endpoints`

### Endpoints
- `POST https://api.mcp.ai/api/api2pdf/add/header/footer` — Convert HTML to PDF with customizable headers and footers using Headless Chrome. Use for generating reports, invoices, or documents with consistent page numbering, titles, dates, or branding on every 
  - body: { html: string, options?: object, fileName?: string, inlinePdf?: boolean }
- `POST https://api.mcp.ai/api/api2pdf/check/status` — Tool to check the health status of the API2PDF service. Use when you need to verify if the API is available and responding. This endpoint does not require authentication and returns a simple status in
- `POST https://api.mcp.ai/api/api2pdf/delete/pdf` — Delete a previously generated PDF from API2PDF storage by its response ID. By default, API2PDF automatically deletes PDFs after 24 hours. Use this tool when you need to immediately remove a PDF for se
  - body: { response_id: string }
- `POST https://api.mcp.ai/api/api2pdf/extract/pages` — Tool to extract specific pages from a PDF document. Use when you need only certain pages from a larger PDF file. Provide a URL to the source PDF and optionally a page range (0-indexed, end exclusive).
  - body: { end?: integer, url: string, start?: integer, inline?: boolean, storage?: object, fileName?: string, extraHTTPHeaders?: object, useCustomStorage?: boolean }
- `POST https://api.mcp.ai/api/api2pdf/libreoffice/pdf/to/html` — Tool to convert a PDF document to HTML using LibreOffice. Use when you need HTML output of a PDF file (experimental; images may be excluded).
  - body: { url: string, inline?: boolean, fileName?: string }
- `POST https://api.mcp.ai/api/api2pdf/libreoffice/thumbnail` — Tool to generate a thumbnail image of a document using LibreOffice. Use when you need a quick visual preview of a PDF or Office file's first page.
  - body: { url: string }
- `POST https://api.mcp.ai/api/api2pdf/merge/pdfs` — Merge multiple PDF documents into a single PDF file. Provide a list of publicly accessible PDF URLs, and they will be combined in the order specified. The merged PDF is available via a download URL fo
  - body: { urls: string[], inline?: boolean, storage?: object, fileName?: string, extraHTTPHeaders?: object, useCustomStorage?: boolean }
- `POST https://api.mcp.ai/api/api2pdf/optimize/pdf` — Tool to optimize a PDF document to reduce file size while maintaining quality. Use when you need to minimize storage or bandwidth for an existing PDF.
  - body: { url: string, inline?: boolean, storage?: object, fileName?: string, extraHTTPHeaders?: object, useCustomStorage?: boolean }
- `POST https://api.mcp.ai/api/api2pdf/reorder/pages` — Reorder pages of a PDF document by specifying a new page sequence. Provide a URL to the source PDF and a list of zero-based page indices in the desired order. For example, to reverse a 3-page PDF, use
  - body: { url: string, pages: integer[], inline?: boolean, storage?: object, fileName?: string, extraHTTPHeaders?: object, useCustomStorage?: boolean }
- `POST https://api.mcp.ai/api/api2pdf/zebra/generate/barcode` — Tool to generate barcodes or QR codes using Zebra Crossing (ZXING). Use when you need a barcode or QR code image from text values.
  - body: { value: string, width?: integer, format: string, height?: integer, showlabel?: boolean }

## Example prompts
- "What can I do in API2PDF?"
- "Show me a summary of my API2PDF account"

## More
- Page: https://mcp.ai/api2pdf
- Agent spec (llms.txt): https://mcp.ai/api2pdf/llms.txt
- Postman collection: https://mcp.ai/api2pdf/postman.json
