BizKitHub
DokumentacePrůzkumník APIVoucher/api/v1/voucher/analyze
getVoucherVeřejné API v1

/api/v1/voucher/analyze

Public mirror of /bff/voucher/analyze. Returns a lightweight snapshot of a voucher: whether it exists in the organisation and, if it does, its computed status (active / inactive / expired / not-yet-valid / limit-reached). Does NOT throw when the voucher is missing — the exists=false branch carries rejectionReason="code_not_found". When redeemContext is supplied, the response additionally carries the rejection reason this voucher would hit for that context. When identityId is supplied and resolves to a known contact, the engine also evaluates the "single use per customer" check. Read-only — never increments usedCount or writes an audit log.

VouchergetApiV1VoucherAnalyze

Parametry

5 v query

Parametry v query

· 5
apiKeystringPovinné

Your BizKitHub API key (passed as GET parameter).

Key format: A 32-character string matching: ^(PROD|DEV_|ROOT)[A-Za-z0-9]{28}$
Prefixes: PROD (production key), DEV_ (individual developer), ROOT (system key with no limits). Learn more

PříkladPRODPGrFxpGEtrOZfuWhnoJohUYBXuOE
codestringPovinné

Voucher code to analyze. Server trims + uppercases.

PříkladSUMMER2024
redeemContextstringVolitelné

Optional redemption context. "order" = voucher is being added to a reservation/order; "voucher_page" = voucher is being redeemed on the dedicated voucher-redeem page. When present, the response includes rejectionReason/rejectionMessage reflecting what the order engine would answer today.

Příkladorder
identityIdstringVolitelné

Logged user identity (from your frontend cookies). Learn more

PříkladZ9CPkS2o3UV163VQn5OUv0T8BQi8Fvdg
customerRealIpstringVolitelné

User IP address used for GEO/IP intelligence.

Accepted formats:

  • IPv4 dot-decimal, e.g. 1.1.1.1 (4 octets, 0–255, no leading zeros).
  • IPv6 as defined by RFC 4291 — full 2001:0db8:0000:0000:0000:0000:0000:0001, zero-compressed 2001:db8::1, IPv4-mapped ::ffff:1.2.3.4, or scoped literals. Both upper- and lower-case hex are accepted.

Server-side canonicalization (ipNormalize in core/src/lib/network/ipNormalize.ts):

  • Valid IPv4 is passed through verbatim.
  • Valid IPv6 is lowercased (RFC 5952 §4.3).
  • IPv4-mapped IPv6 ::ffff:X.X.X.X is unwrapped to plain IPv4 (RFC 4291 §2.5.5.2) so 1.2.3.4 and ::ffff:1.2.3.4 share one brj__geo_ip row.
  • Loopback aliases (::1, 0.0.0.0, localhost, empty string) collapse to 127.0.0.1.
  • Junk values that fail both IPv4 and IPv6 validation are silently rejected and replaced with 127.0.0.1 (loopback).

On the wire: every response returns the canonicalized form — clients can safely rely on lowercase IPv6 and the plain-IPv4 unwrap when de-duping or joining. Server-originated writers (activity log, session log, ban list) resolve the visitor IP via resolveClientIp / resolveClientIpOrNull — always native IPv6 on Vercel Edge (there is no auto-mapping to ::ffff:X.X.X.X).

Enrichment: the system resolves reverse DNS, geolocation, ASN, mobile/proxy/hosting/Tor flags via our VikiTron GEO/IP resolver for both address families. Learn more

Příklad1.1.1.1

Schéma odpovědi

1 zdokumentovaný stavový kód

200ÚspěchVoucher analysis result.
object | object

Voucher analysis result.

Jedna z 2 možností:
Varianta 1

Voucher not found.

exists"false"Povinné

Voucher with this code does not exist.

rejectionReason"code_not_found"Povinné

Always "code_not_found" for the exists=false branch.

rejectionMessagestringPovinné

