Build the code
Pick a tool, an OCR mode or a feature and set its options; the fields and checks are the same as on the tool page. Then add further steps: only tools that can read the previous step's output are offered, and you can reorder or remove steps. The generated code uploads your file once and runs every step on the server in one request. For more than 10 steps, see the workflows guide, which also shows how to add your own buttons and methods with the SDKs.
The code reads your key from WELLFRIEND_API_KEY and shows YOUR_API_KEY where it goes. Replace the sample files (input.pdf, input.png and so on) with your own. Keep the key on your server.
1. What do you want to do?
Every tool (55 entries, any file type) and every other API feature (161), in one list. Search by name, file type or area.
2. Settings
The same choices and checks as the tool page. Defaults are filled in; change only what you need.
- 1
Compress
Reads PDF → gives PDF
More options3 more
Request reference
POST /api/v2/document-operationswithtoolId: "compress-pdf". Make PDFs and images smaller without changing how they look. Every option of Compress{ "toolId": "compress-pdf", "parameters": { "profile": "medium" } }
3. Add a next step (optional)
Only tools that read a PDF (step 1's result) are offered.
4. Your code
What this code does
- Uploads your file (input.pdf) once.
- Step 1: Compress (profile medium).
- Waits until the tool has finished.
- Downloads the result as input-wellfriend.pdf.
What this costs
Enter your file's pages and size. The price comes from the API, so it is what a run is charged.
Each step uses 1 request unit, whatever its page count. OCR steps also use credits: 5 credits for up to 15 pages, then 3.5 credits per additional page, rounded up per job. Uploading the file uses 1 request unit and downloading the result 1 request unit.
#!/usr/bin/env bash
# Needs curl and jq.
# Your API key: set WELLFRIEND_API_KEY, or replace YOUR_API_KEY (keys: https://wellfriend.dev/dashboard/developer-api/keys).
set -euo pipefail
API="${WELLFRIEND_API_URL:-https://wellfriend.dev}"
WELLFRIEND_API_KEY="${WELLFRIEND_API_KEY:-YOUR_API_KEY}"
AUTH="Authorization: Bearer $WELLFRIEND_API_KEY"
RUN=$(uuidgen) # reuse this value to retry safely
# upload FILE CONTENT_TYPE KEY: prints the document id and its version id
upload() {
curl -sS --fail-with-body -X POST "$API/api/v2/documents" -H "$AUTH" -H "Idempotency-Key: $3" \
-H "Content-Type: $2" -H "X-Wellfriend-Filename: $(basename "$1")" --data-binary "@$1" \
| jq -r '"\(.document.id) \(.document.currentVersion.id)"'
}
read -r DOCUMENT_ID VERSION_ID < <(upload 'input.pdf' 'application/pdf' "$RUN-upload")
# Run compress-pdf
OP=$(jq -n --arg doc "$DOCUMENT_ID" --arg ver "$VERSION_ID" --arg key "$RUN-1" \
--argjson parameters '{"profile":"medium"}' \
'{documentId: $doc, versionId: $ver, toolId: "compress-pdf", parameters: $parameters, idempotencyKey: $key}' \
| curl -sS --fail-with-body -X POST "$API/api/v2/document-operations" -H "$AUTH" \
-H "Content-Type: application/json" -H "Idempotency-Key: $RUN-1" --data-binary @- | jq -r .operation.id)
while :; do
RESULT=$(curl -sS --fail-with-body "$API/api/v2/document-operations/$OP" -H "$AUTH")
STATE=$(echo "$RESULT" | jq -r .operation.state)
case "$STATE" in completed) break ;; failed|cancelled|canceled) echo "$RESULT" >&2; exit 1 ;; esac
sleep 1
done
DOCUMENT_ID=$(echo "$RESULT" | jq -r .operation.outputDocumentId)
VERSION_ID=$(echo "$RESULT" | jq -r .operation.outputVersionId)
# Download the result
curl -sS --fail-with-body "$API/api/v2/documents/$DOCUMENT_ID/versions/$VERSION_ID/content" -H "$AUTH" -o 'input-wellfriend.pdf'Your API key goes where the code says YOUR_API_KEY, or set WELLFRIEND_API_KEY. Your key is never shown on this page. Replace the sample file names with your own files.
Every tool and OCR mode
Each link opens the builder with that tool as the first step. OCR modes (searchable PDF, text, Markdown, Word, Excel, JSON and AI field extraction) are in the builder's OCR and AI group.
- Add Page Numbersadd-page-numbers · PDF tools
- Add Watermarkadd-watermark · PDF tools
- Check & Edit Metadataedit-metadata · PDF tools
- Check PDFcheck-pdf · PDF tools
- Compresscompress-pdf · PDF tools
- Crop PDFcrop-pdf · PDF tools
- Flatten PDFflatten-pdf · PDF tools
- Merge PDFmerge-pdf · PDF tools
- N-up PDFn-up-pdf · PDF tools
- OCR PDFocr-pdf · PDF tools
- Organize PDForganize-pdf · PDF tools
- PDF Table Extractionpdf-table-extraction · PDF tools
- Protect PDFprotect-pdf · PDF tools
- Redact PDFredact-pdf · PDF tools
- Repair PDFrepair-pdf · PDF tools
- Rotate PDFrotate-pdf · PDF tools
- Sanitize PDFsanitize-pdf · PDF tools
- Scale PDFscale-pdf · PDF tools
- Sign PDFsign-pdf · PDF tools
- Split PDFsplit-pdf · PDF tools
- Unlock PDFunlock-pdf · PDF tools
- CSV to PDFcsv-to-pdf · Convert tools
- Excel to PDFexcel-to-pdf · Convert tools
- Image to PDFimage-to-pdf · Convert tools
- JSON to PDFjson-to-pdf · Convert tools
- Markdown to PDFmarkdown-to-pdf · Convert tools
- PDF to Chunkspdf-to-chunks · Convert tools
- PDF to EPUBpdf-to-epub · Convert tools
- PDF to Excelpdf-to-excel · Convert tools
- PDF to HTMLpdf-to-html · Convert tools
- PDF to Imagespdf-to-images · Convert tools
- PDF to JSONpdf-to-json · Convert tools
- PDF to Markdownpdf-to-markdown · Convert tools
- PDF to PowerPointpdf-to-powerpoint · Convert tools
- PDF to Textpdf-to-text · Convert tools
- PDF to Wordpdf-to-word · Convert tools
- PDF/A Conversionpdfa-conversion · Convert tools
- PowerPoint to PDFpowerpoint-to-pdf · Convert tools
- SVG to PDFsvg-to-pdf · Convert tools
- Text to PDFtext-to-pdf · Convert tools
- Web page to PDF or imageweb-capture · Convert tools
- Word to PDFword-to-pdf · Convert tools
- Convert from JPGconvert-from-jpg · Image tools
- Convert to JPGconvert-to-jpg · Image tools
- Crop Imagecrop-image · Image tools
- Image Metadataimage-metadata · Image tools
- Resize Imageresize-image · Image tools
- Rotate Imagerotate-image · Image tools
- Watermark Imagewatermark-image · Image tools
Other API features
Secure Links, Deal Rooms, portals, signatures, forms, templates, the OCR jobs API, workflows, webhooks, connectors, embeds, analytics and keys are single requests. The builder's Other API features tab prints each with its request body, which you can edit; the Snippets catalogue lists every one with its scopes.