Documentation

Quick start

1. Get a key

Sign up at smartpdf.ru and confirm your email: 300 ₽ will be credited to your API balance, enough for about 1,200 requests at the current price. In your dashboard, in the “API and MCP” section, create a key: it’s shown only once.

export SMARTPDF_API_KEY=sk_live_…

2. Run the full cycle

The example compresses document.pdf and saves the result next to it as document_smartpdf.pdf. The code in every language has been verified by running it against the API.

Compress PDF
#!/usr/bin/env bash
# SmartPDF API — Compress PDF: upload → operation → wait → download.
# Requires curl and jq.
# Get an API key in your dashboard: https://smartpdf.ru/en/dashboard/api-keys
set -euo pipefail
API="https://api.smartpdf.ru/v1"
AUTH="X-API-Key: $SMARTPDF_API_KEY"

# 1. Upload the file
FILE_ID=$(curl -sS --fail-with-body -H "$AUTH" -F "file=@document.pdf" "$API/upload" | jq -r .file_id)

# 2. Start the operation
BODY=$(jq -n --arg file_id "$FILE_ID" '{file_id: $file_id, level: "medium"}')
TASK_ID=$(curl -sS --fail-with-body -H "$AUTH" -H "Content-Type: application/json" \
  -d "$BODY" "$API/pdf/compress" | jq -r .task_id)

# 3. Wait for the result
while :; do
  TASK=$(curl -sS --fail-with-body -H "$AUTH" "$API/tasks/$TASK_ID")
  STATUS=$(echo "$TASK" | jq -r .status)
  [ "$STATUS" = done ] && break
  [ "$STATUS" = failed ] && { echo "Processing error: $(echo "$TASK" | jq -r .error)" >&2; exit 1; }
  sleep 2
done

# 4. Download the result
RESULT=$(curl -sS --fail-with-body -H "$AUTH" "$API/tasks/$TASK_ID/download")
curl -sS --fail-with-body -o "$(echo "$RESULT" | jq -r .filename)" "$(echo "$RESULT" | jq -r .download_url)"
echo "Done: $(echo "$RESULT" | jq -r .filename)"
bash quickstart.sh — requires curl and jq

3. Next steps

  • Operations — parameters for each of the 47 operations; only step 2 changes, everything else stays as shown here.
  • Webhooks — a completion notification instead of polling the status.
  • Errors and limits — what to check in production.
  • MCP server — the same operations for AI agents.

This page for agents: Markdown · llms.txt