Fetch Voucher

Learn how to use the Fetch Voucher API to retrieve and display assigned vouchers to users.

Overview

The Fetch Voucher API enables you to retrieve voucher codes assigned to users through CleverTapโ€™s Partner Voucher Campaigns. These vouchers can be displayed in the user's voucher tray within your application, allowing a seamless reward experience and promoting post-campaign engagement.

Sample UI Behavior

Hereโ€™s how businesses can implement client-side behaviors when integrating the Fetch Voucher API into their applications. These usage patterns help ensure a seamless and intuitive user experience when displaying assigned vouchers:

  • Logged-in User: Call the API with their identity to show assigned vouchers.
  • Anonymous User: Skip the API call, or show an empty tray with a message prompting login.
  • Voucher Expiry: Use the listExpiry timestamp to filter out expired vouchers on the business's side.

Base URL

Here is an example base URL from the account in the India region:

https://sk1.api.clevertap.com/1/promo/vouchers

Region

To identify the API endpoint for the region of your account, refer to Region.

Headers

For more information about API headers used while processing API requests, refer to Headers.

HTTP Method

GET

Query Parameters

ParameterDescriptionRequiredData TypeSample Value
identityUnique identifier for the user. Accepts phone (E.164 format), email, or CleverTap ID.YesString+919538784114

Sample Responses

The Fetch Voucher API returns different types of responses based on the validity of the input and the state of the userโ€™s assigned vouchers. Below are sample responses for common scenarios:

Success Response

On success, the API returns a list of vouchers assigned to the user:

{
    "status": "success",
    "records": [
        {
            "listExpiry": 1750789800,
            "listTag": "summersale",
            "partner": "AMAZON",
            "campaignId": 1500,
            "externalVoucherId": 1434,
            "listName": "FLAT1000",
            "listDescription": "Get flat 1500 offer on Amazon using this voucher",
            "voucherCode": "BMO9IW7QTALK"
        },
        {
            "listExpiry": 1750789800,
            "listTag": "newyearsale",
            "partner": "FLIPKART",
            "campaignId": 1501,
            "externalVoucherId": 1434,
            "listName": "FLAT20%",
            "listDescription": "Get 20% offer on electronics items",
            "voucherCode": "3248BO386IJG"
        }
    ]
}
KeyDescriptionTypeSample Value
voucherCodeThe voucher code assigned to the user.StringBMO9IW7QTALK
listNameName of the voucher list from which the code is drawn.Stringsummersale
listTagTag associated with the voucher list. (@Bajrang: how is code different from tag??)StringFLAT1000
listExpiryExpiry of the voucher list in the Epoc timestamp format.Epoch1750789800
partnerPartner or brand name associated with the voucher.StringFLIPKART
campaignIdCampaign ID from which the voucher was assigned.Number1500
externalVoucherIdVoucher list ID from which the voucher code is assigned.Number1434
listDescriptionOptional description of the voucher list.String"Offer is applicable on orders above $100" (empty if none)

Empty Response

If the identity is valid but no vouchers are assigned, the API returns the following response:

{
    "status": "success",
    "records": []
}

Error Response

If the identity is missing or invalid:

{
    "status": "fail",
    "error": "Invalid identity",
    "code": 400
}

Errors

To know about the errors applicable to the Fetch Voucher API, refer to API Error Cases.