Skip to content

Coupon code support

Sheetlabs can be used to deliver single-use coupon codes. These are commonly used by online stores that wish to provide a discount to users. However, these stores typically want to ensure that a coupon code is never used more than once.

Sheetlabs can be used to store coupon codes and then issue them via an API. When used in this manner, Sheetlabs guarantees that each coupon code is issued only once (regardless of how many users are simultaneously requesting codes).

Behaviour

When you create an API that is delivering coupon codes, you should be aware of the following:

  1. Each coupon code is guaranteed to only be returned once. Once a coupon code has been returned, it will never be reissued (uness you manually mark it as available again).
  2. If you run out of coupon codes in your data table, then users will receive an empty API response.
  3. Your coupon codes should be unique. This is required for Sheetlabs to track which ones have been used and to allow additional ones to be imported later.

Creating a coupon code based API

To create an API that returns coupon codes, perform the following steps:

  1. Create a new data table and import data from a spreadsheet or Google Sheets.
  2. During the data table creation process, click the "Advanced" button, and check the option that says "My table contains coupon codes". You will then need to select which field in your data table contains the unique coupon codes.
  3. Finish creating your data table as normal.
  4. Create your API as normal too. You do not need to do anything special here. If you only wish you serve one coupon code at a time, you will need to check the "Limit the number of records returned by the API" and set this value to "1".

Once complete, you will be able to use your API as normal. You will find that a record will be returned only once. Try a few requests back to back to see for yourself.

Providing additional coupon codes

If you run out of coupon codes and wish to provide additional ones, you can import data into your data table as normal. Sheetlabs will keep track of which coupon codes have previously been used, even if you replace the entire spreadsheet and include previously-issued codes.

Viewing the status of an individual coupon code

If you wish to view what coupon codes have been used, or optionally change the used status of an individual coupon code, you can do this by viewing the data table. To do this, go to the Data Tables section, click on your table, and then browse the rows. The __used field is used to indicate whether a coupon code has been consumed or not.

Clearing coupon codes

If you wish to remove all coupon codes and clear their used status, you should delete the data table and then import your coupons afresh.