SwapTxt SwapTxt
API Documentation

SwapTxt REST API Reference

Complete developer reference for SwapTxt /v1/ocr, /v1/edits, /v1/account, rate limits, idempotency keys, and HMAC-SHA256 webhook verification.

Authentication & Rate Limits

Pass your key in the Authorization: Bearer <API_KEY> header. Per-account limits are 30 POST submissions/minute, 240 GET reads/minute, 10 concurrent running jobs, and 30 queued jobs.

Core Endpoints

  • POST /v1/ocr — Extracts text lines and integer [x, y, w, h] boxes on a 0–1000 scale. Same image within 24 hours returns charged_ocr: 0.
  • POST /v1/edits — Accepts image_id, image_url, image_base64, or multipart image plus 1–20 replacements. Omit box for automatic OCR matching (match: all | first); unmatched text returns 422 text_not_found without charging.
  • GET /v1/edits/{id} — Returns queued (with queue_position and estimated_seconds), processing, succeeded (Results A, B, C), or failed (auto-refunded).
  • GET /v1/account — Returns remaining edit/OCR balances, active packs, and account limits.

Signed Webhooks

Pass an HTTPS callback_url on POST /v1/edits. When the job finishes, SwapTxt posts the final edit JSON signed with X-SwapTxt-Signature: sha256=<hmac> and retries failed deliveries after 1, 5, and 30 minutes.

Download the full OpenAPI 3.1 YAML specification →