Build API
The instructions of /v1/build, part by part.
POST /v1/build takes multipart/form-data: each file in a field of its own, and an
instructions field with JSON. The instructions name the files by their field.
{
"parts": [ … ],
"actions": [ … ],
"output": { … }
}Unknown fields are refused with invalid_request, so a typo never passes silently. Every file
sent must be used by a part.
curl https://api.nexpdf.dev/v1/build \
-H "Authorization: Bearer $NEXPDF_API_KEY" \
-F contract=@contract.pdf \
-F annex=@annex.docx \
-F 'instructions={
"parts": [
{
"file": "contract"
},
{
"file": "annex",
"pages": {
"start": 0,
"end": 1
}
}
],
"actions": [
{
"type": "rotate",
"degrees": 90,
"pages": [
2
]
},
{
"type": "delete_pages",
"pages": [
0
]
}
]
}' \
-o packet.pdfParts
Up to 20, joined in order. Each part has either file or html.
Prop
Type
Actions
Up to 50, applied in order to the joined document. pages lists count from 0.
type | Fields | Guide |
|---|---|---|
ocr | languages (optional, such as eng+por) | OCR |
watermark | text | Watermark |
rotate | degrees (90, 180 or 270; negative turns the other way); pages (optional, all pages when left out) | Pages |
delete_pages | pages | Pages |
flatten_annotations, flatten_forms | None | Forms |
fill_form | values: { "field name": value } | Forms |
redact | query; mode: text (default), regex or pattern; fill_white | Redaction |
pdfa | level: 1a, 1b, 2a, 2b (default), 2u, 3a, 3b or 3u | PDF/A |
pdfua | part (1 or 2), lang | Accessibility |
optimize | None | Optimize |
encrypt | owner_password; user_password and permissions (optional). Last action only, with PDF output. | Encrypt |
sign | All optional: certificate (the field of an uploaded PKCS#12 file; self-signed when left out), password, name, reason, location, contact, field, appearance (page, rect, text). Last action only, with PDF output that is not linearised. | Digital signatures |
Output
Optional; a PDF when left out.
type | Fields | Returns |
|---|---|---|
pdf | linearize | |
png | page (from 0), dpi (36–300, default 150) | A PNG of one page |
markdown, html, json | None | The text of the document |
docx, xlsx | None | A Word or Excel file |
split | every (pages per file) or ranges (a list of { "start", "end" }) | A ZIP of PDFs, part-1.pdf, part-2.pdf… (Split) |
Cost
The parts and actions are counted as if they were separate calls; see limits and pricing. A job that would need more units than are left this month is refused before it runs.