Human-readable reason, pre-formatted for the frontend.

Varianta 2

Voucher exists — snapshot with computed status.

exists"true"Povinné
codestringPovinné

Voucher code (canonical, uppercase).

type"fixed" | "percentage" | "free-credit" | "free-product"Povinné

Discount type.

valuestringPovinné

Discount value.

activebooleanPovinné

Database active flag (does NOT consider expiration/limit).

effectivelyActivebooleanPovinné

True if voucher is currently usable (active + within validity + below limit).

isValidbooleanPovinné

Alias of effectivelyActive — convenient flag for UI consumers.

status"active" | "inactive" | "expired" | "not-yet-valid" | "limit-reached"Povinné

Computed status enum.

usedCountnumberPovinné

Number of times voucher has been used.

usageLimitnumber | nullPovinné

Maximum number of uses, or null if unlimited.

remainingUsagenumber | nullPovinné

Remaining uses, or null if unlimited.

validFromDate | string | string | numberPovinné

Validity start date.

Jedna z 4 možností:
Varianta 1
Date
Varianta 2
stringdate-time
Varianta 3
stringdate
Varianta 4
number
validToDate | string | string | numberPovinné

Validity end date.

Jedna z 4 možností:
Varianta 1
Date
Varianta 2
stringdate-time
Varianta 3
stringdate
Varianta 4
number
daysUntilExpirationnumber | nullPovinné

Days remaining until expiration, or null if no expiration or already expired.

lastUsedDateDate | string | string | numberPovinné

Last usage date.

Jedna z 4 možností:
Varianta 1
Date
Varianta 2
stringdate-time
Varianta 3
stringdate
Varianta 4
number
notestringPovinné

Internal note (full content).

isOrderSingletonbooleanPovinné

If true, voucher cannot be combined with other vouchers inside a single order.

singleUsePerCustomerbooleanPovinné

If true, every customer may redeem this voucher on at most one order.

redeemableAtOrderbooleanPovinné

If true, voucher may be redeemed on the reservation / order form.

redeemableAtVoucherPagebooleanPovinné

If true, voucher may be redeemed on the dedicated "redeem voucher" page (typically used for free-credit vouchers).

rejectionReason"code_not_found" | "inactive" | "not_yet_valid" | "expired" | "usage_limit_reached" | "already_used_by_customer" | "wrong_redemption_context" | nullPovinné

Rejection reason the order engine would answer for this voucher in the supplied redeemContext. Null when the voucher would be accepted or when redeemContext was not supplied.

Jedna z 8 možností:
Varianta 1
"code_not_found"
Varianta 2
"inactive"
Varianta 3
"not_yet_valid"
Varianta 4
"expired"
Varianta 5
"usage_limit_reached"
Varianta 6
"already_used_by_customer"
Varianta 7
"wrong_redemption_context"
Varianta 8
null
rejectionMessagestring | nullPovinné

Human-readable rejection message. Null when accepted or no context passed.

acceptedForContext"order" | "voucher_page" | nullPovinné

When the engine accepted the voucher this echoes the requested redeemContext; otherwise null.

Jedna z 3 možností:
Varianta 1
"order"
Varianta 2
"voucher_page"
Varianta 3
null

Ukázka odpovědi

application/json
{
  "exists": false,
  "rejectionReason": "code_not_found",
  "rejectionMessage": "example_rejectionMessage"
}

Ukázka požadavku

GET /api/v1/voucher/analyze

get
curl -X GET "https://api.bizkithub.com/api/v1/voucher/analyze?apiKey=PRODPGrFxpGEtrOZfuWhnoJohUYBXuOE&code=SUMMER2024&redeemContext=order&identityId=Z9CPkS2o3UV163VQn5OUv0T8BQi8Fvdg&customerRealIp=1.1.1.1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY"

Potřebujete API klíč?

Všechny veřejné endpointy BizKitHub API se ověřují API klíčem.

Získat API klíč