docimprint

← All docs

Authentication

Aly Sawft · Founder & Engineer, Sawftware LLC ·

How does DocImprint authentication work?

Two paths: Authorization: Bearer dr_live_… for API keys with monthly credits, or x402 USDC micropayments on Base where wallet address becomes resource owner. Both work on every paid endpoint.

Authentication

Two ways to call paid endpoints: API key (monthly credits, simplest setup) or wallet-native x402 (no account, pay per call in USDC). Verify and download endpoints are always free.

API keys

Send Authorization: Bearer dr_live_... (or X-API-Key). The gateway applies monthly quota and rate limits — no per-request wallet handshake.

bashAPI key request
# Capture a document as a tamper-evident evidence bundle
curl -X POST "https://api.docimprint.com/v1/extract?sync=true" \
  -H "Authorization: Bearer dr_live_..." \
  -H "Content-Type: application/json" \
  -d '{"source":"https://bitcoin.org/bitcoin.pdf","mode":"summarize"}'
jsonQuota exceeded (HTTP 402)
{
  "error": "Monthly quota exhausted",
  "quota": { "used": 5000, "limit": 5000, "remaining": 0 },
  "upgrade_url": "https://docimprint.com/pricing"
}

Plans, credit costs, and effective rates: Pricing · Get API key

x402 pay-per-call

No account needed. First request returns 402 Payment Required with USDC amount and recipient on Base. Sign an EIP-712 transfer, retry with X-Payment, and receive X-Payment-Receipt on success. Mainnet: eip155:8453. USDC contract: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913. The Try live playground supports both.

bashx402 handshake
# Every paid endpoint follows the same x402 handshake

# 1. First request → 402 Payment Required
#    Response headers include payment amount, recipient, and network (Base / USDC)

curl -X POST https://api.docimprint.com/v1/extract \
  -H "Content-Type: application/json" \
  -d '{"source": "https://cdn.example.com/report.pdf", "mode": "summarize"}'

# 2. Sign an EIP-712 USDC transfer for the amount in the 402 headers
#    Use x402-fetch (TypeScript), x402-client (Python), or manual signing

# 3. Retry with X-Payment header → 200 + result
curl -X POST https://api.docimprint.com/v1/extract \
  -H "Content-Type: application/json" \
  -H "X-Payment: <eip712-signed-usdc-transfer>" \
  -d '{"source": "https://cdn.example.com/report.pdf", "mode": "summarize"}'

# Successful responses include X-Payment-Receipt with the on-chain tx hash.
# Mainnet: eip155:8453 (Base). Testnet playground uses eip155:84532 (Base Sepolia).

Check your quota

GET /v1/quota returns your current billing period, credits used, and reset date. This call is always free — it never consumes credits.

bashCheck quota
# Check remaining credits — free, no quota consumed
curl https://api.docimprint.com/v1/quota \
  -H "Authorization: Bearer dr_live_..."
jsonResponse
{
  "plan_id": "free",
  "billing_period": "2026-05",
  "credits_used": 23,
  "monthly_credits": 100,
  "remaining": 77,
  "reset_at": "2026-06-01T00:00:00Z"
}

Credits reset on the first of each month (UTC). The reset_at field gives the exact timestamp.

Related