Core Concepts
Idempotency
Idempotency lets you safely retry API requests without creating duplicate side effects — essential for payment and fraud flows where network failures are common.
Inspired by Flutterwave's idempotency model, Scrub uses the Idempotency-Key header.
How it works
Send a unique key with any POST request to these endpoints:
POST /fraud/analyze/POST /fraud/report/POST /credit/report/POST /credit/inquiry/
POST /v1/fraud/analyze/
Authorization: Bearer YOUR_API_KEY
Idempotency-Key: idem_7k2m9x1p3q
Content-Type: application/json
{ ... }httpInteractive idempotency demo
Rules
| Rule | Detail |
|---|---|
| Key format | Any unique string up to 255 characters (UUIDs recommended) |
| Scope | Keys are scoped to your API key and endpoint path |
| TTL | Keys are stored for 24 hours |
| Same key, same body | Returns the original response with 200 OK |
| Same key, different body | Returns 409 Conflict with error code DUPLICATE_IDempotency |
| Missing key | Request is processed normally (not idempotent) |
Generating keys
import { randomUUID } from 'crypto';
const idempotencyKey = `idem_${randomUUID()}`;javascriptimport uuid
idempotency_key = f"idem_{uuid.uuid4()}"pythonWhen to use idempotency
- Always for fraud analysis on financial transactions
- Always for credit report generation (async, expensive)
- Recommended for fraud report submissions
- Not needed for read-only GET requests