Inkspan › Guides › How to add a watermark to a PDF in Node.js
The /v1/pdf/watermark endpoint stamps a line of text across every page of a document in light grey, over the existing content. It is built for document-control workflows — marking drafts, flagging confidential copies, and labelling documents sent for review so they are not mistaken for final versions.
The watermark is applied to every page in one request, and the output is a normal PDF you can pass straight to another endpoint such as merge or compress.
import fs from 'node:fs';
const fd = new FormData();
fd.append('file', new Blob([fs.readFileSync('input.pdf')]), 'input.pdf');
fd.append('text', "CONFIDENTIAL");
const res = await fetch('https://api.inkspan.dev/v1/pdf/watermark', {
method: 'POST',
headers: { 'X-API-Key': process.env.INKSPAN_KEY },
body: fd,
});
if (!res.ok) throw new Error(await res.text());
fs.writeFileSync('watermarked.pdf', Buffer.from(await res.arrayBuffer()));
| Name | Type | Required | Description |
|---|---|---|---|
file | file | yes | The PDF to watermark. |
text | string | no | Watermark text. Defaults to CONFIDENTIAL. |
Returns a PDF as a binary stream with Content-Type: application/pdf and Content-Disposition: attachment; filename=watermarked.pdf. Write the response body straight to disk — do not parse it as JSON.
| Status | Meaning | Fix |
|---|---|---|
401 | Invalid or missing API key | Send your key in the X-API-Key header. |
402 | Monthly quota exceeded | The response reports used/quota. Upgrade at inkspan.dev/#pricing. |
422 | Missing or invalid parameter | Check required fields in the table above — the body names the offending field. |
Failed requests do not count against your quota; only successful ones are metered.
Not through this endpoint — it applies one house style. For full control, render your own overlay with /v1/generate/html and composite it.
Yes, every page of the document receives the same stamp in a single call.
Yes, by anyone with a PDF editor. Treat it as a label, not a security control.
Get a free API key →Related Manipulate guides: merge PDF files · split a PDF into pages · compress a PDF · convert a PDF to images · fill a PDF form