ValulogDashboard

API version 1.3.0 · openapi.yaml

API reference

Base URL https://api.valulog.com/v1. Get a free test key from your dashboard.

Example

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 }
    ]
  }'

The system of record for pricing, discounts, and audit-safe refunds. Valulog is not a payment processor and does not give tax advice: payments stay with your payment provider; Valulog records how prices, discounts and refunds were calculated.

Authentication

Every endpoint except /health needs an API key: Authorization: Bearer vl_live_… (live) or Bearer vl_test_… (sandbox). - The merchant is taken from the key. Do not send merchant_id; if you do, it must match the key's merchant or the request is refused (403). - Sandbox (test) and live data are separate: a test key never sees live data. - Records belonging to another merchant are reported as 404. - Invalid or revoked keys return 401. Live keys need a paid plan (403 PLAN_REQUIRED).

Rate limits

Per API key, per minute. Sandbox keys: 10. Starter: 60. Growth: 300. Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. If the limiter is unavailable the API refuses with 503 rather than letting unmetered requests through.

Monthly allowance

Calculations and refunds count towards a monthly allowance (UTC calendar month): Sandbox/test keys 1,000, Starter 25,000, Growth 250,000. Reads and idempotent replays are not counted. Mutations return X-Quota-Limit and X-Quota-Remaining; when the allowance is used up they return 429 QUOTA_EXCEEDED until the 1st of the next month or a plan upgrade.

Core Philosophy

  • Immutable Snapshots: We do not recalculate refunds. We replay history.
  • Integer Math: No floats. All values are minor currency units (cents/pence/yen).
  • Idempotency First: Idempotency-Key header is mandatory for all mutations.

Discount Rules

Rules are a discriminated union on the type field: - FIXED_AMOUNT → uses amount_cents - PERCENTAGE → uses basis_points (1000 = 10%) - BUY_X_GET_Y → uses buy_quantity, get_quantity, get_discount_basis_points

Every rule declares application_base: - ORIGINAL_SUBTOTAL — discount calculated on pre-discount value - REMAINING_BALANCE — discount cascades after previous rules - PER_LINE — applied independently per eligible line

Currency

All values are in minor units for the given currency: - GBP/USD/EUR: cents (exponent 2) - JPY/KRW: whole units (exponent 0) - KWD/BHD: fils (exponent 3)

The response includes currency_minor_unit_exponent so consumers know how to display.

Endpoints

GET/health

Health check

Public (no key). Reports whether the API, its database (postgres) and its rate-limit and idempotency store (redis) are reachable right now. Sent with Cache-Control: no-store. There is no separate status page and no uptime SLA; see https://valulog.com/status.

  • 200 The API and all its dependencies are reachable
  • 503 At least one dependency is not reachable; writes are refused with SERVICE_UNAVAILABLE

POST/calculate

Calculate allocations and freeze an immutable snapshot

ParameterInTypeNotes
Idempotency-Key *headerstringUnique per operation. Scoped to your merchant and environment. A UUID is recommended.

Body: CalculationRequest

  • 200 Snapshot frozen
  • 400 Request validation failed
  • 401 Missing, invalid or revoked API key
  • 403 merchant_id does not match the key, or the plan does not allow live keys (PLAN_REQUIRED)
  • 409 Key reused with different payload
  • 429 Too many requests (`RATE_LIMITED`) or monthly allowance used (`QUOTA_EXCEEDED`)
  • 503 A dependency is unavailable; retry after the Retry-After seconds

POST/refunds

Process idempotent refund against frozen snapshot

ParameterInTypeNotes
Idempotency-Key *headerstringUnique per operation. Scoped to your merchant and environment. A UUID is recommended.

Body: RefundRequest

  • 200 Refund processed
  • 400 Request validation failed
  • 401 Missing, invalid or revoked API key
  • 403 merchant_id does not match the key, or the plan does not allow live keys (PLAN_REQUIRED)
  • 404 Resource not found
  • 409 Key reused with different payload
  • 422 Insufficient refundable amount
  • 429 Too many requests (`RATE_LIMITED`) or monthly allowance used (`QUOTA_EXCEEDED`)
  • 503 A dependency is unavailable; retry after the Retry-After seconds

GET/transactions/{transaction_id}

Retrieve frozen transaction with refund ledger

ParameterInTypeNotes
transaction_id *pathstring (uuid)
  • 200 The frozen transaction and its refund ledger
  • 401 Missing, invalid or revoked API key
  • 404 Resource not found
  • 429 Too many requests (`RATE_LIMITED`) or monthly allowance used (`QUOTA_EXCEEDED`)
  • 503 A dependency is unavailable; retry after the Retry-After seconds

GET/transactions/{transaction_id}/refunds

List refunds with cursor pagination

