Developer API

Snippeted: the snippet builder

Code for any tool or feature with your own settings, or a pipeline of up to 10 tools on one upload, in cURL, Node, Python, the TypeScript, Python and Go SDKs and the CLI, with your API key as a placeholder.

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. 1

    Compress

    Reads PDF → gives PDF

    Options

    How hard to compress.

    A size to aim for, in the unit beside it.

    More options3 more
    More options
    %

    How far above the target still counts as reaching it. 5–10 %.

    Images only. Keep copies the camera and editing details; Strip removes them but keeps the orientation and colour profile.

    Optional. The extension is added for you.

    Request reference

    POST /api/v2/document-operations with toolId: "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

  1. Uploads your file (input.pdf) once.
  2. Step 1: Compress (profile medium).
  3. Waits until the tool has finished.
  4. 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.

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.