BizKitHub
DokumentacjaEksplorator APIVoucher/api/v1/voucher/analyze
getVoucherPubliczne 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 w query

Parametry query

· 5
apiKeystringWymagane

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

PrzykładPRODPGrFxpGEtrOZfuWhnoJohUYBXuOE
codestringWymagane

Voucher code to analyze. Server trims + uppercases.

PrzykładSUMMER2024
redeemContextstringOpcjonalne

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.

Przykładorder
identityIdstringOpcjonalne

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

PrzykładZ9CPkS2o3UV163VQn5OUv0T8BQi8Fvdg
customerRealIpstringOpcjonalne

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

Przykład1.1.1.1

Schemat odpowiedzi

1 udokumentowany kod statusu

200SukcesVoucher analysis result.
object | object

Voucher analysis result.

Jedna z 2 opcji:
Wariant 1

Voucher not found.

exists"false"Wymagane

Voucher with this code does not exist.

rejectionReason"code_not_found"Wymagane

Always "code_not_found" for the exists=false branch.

rejectionMessagestringWymagane

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

Wariant 2

Voucher exists — snapshot with computed status.

exists"true"Wymagane
codestringWymagane

Voucher code (canonical, uppercase).

type"fixed" | "percentage" | "free-credit" | "free-product"Wymagane

Discount type.

valuestringWymagane

Discount value.

activebooleanWymagane

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

effectivelyActivebooleanWymagane

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

isValidbooleanWymagane

Alias of effectivelyActive — convenient flag for UI consumers.

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

Computed status enum.

usedCountnumberWymagane

Number of times voucher has been used.

usageLimitnumber | nullWymagane

Maximum number of uses, or null if unlimited.

remainingUsagenumber | nullWymagane

Remaining uses, or null if unlimited.

validFromDate | string | string | numberWymagane

Validity start date.

Jedna z 4 opcji:
Wariant 1
Date
Wariant 2
stringdate-time
Wariant 3
stringdate
Wariant 4
number
validToDate | string | string | numberWymagane

Validity end date.

Jedna z 4 opcji:
Wariant 1
Date
Wariant 2
stringdate-time
Wariant 3
stringdate
Wariant 4
number
daysUntilExpirationnumber | nullWymagane

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

lastUsedDateDate | string | string | numberWymagane

Last usage date.

Jedna z 4 opcji:
Wariant 1
Date
Wariant 2
stringdate-time
Wariant 3
stringdate
Wariant 4
number
notestringWymagane

Internal note (full content).

isOrderSingletonbooleanWymagane

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

singleUsePerCustomerbooleanWymagane

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

redeemableAtOrderbooleanWymagane

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

redeemableAtVoucherPagebooleanWymagane

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" | nullWymagane

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 opcji:
Wariant 1
"code_not_found"
Wariant 2
"inactive"
Wariant 3
"not_yet_valid"
Wariant 4
"expired"
Wariant 5
"usage_limit_reached"
Wariant 6
"already_used_by_customer"
Wariant 7
"wrong_redemption_context"
Wariant 8
null
rejectionMessagestring | nullWymagane

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

acceptedForContext"order" | "voucher_page" | nullWymagane

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

Jedna z 3 opcji:
Wariant 1
"order"
Wariant 2
"voucher_page"
Wariant 3
null

Przykład odpowiedzi

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

Przykład żądania

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"

Potrzebujesz klucza API?

Wszystkie publiczne endpointy BizKitHub API uwierzytelniają się kluczem API.

Uzyskaj klucz API