---
title: "Repair a damaged PDF"
method: POST
path: "/pdf-repair"
tags: ["PDF"]
---

# Repair a damaged PDF

`POST /pdf-repair`

## Request

- Base URL: `https://api.cofferdock.com`
- URL: `https://api.cofferdock.com/pdf-repair`
- Auth: API key in header `x-api-key`

Fixes a PDF that will not open or says the file is damaged (a broken or missing internal index, a download cut off near the end, wrong offsets) by rebuilding its structure with qpdf, and returns a clean PDF with everything that could be read. It repairs structure, not content: pages whose data is missing from the file cannot be recovered, and meta.pages tells you how many come out. A healthy PDF comes back as an equivalent copy (meta.repaired is false). A password-protected PDF must be unlocked first with /pdf-unprotect. If nothing can be recovered the call returns 422 and the credit is not charged.

Costs 1 credit per call.

## Request body

- object
  - `file` string, byte, required: The damaged PDF to repair, base64-encoded. The "%PDF-" marker must appear in the first 1024 bytes of the file.
  - `output` 'json' | 'binary' | 'url' | 'pdf': How to return the PDF: "json" (base64 in the JSON response), "binary" (the PDF itself, ready for n8n/Make/Zapier) or "url" (a temporary download link, valid 15 minutes). Default: json when the request is JSON, binary when the input was sent raw.

## Response `200`

Result.

- object
  - `success` boolean
  - `pdf` string, byte
  - `meta` object
    - `repaired` boolean: true if the file had problems that were worked around; false if it was fine.
    - `pages` integer: Pages in the resulting PDF.
    - `warnings` string[]: qpdf notices about what was broken (up to 10, in English).
    - `warnings_total` integer
    - `original_size_bytes` integer
    - `size_bytes` integer
    - `used` integer: Credits used this month, after this call.
    - `remaining` integer, nullable: Credits left this month (null = unlimited).
    - `unlimited` boolean

## Other responses

- `400`: Invalid input (nothing is charged).
- `401`: Missing or invalid API key.
- `403`: Email not verified.
- `422`: Nothing could be recovered from the file (no readable pages). The credit is not charged.
- `429`: Monthly credit limit reached, or too many requests per minute for this key (see Retry-After).
- `503`: Server busy (queue full). Retry after the seconds in the Retry-After header.

---

[API](https://skmtc.dev/cofferdock/apis/cofferdock-api.md) · [All operations](https://skmtc.dev/cofferdock/apis/cofferdock-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cofferdock/apis/cofferdock-api/revisions/b57aa000d33a?raw)
