Quickstart
Your first calculation and refund in about five minutes. Every command can be copied as it is; replace the placeholders in angle brackets. Base URL https://api.valulog.com/v1.
1. Get a free test key
Sign in to the dashboard with your email, leave Environment on Test and choose “Create key”, then copy it: it is shown once. Keep it in an environment variable, never in code or chat.
Shell export VALULOG_KEY="vl_test_paste_your_key_here"2. Check the API is reachable
The health check needs no key. A 200 with "status": "healthy" means the API, its database and its rate-limit store are all reachable.
curl curl https://api.valulog.com/v1/health3. Calculate a discounted basket
Send the lines and the discount rules with an Idempotency-Key you choose (your order number works well). Keep the transaction_id from the response.
curl https://api.valulog.com/v1/calculate \ -H "Authorization: Bearer $VALULOG_KEY" \ -H "Idempotency-Key: order-1042" \ -H "Content-Type: application/json" \ -d '{ "currency": "GBP", "items": [ { "id": "line-1", "sku": "TEE", "unit_price_cents": 2000, "quantity": 2 }, { "id": "line-2", "sku": "MUG", "unit_price_cents": 1000, "quantity": 1 } ], "discounts": [ { "rule_id": "TENOFF", "type": "PERCENTAGE", "basis_points": 1000 } ] }'Response (trimmed, fictional IDs) { "transaction_id": "3b0c6f1e-8d2a-4c47-9f5e-2a7d1c9b4e60", "currency": "GBP", "allocations": [ { "line_item_id": "line-1", "quantity": 2, "original_cents": 4000, "allocated_discount_cents": 400, "final_cents": 3600 }, { "line_item_id": "line-2", "quantity": 1, "original_cents": 1000, "allocated_discount_cents": 100, "final_cents": 900 } ], "totals": { "subtotal_cents": 5000, "total_discount_cents": 500, "final_total_cents": 4500, "item_count": 3 }, "snapshot_hash": "sha256:…" }4. Refund one unit of a line
Valulog reads the frozen snapshot: the T-shirt line was paid £36.00 for two units, so one unit refunds £18.00. Pay that out through your payment provider.
curl curl https://api.valulog.com/v1/refunds \ -H "Authorization: Bearer $VALULOG_KEY" \ -H "Idempotency-Key: return-1042-1" \ -H "Content-Type: application/json" \ -d '{ "transaction_id": "<transaction_id from step 3>", "line_item_id": "line-1", "quantity": 1, "reason": "Customer return" }'5. Retry safely
Run step 4 again with the same Idempotency-Key. You get the original refund back with the header X-Idempotent-Replayed: true: no second refund, no operation counted.
6. Read the record and check it
Fetch the snapshot with its refund ledger, page through refunds, or recompute the hash to show the record has not changed.
curl curl https://api.valulog.com/v1/transactions/<transaction_id> -H "Authorization: Bearer $VALULOG_KEY" curl "https://api.valulog.com/v1/transactions/<transaction_id>/refunds?limit=50" -H "Authorization: Bearer $VALULOG_KEY" curl https://api.valulog.com/v1/transactions/<transaction_id>/integrity -H "Authorization: Bearer $VALULOG_KEY"
Next
- API reference: every endpoint, field and response.
- Errors: what each error code means and whether to retry.
- Use cases: discounted lines, buy-one-get-one-free, double refunds, audit trail.
- When you are ready for live keys, choose a plan.