Wipe all sandbox transactional data for the current tenant
const url = 'https://api.emite.cr/v1/tenants/me/sandbox/reset';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"confirmation":"SANDBOX"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.emite.cr/v1/tenants/me/sandbox/reset \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "confirmation": "SANDBOX" }'Destructive. Deletes sandbox invoices (+ children), submissions, idempotency keys, atv_tokens (next sandbox emission triggers re-auth), pending pg-boss jobs scoped to sandbox, and R2/S3 objects under tenants/<tenantId>/sandbox/. PRESERVES configuration: parties, items, branches, terminals, credentials, api_keys, users, branding, settings — and invoice_sequences (Hacienda dedups consecutivos server-side, so the local counter is authoritative and survives the reset). Requires literal confirmation: "SANDBOX" in the body.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Literal phrase that must equal exactly SANDBOX (case-sensitive). The former RESET SANDBOX is still accepted. Any other value rejects with 400.
Example
SANDBOXResponses
Section titled “Responses”Actual counts deleted (fresh measurements; may differ from preview).
object
Sandbox invoices that will be / were deleted (cascades to lines, taxes, discounts, payment methods, exonerations).
Sandbox hacienda_submissions rows deleted.
Sandbox idempotency_keys rows deleted.
Sandbox atv_tokens rows deleted (next sandbox emission triggers re-auth against Hacienda).
Pending pg-boss jobs cancelled (hacienda.poll, email.invoice-* in created/retry state).
R2/S3 objects deleted under tenants/<tenantId>/sandbox/ and legacy invoices/<id>/... keys. Best-effort — orphans are inert.
R2/S3 keys that failed to delete. Orphan, can be reaped by a sweeper later.
Examplegenerated
{ "invoicesDeleted": 1, "submissionsDeleted": 1, "idempotencyKeysDeleted": 1, "atvTokensRevoked": 1, "pendingJobsCancelled": 1, "blobsDeleted": 1, "blobsFailed": [ "example" ]}Missing or invalid JWT.
Sandbox reset requires the sandbox:reset scope (owner+admin only) AND a JWT session. API keys cannot trigger a reset.
Another sandbox reset is already in progress for this tenant (SANDBOX_RESET_IN_PROGRESS).