Skip to content
Documentation menu

Vouchereto API · v1

Quickstart

Redeem your first voucher in the sandbox: get a test key, create a test voucher, reserve it, capture it and watch the webhook arrive. No real money is involved.

1. Get a test API key

  1. Sign in to the merchant portal at merchant.vouchereto.com (accounts are invite-only: request access).
  2. Switch the portal to Test mode (Modo prueba) and open Developers (Desarrolladores) → API keys.
  3. Create a key. It looks like vch_test_AbC123dEf456_… and is shown once: store it in your secret manager.

Export it in your shell so the samples below can read it:

shell
export VOUCHERETO_API_KEY="vch_test_…"
Running our stack locally instead? The local stack prints a ready-made test key and webhook secret with one command.

2. Create a test voucher

Sandbox vouchers are real codes tied to your merchant, created in the state you ask for. Every request must be signed (the samples show how; the signing page explains it).

POST /v1/sandbox/vouchers
# Bash + openssl: sign and send a request
KEY="$VOUCHERETO_API_KEY"                    # vch_test_…
API="${VOUCHERETO_API:-https://api.vouchereto.com}"
SECRET="${KEY##*_}"                          # the secret is the last "_" segment of the key
METHOD="POST"
PATH_Q="/v1/sandbox/vouchers"                # path (with /v1 and any ?query)
BODY='{"state":"active","amount_minor":5000,"currency":"USD"}'
T=$(date +%s)
SIG=$(printf '%s.%s %s\n%s' "$T" "$METHOD" "$PATH_Q" "$BODY" \
  | openssl dgst -sha256 -hmac "$SECRET" -hex | sed 's/^.* //')

curl -sS -X "$METHOD" "$API$PATH_Q" \
  -H "Authorization: Bearer $KEY" \
  -H "Vouchereto-Signature: t=$T,v1=$SIG" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  --data-raw "$BODY"

The response contains code, for example K7QM-4XPD-9TRW-2WNZ. That is what a customer would type on your site.

3. Reserve the voucher

Reserving locks the voucher's full value for ttl_seconds (default 900). Use the same helper with a different path and body:

reserve
POST /v1/redemptions
{ "code": "K7QM-4XPD-9TRW-2WNZ", "currency": "USD", "customer_ref": "user_8842" }

201 Created
{
  "id": "f4e8b730-294e-4351-a85d-dc525dcadc18",
  "object": "redemption",
  "status": "reserved",
  "amount_minor": 5000,
  "currency": "USD",
  "voucher_last4": "2WNZ",
  "customer_ref": "user_8842",
  "livemode": false,
  "expires_at": "2026-10-22T17:37:55.915Z",
  "captured_at": null,
  "created_at": "2026-10-22T17:22:55.915Z"
}

4. Capture it

Capture once your side succeeded (for example, after you added the balance to the customer's account). Captures are final.

capture
POST /v1/redemptions/f4e8b730-294e-4351-a85d-dc525dcadc18/capture
(empty body, still signed, with its own Idempotency-Key)

200 OK
{ "id": "f4e8b730-…", "object": "redemption", "status": "captured", "captured_at": "2026-10-22T17:22:56.118Z", … }

If something went wrong on your side, call POST /v1/redemptions/{id}/cancel instead and the customer keeps the voucher.

5. Receive the webhook

  1. In the portal (test mode) open Developers → Webhooks and add an https:// endpoint subscribed to redemption.captured. Copy its whsec_… secret.
  2. Capture another sandbox voucher: within a minute your endpoint receives a signed redemption.captured event.
  3. Verify the signature before trusting it: code in Node, Python and PHP.
No public https endpoint yet? Use a tunnel (for example cloudflared tunnel --url http://localhost:8080) or a request bin while you develop. The portal shows every delivery and lets you resend it.

Do it all with one command

The same flow, plus idempotent retries, the single-use check, listing, cancelling and creating checkout and redeem sessions, is in our repository as a script you can run against the sandbox:

shell
VOUCHERETO_API_KEY=vch_test_… npx tsx scripts/sandbox/quickstart.ts

Next: choose your integration in the guides, then read idempotency, errors and limits before going live.