# Developer sandbox

> Build and verify a Relvo integration with isolated test data

Source: https://app.relvoerp.com/docs/product/guides/sandbox/

Use `https://app.relvoerp.com/api/v1/sandbox` as your test API base. It shares the main app's infrastructure while keeping test data in a separate organization. An OWNER or ADMIN opens **Settings → Developers → API keys**, clicks **Crear sandbox de integración**, and is switched into the empty test workspace. Its creator is the owner; no production data or credentials are copied. A persistent Sandbox banner identifies the selected workspace.

## Your first integration

Open **Settings → Developers**. The checklist reads your organization's actual
issuer, keys, customer, active contract, invoice and successful webhook delivery.
Metrics and usage are additional steps for usage-based billing. Refresh progress
after making changes; errors never count as completed work.

Create a fictional issuer, customer and customer billing entity, using USD for
the examples below. Issue a temporary `full_access` sandbox key, store it in your
secret manager, and expose it to your terminal as `RELVO_API_TOKEN`. Narrowly scoped
keys remain recommended for your final integration. Keys are displayed once.
The token prefix does not determine access: the authenticated key
belongs to one organization, whose current mode must be sandbox. Never commit keys or paste them into verification websites.

```bash
curl --fail-with-body https://app.relvoerp.com/api/v1/sandbox \
  -H "Authorization: Bearer $RELVO_API_TOKEN"
```

This authenticated operation requires `full_access` and returns `runtime`,
`tenant_mode`, and `organization_id`. `tenant_mode` must be `sandbox`. On the main app, `runtime` is `prod`; this is expected.
A live organization key receives `403` from the sandbox API. All resource paths
match the normal API, replacing `/api/v1/public` with `/api/v1/sandbox`.
For an SDK, generate your client from [the sandbox OpenAPI contract](https://app.relvoerp.com/sandbox-openapi.json); it contains the same operations and schemas with sandbox paths.

## Run a billing example

The repository includes `scripts/sandbox_scenarios.py`, which calls ordinary public
APIs and creates no financial rows directly. Record a UUIDv7 run ID and reuse the
same ID and inputs after a timeout. Each step reuses its idempotency key.

```bash
uv run python scripts/sandbox_scenarios.py \
  --scenario graduated --run-id "$RELVO_RUN_ID" \
  --issuer-id "$RELVO_SANDBOX_ISSUER_ID" \
  --customer-id "$RELVO_SANDBOX_CUSTOMER_ID" \
  --billing-entity-id "$RELVO_SANDBOX_BILLING_ENTITY_ID" \
  --period-start 2026-10-01 --period-end 2026-11-01
```

Choose a completed calendar month, with an exclusive end date. The receiver must
bill in USD. Use a fresh run ID for a different scenario or different inputs.

| Scenario | Inputs | Independently expected USD subtotal |
|---|---|---|
| `fixed` | One complete month at 100 | 100.00 |
| `usage` | 1,500 units at 0.01 | 15.00 |
| `graduated` | First 1,000 units at 0.01; next 500 at 0.005 | 12.50 |
| `minimum` | Usage of 15, with a minimum of 25 | 25.00 |

The runner waits for usage receipts to become `processed` before activating the
contract, then waits for the ordinary billing worker to produce the invoice. It
compares the actual native-currency subtotal with the table. Taxes and provider
issuance are separate. Exit 75 means usage or billing is still pending; rerun with
identical inputs. A mismatch fails rather than being marked successful. No test
clock is installed, and the script never issues a fiscal document or payment.

## Verify and debug webhooks

In the sandbox workspace developer page, register a public HTTPS receiver. The default
subscriptions are `customer.created` and `invoice.drafted`. Save the one-time
signing secret in your receiver and click **Verificar receptor**. Your receiver
must verify the signature and echo the ownership challenge; follow the
[webhook guide](https://app.relvoerp.com/docs/product/guides/webhooks.md) for the exact format.

Create a customer or run a scenario. The console shows the latest ten delivery
outcomes per endpoint, including event identity and attempt count. It supports
pausing, resuming, secret rotation and redelivering completed or terminally failed
deliveries. Redelivery preserves event identity, so deduplicate in your receiver.
For full history, pagination, event subscriptions and diagnostics, use the
[public webhook API](https://app.relvoerp.com/docs). Private-network destinations and redirects are not
allowed. API, HTTP, signature, and financial semantics match the production API.

## Integration capabilities

| Capability | Sandbox behavior |
|---|---|
| Customers, catalog, contracts, metering and billing | Real domain behavior with isolated test data |
| Customer webhooks | Verified public HTTPS receivers; signed deliveries and retries |
| Email | No arbitrary customer delivery; inspect the existing email drafts and previews |
| Payments and fiscal documents | Only independently configured, verified provider test tiers |
| Provider without a test tier | Unavailable; never substitute production credentials |
| FX, proration, credits and partial payments | Existing domain capabilities; configure their inputs and verify them separately from the four starter scenarios |
| Advancing time | No global clock override; use explicit billing periods and previews |

A provider saying “certification” is not sufficient evidence of a test tier.
Confirm the provider/account environment before connecting it. Sandbox invoice
preview PDFs and download filenames are labeled as test artifacts; original
provider PDF bytes are preserved.

## Limits, fresh workspaces and production

API requests have per-key and per-IP limits. Every sandbox workspace also has a shared
organization budget across keys and IPs. Use `RateLimit-*` and `Retry-After` to
handle `429`; creating more keys does not increase the workspace budget.

Ask your Relvo contact for a fresh workspace when you need a clean dataset. The
replacement is validated before the old organization is retired. Old financial
history remains intact, and API keys from the retired organization stop
authenticating. This does not clone production data.

To go live, onboard a separate production organization, configure production
providers, and issue production keys. Recreate reviewed configuration through the
normal APIs. Sandbox usage, invoices, payments, callbacks and financial history
are never promoted to production. Automatic configuration transfer and global
time travel are not part of this release.
