Apply voucher and coupon codes with the Booking API
- Last verified
- Last verified Sep 23, 2026
Use this guide to add a code field to your cart. One mutation handles voucher numbers, coupon codes and promotion codes, so customers can enter any of them in the same field.
Before you start
- A cart and its cart token. The Booking API quickstart shows how to create one.
- A code to test with, such as the number of a voucher with remaining value.
Apply a code
Send the code exactly as the customer entered it, with the cart token as id.
mutation ApplyCode($input: RequestApplyCodeInput!) {
requestApplyCode(input: $input) {
request {
vouchers {
number
value
}
discounts {
label
value
coupon {
number
}
}
totalGrossValue
}
followUpProducts {
id
name
}
errors {
key
message
messageTranslated
}
}
}{ "input": { "id": "<cart token>", "code": "3278598764" } }{
"data": {
"requestApplyCode": {
"request": {
"vouchers": [{ "number": "3278598764", "value": { "amount": -1000, "currency": "EUR" } }],
"discounts": [],
"totalGrossValue": { "amount": 1000, "currency": "EUR" }
},
"followUpProducts": null,
"errors": null
}
}
}Show the result from the returned cart:
| Field | What it contains |
|---|---|
vouchers | Vouchers used as payment. value is negative because it reduces the amount to pay. |
discounts | Discounts from coupons and promotions. coupon.number is the code that granted the discount. |
totalVouchers | The sum of all applied vouchers. |
totalDiscount | The sum of all discounts. |
totalGrossValue | The amount the customer still pays. |
When the code cannot be applied, the cart is unchanged and errors explains why. Show messageTranslated next to the code field.
Redeem a voucher for a product
Some vouchers are redeemed for a specific product, such as a guided tour. When the customer enters such a voucher, the response contains an error with the key requestItem and lists the products the voucher can be redeemed for in followUpProducts.
Let the customer choose one of these products, then apply the code again with the product as requestItem. KORONA Event adds the product to the cart and redeems the voucher for it.
{
"input": {
"id": "<cart token>",
"code": "3278598764",
"requestItem": {
"offerableType": "PRODUCT",
"offerableId": "<product id>",
"pricings": [{ "quantity": 1, "priceOriginType": "PRODUCT", "priceOriginId": "<product id>" }]
}
}
}Remove a code
Remove a voucher with its number, or a coupon with its coupon.number.
mutation RemoveCode($input: RequestRemoveCodeInput!) {
requestRemoveCode(input: $input) {
request {
vouchers {
number
}
}
errors {
key
message
messageTranslated
}
}
}{ "input": { "id": "<cart token>", "code": "3278598764" } }