webcapture Get a free key

Convert a URL to PDF with curl

Two curl calls, one document: the POST hands the endpoint a url and comes back with a receipt, the GET trades the receipt's download url for the pdf bytes.

The convert endpoint is synchronous by default: the call holds until the render finishes, then answers 200 with a JSON receipt. The receipt is metadata, not the document; the bytes live behind the receipt's download url, and that url only answers to your key.

The recipe

ORIGIN="https://webcapture.io"

RECEIPT=$(curl -sS -X POST "$ORIGIN/v1/convert" \
  -H "Authorization: Bearer wc_your_key" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/"}')
echo "$RECEIPT"
# {"id": "cnv_9f2c01ab", "bytes": 158120, "attempts": 1,
#  "remaining": 49, "sourceUrl": "https://example.com/", "sourceType": "url",
#  "download": ".../v1/conversions/cnv_9f2c01ab.pdf"}

ID=$(printf '%s' "$RECEIPT" | sed -E 's/.*"id": *"([^"]+)".*/\1/')
case "$ID" in cnv_*) ;; *) echo "convert failed: $RECEIPT" >&2; exit 1 ;; esac

# fetch the bytes with the same header:
curl -sS -H "Authorization: Bearer wc_your_key" \
  -o page.pdf \
  "$ORIGIN/v1/conversions/$ID.pdf"

The first call renders example.com and answers with the receipt: id, bytes, attempts, remaining (renders left this month), sourceUrl, sourceType, and download. The second call fetches that download url and writes page.pdf. One render, one document against the key's quota, and the receipt's remaining field tells you where the month stands.

Same-key GET: 401 without it; 404 for another key.

The fields this recipe uses

Related

Method

Source: convert field reference, checked 2026-10-05. Corrections.