Getting started with the API

From zero to your first successful API call in under 5 minutes.

01

Sign up and start your free trial

Create an account at versafile.app/signup. No credit card required. You get 100 trial credits valid for 7 days.

02

Create an API key

Go to your Dashboard → API Keys → "Create new key". Give it a name (e.g. "development"), copy the key (it starts with sk_ppdf_), and store it securely. You cannot view it again after creation.

03

Make your first request

Send a multipart/form-data POST request with your PDF and the Authorization header. The example below merges two PDFs and saves the result:

curl -X POST https://versafile.app/api/v1/pdf/merge \
  -H "Authorization: Bearer sk_ppdf_your_key_here" \
  -F "file=@document1.pdf" \
  -F "file=@document2.pdf" \
  --output merged.pdf
04

Check the response headers

Every successful response includes three headers that tell you your current state:

x-versafile-credits-remaining: 99
x-versafile-plan: trial
x-request-id: 01HXYZ...
05

Extract text for AI endpoints

The AI extraction endpoints (/invoice-extract, /receipt-extract, etc.) take a JSON body with documentText, not a file. First extract the text, then pass it to the AI endpoint:

import requests

API_KEY = "sk_ppdf_your_key_here"
BASE = "https://versafile.app"

# Step 1: extract text
with open("invoice.pdf", "rb") as f:
    text_resp = requests.post(
        f"{BASE}/api/v1/pdf/text",
        headers={"Authorization": f"Bearer {API_KEY}"},
        files={"file": f},
    )
    doc_text = text_resp.json()["text"]

# Step 2: extract structured data
extract_resp = requests.post(
    f"{BASE}/api/v1/invoice-extract",
    headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json",
    },
    json={"documentText": doc_text},
)
print(extract_resp.json())
06

Handle errors gracefully

Check the HTTP status code. Common codes: 401 (bad API key), 402 (out of credits), 403 (plan inactive), and 413 (file too large for your plan). Each error response includes an error and code field:

{
  "error": "Insufficient credits.",
  "code": "insufficient_credits",
  "creditsRequired": 10
}
07

Go to production

When ready, upgrade from the dashboard billing tab. Store your API key in environment variables, use separate keys per environment, and monitor usage from the dashboard logs.

Need help?

Check the FAQ, the full API reference, or email support@versafile.app.