ParameterInTypeNotes
transaction_id *pathstring (uuid)
cursorquerystringOpaque value from `next_cursor` on the previous page.
limitqueryinteger
  • 200 A page of refunds for the transaction
  • 401 Missing, invalid or revoked API key
  • 404 Resource not found
  • 429 Too many requests (`RATE_LIMITED`) or monthly allowance used (`QUOTA_EXCEEDED`)
  • 503 A dependency is unavailable; retry after the Retry-After seconds

GET/transactions/{transaction_id}/integrity

Verify snapshot hash integrity (audit endpoint)

ParameterInTypeNotes
transaction_id *pathstring (uuid)
  • 200 Integrity verified
  • 401 Missing, invalid or revoked API key
  • 404 Resource not found
  • 409 Integrity violation detected
  • 429 Too many requests (`RATE_LIMITED`) or monthly allowance used (`QUOTA_EXCEEDED`)
  • 503 A dependency is unavailable; retry after the Retry-After seconds

Schemas

HealthResponse

statushealthy | degraded
timestampstring (date-time)
versionstring
uptime_secondsinteger
dependenciesobject

CalculationRequest

merchant_idstring (uuid)Optional and not needed. The merchant comes from the API key; a different value is refused (403).
currency *stringISO 4217 code. Supported: USD, GBP, EUR, JPY, KWD, etc.
items *CartItem[]
discountsDiscountRule[]
metadataobject

CartItem

id *string
skustring
unit_price_cents *integerPrice per unit in minor currency units
quantity *integer
is_discount_eligibleboolean
metadataobject

DiscountRule

FixedAmountRule

rule_id *string
type *FIXED_AMOUNT
amount_cents *integerFixed discount in minor currency units
applicable_itemsstring[]
max_discount_centsinteger
application_baseORIGINAL_SUBTOTAL | REMAINING_BALANCE | PER_LINE

PercentageRule

rule_id *string
type *PERCENTAGE
basis_points *integer1000 = 10%, 10000 = 100%
applicable_itemsstring[]
max_discount_centsinteger
application_baseORIGINAL_SUBTOTAL | REMAINING_BALANCE | PER_LINE

BuyXGetYRule

rule_id *string
type *BUY_X_GET_Y
buy_quantity *integerItems needed to qualify
get_quantity *integerItems that receive the discount
get_discount_basis_points *integer10000 = free, 5000 = 50% off
cheapest_firstbooleantrue = discount cheapest eligible items first
applicable_itemsstring[]
max_discount_centsinteger
application_baseORIGINAL_SUBTOTAL | REMAINING_BALANCE | PER_LINE

CalculationResult

transaction_idstring (uuid)
merchant_idstring (uuid)
currencystring
currency_minor_unit_exponentinteger0 for JPY, 2 for GBP/USD, 3 for KWD
allocationsLineAllocation[]
totalsCalculationTotals
snapshot_hashstring
metadataobject
created_atstring (date-time)
engine_versionstring

LineAllocation

line_item_idstring
skustring
quantityinteger
unit_price_centsinteger
original_centsinteger
allocated_discount_centsinteger
final_centsinteger
final_tax_basis_centsinteger
rule_provenanceobject[]

CalculationTotals

subtotal_centsinteger
total_discount_centsinteger
final_total_centsinteger
item_countinteger

RefundRequest

transaction_id *string (uuid)
line_item_id *string
quantityinteger
reasonstring
metadataobject

RefundResult

refund_idstring (uuid)
transaction_idstring (uuid)
line_item_idstring
refund_amount_centsinteger
quantity_refundedinteger
statusCOMPLETED | ALREADY_REFUNDED | PARTIAL
original_line_total_centsinteger
previously_refunded_centsinteger
remaining_refundable_centsinteger
reasonstring
metadataobject
created_atstring (date-time)

TransactionSnapshot

transaction_idstring (uuid)
merchant_idstring (uuid)
currencystring
currency_minor_unit_exponentinteger
request_snapshotCalculationRequest
result_snapshotCalculationResult
refund_ledgerRefundResult[]
total_refunded_centsinteger
net_total_centsinteger
created_atstring (date-time)
snapshot_hashstring
engine_versionstring

PaginatedRefunds

transaction_idstring (uuid)
refundsRefundResult[]
has_moreboolean
next_cursorstringOpaque; pass it back as `cursor`.
total_refunded_centsinteger

IntegrityReport

transaction_idstring (uuid)
stored_hashstring
computed_hashstring
is_validboolean
checked_atstring (date-time)

ErrorResponse

error_code *UNAUTHENTICATED | FORBIDDEN | PLAN_REQUIRED | SERVICE_UNAVAILABLE | VALIDATION_ERROR | IDEMPOTENCY_CONFLICT | NOT_FOUND | ALREADY_REFUNDED | INSUFFICIENT_REFUNDABLE | RATE_LIMITED | QUOTA_EXCEEDED | INTERNAL_ERROR
message *string
detailsobject
request_id *string
doc_urlstring (uri)https://valulog.com/docs/errors/<error_code>: what the code means and whether to retry.