Vouchers API Guide
Welcome to the Vouchers API guide! Vouchers are a way to provide discounts to your customers by covering part of the cost for them, essentially lowering your commission. This is often used to reward returning customers or as an incentive in a marketing campaign to bring in new customers. Currently, the API only supports percentage-based discounts, but more options are being developed.
Prerequisites
Before you start, setting up a collection in Postman can make it easy to test the voucher system. This is not a requirement, but it is currently the easiest way to interact with the voucher's API.
- Installed Postman
- Imported the provided Postman collection file (
Vouchers-api.postman_collection.json
) - Authenticate using your liteAPI Key. You can use either a Sandbox or Production key to create vouchers.
- The base URL (host) is included in the Postman collection, but if you are doing this via curl or other methods, you will use
https://da.liteapi.travel
as the base URL.
Endpoints Overview
The Vouchers API includes the following main endpoints:
- Create Voucher
- Update Voucher
- Get Voucher by ID
- Get All Vouchers
1. Create Voucher
Endpoint: POST {{host}}/vouchers
Description: Creates a new voucher.
What does each field do?
voucher_code
This is the code the customer enters at checkout to activate the voucher.discount_type
Currently only percentage is supported as a value, but eventually other types will be available, like a voucher for a specific currency ammount.discount_value
For percentage vouchers, this defines the discount. A value of 20 is a 20% (or .20) discount to applied to the cost of the booking.minimum_spend
This field defines the least amount that the total cost can add to to still be able to use this voucher. A value of 60 means the total booking must be at least $60 USD to use this voucher. The vouchers work across currencies, and will use the current currency exchange rate to calculate the USD ammount.maximum_discount_amount
This amount sets an upper limit on how much the voucher will discount the rate. A value of 20, means that no more than $20 USD can be discounted off of a single booking with this voucher. Currency exchange rates will be used for non-USD currencies.validity_start
Here you can set the date and time when this voucher will begin functioning. Think of this as the begining of your sales campaign.validity_end
Here you can set the date and time when this voucher will stop functioning. Think of this as the end of your sales campaign.usages_limit
How many bookings can this voucher be applied to. Remember Sandbox bookings do not count, so if set to one, you can still test the booking code before sharing it.status
: Set this to active when you create the voucher for it to work. Set it to inactive if you want to disable the voucher from functioning.terms_and_conditions
Text defining the terms and conditions associated with this voucher.
Request Body:
{
"voucher_code": "discount20",
"discount_type": "percentage",
"discount_value": 20,
"minimum_spend": 60,
"maximum_discount_amount": 20,
"validity_start": "2024-06-03",
"validity_end": "2024-06-30",
"usages_limit": 100,
"status": "active",
"terms_and_conditions": "This voucher is valid for bookings made through our platform only. Cannot be combined with other offers."
}
2. Update Voucher
Endpoint: PUT {{host}}/vouchers/:id
Description: Updates the details of an existing voucher.
The ID passed to the endpoint determined the voucher updated. Otherwise the fields function the same as on the create endpoint.
Request Body:
{
"voucher_code": "discount20",
"discount_type": "percentage",
"discount_value": 20,
"minimum_spend": 20,
"maximum_discount_amount": 30,
"validity_start": "2024-08-03",
"validity_end": "2024-09-30",
"usages_limit": 100,
"status": "active",
"terms_and_conditions": "This voucher cannot be combined with other offers."
}
3. Get Voucher by ID
Endpoint: GET {{host}}/vouchers/:id
Description: Retrieves the details of a voucher by its ID.
The ID passed to the endpoint determines which voucher details are returned.
4. Get All Vouchers
Endpoint: GET {{host}}/vouchers/
Description: Retrieves a list of all your account's vouchers.
Hitting the endpoint without an ID returns all your account's vouchers.
Creating your First Voucher
Step 1: Setup Authentication
- Under Variables, set apiKey to your liteAPI Key.
Step 2: Create a new Voucher
- Open the Create Voucher request.
- Fill in the required voucher details in the request body.
- Send the request and verify the voucher is created.
Step 3 Verify your Voucher is Listed
- Open the Get All Vouchers request.
- Send the request and review the list of all vouchers. Your new voucher should be listed
Step 6: Place a booking using your voucher code during prebook.
- To use the voucher, it is passed during the prebook step as
voucherCode
. This must be used along with theusePaymentSdk
flag set to true. This informs the liteAPI Payment SDK to use the attached account credit card to cover the discounted portion.
Your body parameters will look like this:
{
"offerId": "YOUR_OFFER_ID",
"usePaymentSdk": true,
"voucherCode": "discount20"
}
The result is that for a $100 booking, the customer's card (The person booking the room) will be charged $80 while the attached account credit card will cover the other $20.
Other Endpoints to Try
Retrieve a Specific Voucher's Details
- Open the Get Voucher by ID request.
- Replace
:id
in the URL with the ID of the voucher to retrieve. - Send the request and review the voucher details.
Update the Voucher
- Open the Update Voucher request.
- Replace
:id
in the URL with the ID of the voucher to update. - Update the request body with the new voucher details.
- Send the request and verify the changes.
Updated 5 months ago