Documentation

Webhooks

How to enable

Pass webhook_url — an https address of your server — in the operation request. When the operation finishes, SmartPDF sends a POST request with JSON to it:

{
  "event": "task.done",
  "task_id": "3f2c5b0e-8a41-4d7e-9c1f-5d0b8f2e7a64",
  "operation_type": "compress",
  "status": "done",
  "timestamp": "2026-10-05T11:00:00.512341+00:00",
  "download_url": "https://api.smartpdf.ru/v1/tasks/3f2c5b0e-…/file?token=…",
  "filename": "document_smartpdf.pdf"
}

For a failed operation, you get "event": "task.failed" and error_message instead of the link: the same text as in the error field of the task status. The link in the webhook is valid for an hour.

Delivery

Respond with a 2xx code. Otherwise, there will be three more attempts — after 10, 30 and 90 seconds. Redirects are not followed.

Headers:

  • X-SmartPDF-Event — the event, as in the body;
  • X-SmartPDF-Delivery — the operation id, the same for all retries: use it to discard duplicates;
  • X-SmartPDF-Signature: t=<unix-time>,v1=<signature>.

Verifying the signature

The secret is in your dashboard, in the “API and MCP” section; you can also issue a new one there, and the old one stops working immediately. The signature is HMAC-SHA256 of the string <t>.<raw request body>, in hex. Compare it in constant time and reject requests older than 5 minutes. Verify the raw request body, before parsing the JSON.

Signature verification
# verify <secret> <request body file> <X-SmartPDF-Signature header> — requires openssl and date
verify() {
  local secret=$1 body=$2 header=$3 t v1 now expected
  t=$(printf "%s" "$header" | tr "," "\n" | sed -n "s/^t=//p")
  v1=$(printf "%s" "$header" | tr "," "\n" | sed -n "s/^v1=//p")
  now=$(date +%s)
  [ -n "$t" ] && [ $((now - t)) -le 300 ] && [ $((t - now)) -le 300 ] || return 1
  expected=$({ printf "%s." "$t"; cat "$body"; } | openssl dgst -sha256 -hmac "$secret" -hex | sed "s/^.* //")
  [ "$expected" = "$v1" ]
}

Each example has been verified by running it: a genuine signature is accepted, while a tampered body and an old timestamp are rejected.

This page for agents: Markdown · llms.txt