---
title: "Shrink a PDF by recompressing its embedded JPEGs"
method: POST
path: "/pdf-compress"
tags: ["PDF"]
---

# Shrink a PDF by recompressing its embedded JPEGs

`POST /pdf-compress`

## Request

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

Finds every embedded JPEG image and re-encodes it at the given quality, leaving text and fonts untouched. Only affects images stored as JPEG (/DCTDecode); other internal image formats are left as-is. If the result would not be smaller, the original is returned unchanged.

Costs 1 credit per call.

## Request body

- object
  - `file` string, byte, required: The PDF to compress, base64-encoded.
  - `quality` integer: JPEG quality (10-90) used to re-compress the images inside the PDF: lower = smaller file but blurrier images. Default 50.
  - `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
    - `images_compressed` integer
    - `original_size_bytes` integer
    - `size_bytes` integer
    - `reduction_percent` 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.
- `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)
