Boleta API · v1
Reference
All requests go to https://boleta.offsetworks.xyz. All responses are JSON. Errors return { error, details? } with a 4xx/5xx status.
Quickstart
The two-step flow most consumers use:
// 1) Issue a reference code for the expected payment
const ref = await fetch('https://boleta.offsetworks.xyz/api/v1/references', {
method: 'POST',
headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
merchantSlug: 'OBRO',
whiteLabel: true,
expectedAmount: 1500,
currency: 'GTQ',
account: { bank: 'BI', accountNumber: '...', accountHolder: '...' },
metadata: { invoiceId: 'inv_42' }
})
}).then(r => r.json())
// → { code: 'OBRO-A7K2', referenceCodeId, accountId, depositInstructions: {...} }
// 2) Later, parse the customer's screenshot of their bank confirmation
const result = await fetch('https://boleta.offsetworks.xyz/api/v1/parse', {
method: 'POST',
headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
fileUrl: '<the public URL of the file you uploaded to /v1/uploads>',
contentType: 'image/png',
merchantSlug: 'OBRO',
expectedCodes: [ref.code],
expectedAmount: 1500,
currency: 'GTQ',
})
}).then(r => r.json())
// → { ok, rows: [{ referenceCode, amount, confidence, status, ... }], meta }Even simpler: redirect your payer to https://boleta.offsetworks.xyz/r/{code} and they upload the screenshot themselves. You get the webhook.
Auth
Every API call requires a bearer token in the Authorization header. Tokens look like bol_live_PREFIX_secret (production) or bol_test_PREFIX_secret (sandbox). They're stored hashed (SHA-256) — the plaintext is shown once when minted and is unrecoverable.
curl -H "Authorization: Bearer bol_live_XXXXXX_..." \
https://boleta.offsetworks.xyz/api/v1/banksDashboard auth is the same token in an HTTP-only cookie set by the /login form. The cookie is also accepted as fallback for API endpoints.
POST /v1/references · Issue a reference code
Mints a BOL-{MERCHANT}-{CODE} or (white-label) {MERCHANT}-{CODE} reference and persists a ReferenceCoderow when an Account can be resolved. Returns deposit instructions (QR text, WhatsApp message, bank deep link) ready to share with the payer.
Request
{
"merchantSlug": "OBRO", // 2-6 chars, immutable, your tenant slug
"whiteLabel": true, // optional. true = no BOL- prefix
"expectedAmount": 1500, // positive number
"currency": "GTQ", // GTQ | USD
"accountId": "uuid", // OR pass account below to find-or-create
"account": {
"bank": "BI", // BI | BAC | BANRURAL | GYT | BAM | PROMERICA | BANTRAB | INMOBILIARIO | AZTECA | VIVIBANCO | OTHER
"accountNumber": "123-456",
"accountHolder": "Empresa S.A."
},
"metadata": { "invoiceId": "..." },// optional, travels in webhooks
"expiresAt": "2026-06-01T00:00:00Z" // optional, default +30 days
}Response 200
{
"ok": true,
"code": "OBRO-A7K2",
"referenceCodeId": "uuid", // present when persisted
"accountId": "uuid",
"expectedAmount": 1500,
"currency": "GTQ",
"metadata": {...},
"depositInstructions": {
"code": "OBRO-A7K2",
"qrPayload": "Depósito a Banco Industrial\nCuenta: ...",
"whatsappText": "Hola, te confirmo el depósito:...",
"deepLink": "bibanca://transfer?account=...&amount=...&memo=..."
},
"persisted": true
}POST /v1/uploads · Upload a file to permanent Arweave storage
Forwards a multipart/form-data upload to Stash and returns a permanent Irys/Arweave URL. Pass that URL to /v1/parse. The same URL is parseable multiple times (e.g. tier-1 cheap pass, then tier-2 escalation).
Request
curl -X POST https://boleta.offsetworks.xyz/api/v1/uploads \
-H "Authorization: Bearer bol_live_..." \
-F "file=@/path/to/screenshot.png" \
-F "accountId=<uuid>" # optional; needed for /v1/parse persistenceResponse 200
{
"ok": true,
"upload": {
"id": "stash-uuid",
"statementUploadId": "uuid", // present when accountId resolved
"filename": "screenshot.png",
"contentType": "image/png",
"size": 41161,
"url": "https://devnet.irys.xyz/...", // hand this to /v1/parse
"arweaveId": "...",
"createdAt": "2026-05-24T..."
}
}POST /v1/parse · Parse + reconcile
Fetches the file by URL, dispatches to the chosen parser tier, reconciles against the expected codes, and returns reconciled rows. Auto-persists to PaymentVerification when an account can be resolved (explicit accountId → expected-code lookup → single-account tenants).
Request
{
"fileUrl": "https://devnet.irys.xyz/...",
"contentType": "image/png",
"merchantSlug": "OBRO",
"expectedCodes": ["OBRO-A7K2", "OBRO-K4N7"],
"expectedAmount": 1500,
"currency": "GTQ",
"amountTolerance": 2, // optional, default ±2
"policy": { "mode": "recommended" },// default. Also "cheapest" | "most-accurate" | "auto" | { mode: "fixed", providerId }
"accountId": "uuid", // optional, otherwise auto-resolved
"statementUploadId": "uuid", // optional, links the parse to the upload row
"webhook": {
"url": "https://your-app.com/boleta-webhook",
"secret": "whsec_...",
"events": ["verification.matched"],
"timeoutMs": 5000
}
}Response 200
{
"ok": true,
"rows": [
{
"referenceCode": "OBRO-A7K2",
"amount": 1500,
"date": "2026-05-23",
"senderName": "Juan García",
"rawDescription": "TRANSF OBRO-A7K2 JUAN GARCIA",
"confidence": "high",
"status": "AUTO_MATCHED"
}
],
"irrelevantCount": 4,
"meta": {
"tier": 2, "provider": "claude-haiku-4-5",
"model": "claude-haiku-4-5-20251001", "durationMs": 3400,
"costUsd": 0.0048, "retried": false
},
"persistedVerificationIds": ["uuid"],
"webhookDeliveries": [{...}]
}POST /v1/deposit-instructions · Build payloads without issuing a code
Pure helper — no auth required. Returns QR text + WhatsApp message + bank-app deep link for any (bank, account, amount, reference) tuple.
{
"bank": "BI",
"accountNumber": "123-456",
"accountHolder": "Empresa S.A.",
"amount": 1500,
"currency": "GTQ",
"reference": "OBRO-A7K2"
}
// →
{
"qrPayload": "...",
"whatsappText": "...",
"deepLink": "bibanca://..."
}GET /v1/banks · Public catalog
Returns the catalog of Guatemalan banks + account types. No auth required. Use to populate dropdowns.
POST /v1/r/[code]/receipt · Payer-side receipt upload
Public endpoint — the reference code IS the access token. The payer uploads their bank screenshot directly; Boleta uploads it to Stash, parses inline, persists, auto-closes the reference on a HIGH match, and fires the merchant's webhook. IP-throttled to 3 attempts per code per minute.
This is what the /r/{code} public page calls under the hood.
Webhooks
Pass webhook in /v1/parse requests OR set webhookUrl + webhookSecret on an Account to receive HMAC-SHA256-signed POSTs. Events: verification.matched, verification.needs_review, parse.completed.
Headers
X-Boleta-Signature: t=<unix-ms>,v1=<hex-hmac-sha256(secret, "<t>.<rawBody>")>
X-Boleta-Event: verification.matched
X-Boleta-Delivery: <uuid>
Content-Type: application/jsonVerify signature (Node)
import crypto from 'node:crypto'
function verify(headers, secret, rawBody) {
const m = /^t=(\d+),v1=([0-9a-f]+)$/.exec(headers['x-boleta-signature'] ?? '')
if (!m) return false
const expected = crypto.createHmac('sha256', secret).update(`${m[1]}.${rawBody}`).digest('hex')
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(m[2]))
}Failed inline deliveries are persisted to WebhookDelivery and retried by the worker with exponential backoff: 30s, 5m, 30m, 2h, 12h, 24h then abandoned. Retry an abandoned delivery manually from the dashboard.
Provider tiers
| Tier | Provider ID | Cost | Latency | Notes |
|---|---|---|---|---|
| 0 | regex | $0 | <100ms | Text/CSV only |
| 1 | tesseract+groq-llama | ~$0.00005 | 1-30s | Local OCR + tiny LLM extraction |
| 2 | claude-haiku-4-5 | ~$0.0015 | 2-4s | Default (policy recommended). Native vision. |
| 3 | claude-sonnet-4-6 | ~$0.05 | 5-15s | Fallback when Haiku fails |
@boleta/sdk
Zero-dep, isomorphic TypeScript client. Same surface as the REST API but typed and ergonomic.
pnpm add @boleta/sdk
import { Boleta } from '@boleta/sdk'
const boleta = new Boleta({ apiKey: process.env.BOLETA_API_KEY })
const result = await boleta.uploadAndParse(file, {
merchantSlug: 'OBRO',
expectedCodes: ['OBRO-A7K2'],
expectedAmount: 1500,
})Embeddable widget
Drop a Boleta deposit + receipt-upload widget into any third-party page. Two lines: a script tag pointing at the per-code widget bundle, and a div with the reference code as a data attribute.
<div data-boleta-code="OBRO-A7K2"></div>
<script src="https://boleta.offsetworks.xyz/widget/r/OBRO-A7K2"></script>The widget fetches public metadata, renders the deposit instructions with the amount + reference highlighted, and shows a "Subir comprobante" button that uploads directly to /v1/r/:code/receipt. The same webhook fires that fires from the hosted public page. MATCHED/EXPIRED/VOID states render a closed-state card instead of the upload UI.
The bundle is ~3KB, has zero runtime deps, works in every modern browser, and CORS is open.
GET /v1/audit · Tenant-scoped audit log
Returns the audit-log rows for your tenant (every mutation through /api/internal/* writes one). Cursor-paginated; pass the returned nextCursor on the next request to walk further back.
GET /api/v1/audit?limit=50&resourceType=Account&action=account.update
→
{
"ok": true,
"items": [
{
"id": "uuid",
"action": "account.update",
"resourceType": "Account",
"resourceId": "uuid",
"apiKeyPrefix": "bol_live_…",
"before": null,
"after": { "displayName": "…", "defaultPolicy": "AUTO", "webhookSecret": "<redacted>" },
"ip": "1.2.3.4",
"userAgent": "Mozilla/5.0 …",
"createdAt": "2026-05-24T…"
}
],
"nextCursor": "uuid-or-null"
}Errors
Standard HTTP status codes:
400— bad request body (Zod validation;detailshas the field-level errors)401— missing / invalid / revoked API key403— wrong scope or tenant ownership mismatch404— resource not found within your tenant409— state conflict (e.g. reference not OPEN)413— file too large (10MB limit)429— rate-limited (public receipt endpoint only, for now)502— upstream failure (Stash, parser provider)