Skip to content

Wipe all sandbox transactional data for the current tenant

POST
/v1/tenants/me/sandbox/reset
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.

Media typeapplication/json
object
confirmation
required

Literal phrase that must equal exactly SANDBOX (case-sensitive). The former RESET SANDBOX is still accepted. Any other value rejects with 400.

string
Example
SANDBOX

Actual counts deleted (fresh measurements; may differ from preview).

Media typeapplication/json
object
invoicesDeleted
required

Sandbox invoices that will be / were deleted (cascades to lines, taxes, discounts, payment methods, exonerations).

number
submissionsDeleted
required

Sandbox hacienda_submissions rows deleted.

number
idempotencyKeysDeleted
required

Sandbox idempotency_keys rows deleted.

number
atvTokensRevoked
required

Sandbox atv_tokens rows deleted (next sandbox emission triggers re-auth against Hacienda).

number
pendingJobsCancelled
required

Pending pg-boss jobs cancelled (hacienda.poll, email.invoice-* in created/retry state).

number
blobsDeleted
required

R2/S3 objects deleted under tenants/<tenantId>/sandbox/ and legacy invoices/<id>/... keys. Best-effort — orphans are inert.

number
blobsFailed
required

R2/S3 keys that failed to delete. Orphan, can be reaped by a sweeper later.

Array<string>
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).