βοΈ Deprecated
This endpoint represents the deprecated version of the API responsible for voucher validation, and we do not recommend using it. The new Stackable Discounts API introduces additional features and improvements while maintaining backward compatibility, including applying a combination of coupon codes and promotion tiers. Developers are encouraged to migrate to the latest version to take advantage of the latest enhancements and bug fixes. No updates will be provided to the deprecated endpoint.
To verify a voucher code given by customer, you can use this method. It is designed for client side integration which means that is accessible only through public keys. This method is designed to be run directly either in web browsers or mobile apps.
βοΈ Specifying gift credits and loyalty points
This endpoint does not support specifying the specific amount of gift credits to apply to an order nor the specific amount of loyalty points to an order. It calculates the amount that is available on the card and applies as much credits or points as possible to cover the total amount.
Voucherify can help you track anonymous customers. Once you integrate Voucherify into your web app and call the validate method, Voucherify will return a tracking ID and the script will store it in a cookie. Each subsequent validate call will use the same tracking ID.
Voucherify tracks a user using a tracking ID to see if the user who is validating vouchers is the same as the one who consuming them. Voucherify does this by setting up an identity for the user. A tracking_id will be generated on the server side, unless you specify your own tracking_id. In both cases, you will receive the tracking_id in the validation response.
The returned tracking_id field should be used as the customer source_id in subsequent redemption requests. Moreover, the tracking_id returned from Validation API is encoded. Voucherify will recognize both values for identifying customer - the one before encryption sent as a query parameter to the GET v1/validate request, and the version encrypted and returned as part of the validation request.
Customer tracking workflow in a nutshell:
Client-side:
tracking_id.Backend:
tracking_id to your backend during a redemption call. The tracking_id is sent as a value assigned to the property source_id in a customer object.id.id or the customer source_id to fetch or modify the customer details.A customer is created (upserted) automatically with a redemption call. Alternatively, you can create a new profile by creating a customer via a dedicated API method. Take a look at the customer object to understand the entityβs structure.
π Customer identifier
The source id of the customer may either be an already hashed version of the
tracking_id, which you received in a response from a validation request or a custom ID you predefined (i.e. an email address). Nevertheless, we recommend using identifiers delivered by Voucherify API.
| Query Parameters | Example URL |
|---|---|
Shortcut - customer query param instead of customer[source_id] | https://api.voucherify.io/client/v1/validate?code=sKKFCKLZ&amount=10100&customer=customer_id |
Pass customerβs and redemptionβs context metadata in query parameters | https://api.voucherify.io/client/v1/validate?code=sKKFCKLZ&amount=10100&customer=sure_he_is_new&metadata[shop]=1&customer[metadata][propsy]=2&metadata[test]=true |
Use tracking_id instead of source_id | https://api.voucherify.io/client/v1/validate?code=IKU-mvS-JOG&amount=10100&tracking_id=sure_he_is_new_5&metadata[shop]=1&metadata[test]=true |
Voucher validation might fail because of one of these reasons:
voucher not found - voucher doesnβt exist or was deletedvoucher expired - voucher is out of [start date - expiration date] timeframevoucher is disabled - learn more about disabled voucherscustomer does not match segment rules - learn more about customer trackingorder does not match validation rules - learn more about validation rulesThe access token received from the authorization server in the OAuth 2.0 flow.
Indicates the origin (scheme, hostname, and port).
A code that identifies the voucher.
"2CpRCE2c"
A tracking identifier of a user that validated the voucher. This identifier is generated during voucher validation based on your internal ID (e.g., email, database ID) during the first request. This is a hashed customer source ID. If the request is performed for the first time, pass the internal ID to track the customer. Although not all information is required, the extra information helps prevent fraud.
A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts.
The session unique ID assigned by Voucherify or your own unique session ID. Sending an existing ID will result in overwriting an existing session. If no session key is provided, then a new ID will be generated.
"ssn_yQGMTeKBSw8OOuFPwlBEjzGy8d8VA9Ts"
Value for the period of time that the session is active. Units for this parameter are defined by the session_ttl_unit parameter.
Defines the type of unit in which the session time is counted.
HOURS, DAYS, MINUTES, SECONDS, MILLISECONDS, MICROSECONDS, NANOSECONDS Metadata key value pairs.
Array of order items.
The session is required to establish a session between multiple parallel validation and redemption requests. This parameter is required to establish a new session. The session locks the redemption quantity by 1 and additionally the redemption gift credits specified within the request for a gift card and the loyalty points for a loyalty card.
Customer details. Customer source ID and/or customer metadata.
Order details.
Returns information whether the voucher is valid in the context of the parameter values provided in the query parameters. Moreover, it returns a hashed source identifier which can be used as tracking ID in future calls. If a validation session is established, then the session details will be returned as well. Read more on validation sessions.
Response schema model for validating a discount code using POST v1/vouchers/{code}/validate.
Indicates whether the voucher is valid within the context of the parameters provided in the request body.
Contains list of items that qualify in the scope of the discount. These are definitions of included products, SKUs, and product collections. These can be discounted.
Contains list of items that do not qualify in the scope of the discount. These are definitions of excluded products, SKUs, and product collections. These CANNOT be discounted.
Hashed customer source ID.
This is an object representing an order with calculated discounts applied using the voucher code.
Voucher code.
Contains information about the discount to be applied to the order.
The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format.
Activation timestamp defines when the voucher starts to be active in ISO 8601 format. Voucher is inactive before this date.
"2022-10-04T00:00:00.000Z"
Expiration timestamp defines when the voucher expires in ISO 8601 format. Voucher is inactive after this date.
"2022-10-31T00:00:00.000Z"
Voucher's parent campaign name.
Voucher's parent campaign's unique ID.
"camp_W8DJVd8J0btqXT6FBwn7BSkC"
Schema model for session lock object. The session object contains information about the session key that was used to establish a session between multiple parallel validation and redemption requests.