Ex Extract API

Billing & credits

Extract API bills by PDF page — one credit = one page. Multi-page files reserve credits for every page up front; failed extractions and cache hits refund or skip the charge.

Credit rules

  • Charged: successful extraction, cached: false — credits equal to page_count
  • Free / refunded: cache hits, failed extractions, cancelled jobs
  • Cap: max 20 pages per request (EXTRACT_MAX_BILLABLE_PAGES)
  • Monthly free: 15 page credits after email verification

Check balance

GET https://cyber.lerepop.lv/api/v1/account/balance
Authorization: Bearer ext_live_...
{
  "balance": 87,
  "currency": "pages",
  "unit": "page_credit",
  "purchased": 72,
  "free_monthly": 15
}

Usage statistics

GET https://cyber.lerepop.lv/api/v1/account/usage

Returns 30-day stats: total requests, completed, cached, failed, avg confidence, avg processing time.

Buy credit packs

POST https://cyber.lerepop.lv/api/v1/account/checkout
Content-Type: application/json
Authorization: Bearer ext_live_...

{ "pack": "pack_100" }

Available packs (page credits):

packCreditsPrice
pack_2020 pages€7
pack_100100 pages €29
pack_10001000 pages €199

Response:

{
  "checkout_url": "https://checkout.stripe.com/c/pay/cs_...",
  "session_id": "cs_..."
}

Redirect your user to checkout_url. After payment, Stripe webhook credits your account automatically.

Checkout redirect URLs

  • Success: https://cyber.lerepop.lv/checkout/success
  • Cancel: https://cyber.lerepop.lv/checkout/cancel

These are informational pages — balance updates happen via webhook, not redirect.

Insufficient credits

When balance is below the PDF page count, POST /extract returns:

HTTP 402 Payment Required
{
  "error": "insufficient_credits",
  "message": "Insufficient page credits. This PDF requires 3 credit(s) (1 per page).",
  "balance": 1,
  "credits_required": 3
}

PDFs over the page cap return HTTP 422 with error: too_many_pages.

Stripe configuration

Required environment variables (server-side only):

  • STRIPE_SECRET_KEY
  • STRIPE_WEBHOOK_SECRET
  • STRIPE_PRICE_PACK_20 — Stripe Price ID
  • STRIPE_PRICE_PACK_100 — Stripe Price ID
  • STRIPE_PRICE_PACK_1000 — Stripe Price ID