Skip to content

API

A PDF API for one cent

Compress, merge and convert from your code. $0.01 per document, the first 100 per month free. No subscription, no minimum.

The API processes files on the server

Unlike the browser editor, the API sends the file to our server. It is processed in memory, never written to disk and not kept after the response; file names are not stored. For documents that must not leave your network, use the browser or Enterprise.

Authentication

Bearer key in the header

Create a key in your dashboard. It starts with sd_live_ and is shown once: we only store its hash. Send the key with every request:

Authorization: Bearer sd_live_XXXXXXXXXXXXXXXXXXXXXXXX

Request body — multipart/form-data with fields file or a raw file with Content-Type: application/pdf | image/png | image/jpeg. The response is the finished PDF. Limit — 100 MB per file and 50 files per request.

Endpoints

Three operations

POST/api/v1/compress

Compress

Lossless compression: removes Info and XMP metadata and unused objects, rebuilds the document with object streams. The result is never larger than the original.

file
One PDF. Can be sent as a raw body with Content-Type: application/pdf.
curl
curl -X POST https://lockpage.tools/api/v1/compress \
  -H "Authorization: Bearer $LOCKPAGE_KEY" \
  -F file=@contract.pdf \
  -o contract.min.pdf
POST/api/v1/merge

Merge

Merges PDFs in the order of the file fields. 2 to 50 files per request.

file
Repeated field, 2 to 50 PDFs. Order is preserved.
curl
curl -X POST https://lockpage.tools/api/v1/merge \
  -H "Authorization: Bearer $LOCKPAGE_KEY" \
  -F file=@act.pdf \
  -F file=@invoice.pdf \
  -o merged.pdf
POST/api/v1/convert

Convert

The server supports PNG and JPEG → PDF: every image becomes a page. Other directions return 501 not_implemented — for now they work only in the browser.

file
One or more PNG/JPEG images.
to
Target format: pdf. For a raw body use the query parameter ?to=pdf.
curl
curl -X POST "https://lockpage.tools/api/v1/convert?to=pdf" \
  -H "Authorization: Bearer $LOCKPAGE_KEY" \
  -H "Content-Type: image/jpeg" \
  --data-binary @scan.jpg \
  -o scan.pdf

Responses

Success and errors

A successful response is a PDF with usage headers. An error is JSON with a machine code and a human-readable message you can show to users.

200 OK
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="securadoc-merge.pdf"
Cache-Control: no-store
X-Lockpage-Documents: 2
X-Lockpage-Price-Usd-Per-Document: 0.01

%PDF-1.7 …
Error
HTTP/1.1 400 Bad Request Content-Type: application/json { "error": { "code": "bad_request", "message": "merge needs at least two files" } }
HTTPcodeWhen
400bad_requestNo files, wrong set of files for the operation, damaged PDF
401unauthorizedNo Authorization header, invalid or revoked key
413too_largeFile is larger than 100 MB
415unsupported_media_typeInput file format is not supported
501not_implementedThis conversion is not available on the server yet
500internalInternal error. Please try again later.
Node.js 20+
const form = new FormData();
form.append("file", new Blob([await fs.readFile("a.pdf")]), "a.pdf");
form.append("file", new Blob([await fs.readFile("b.pdf")]), "b.pdf");

const res = await fetch("https://lockpage.tools/api/v1/merge", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.LOCKPAGE_KEY}` },
  body: form,
});
if (!res.ok) throw new Error((await res.json()).error.message);
await fs.writeFile("merged.pdf", Buffer.from(await res.arrayBuffer()));

Usage

How pricing works

A document is one input file in a successful request: merging three PDFs counts as three documents. Failed requests are free. The first 100 documents each calendar month are free, then $0.01 per document. Your current month's usage is shown in the dashboard.

Documents per monthCost
up to 100Free
1,000$9
10,000$99
100,000$999