The Voucherify Developer Hub

Welcome to the Voucherify developer hub. You'll find comprehensive guides and documentation to help you start working with Voucherify as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

Only once per customer

Outdated

Let's create a public BlackFriday2016 code which can be used only once per single customer. This guide shows you how to define this type of campaigns in the campaign wizard and then redeem it programmatically with the API.

Campaign wizard

  1. Run the wizard and choose the standalone code option.
  1. Define the discount type. As you can see in the picture below in our case it's 25% off.
  1. Type (or generate) the discount code
  1. Use the validation rules to limit redemptions to single per customer and confirm it with Add a rule button. *Remember to check Unlimited* option too.
  1. You can optionally define some metadata in the 5th stage and finally save the campaign.

Congrats, your code is ready to be shared and redeemed!

Redemption

The redemption comes down to calling the redeem method providing the customer data in the payload. In the following example you can see:

  • redeem request example
  • successful response
  • unsuccessful response (because the same customer tried to redeem the code again)
curl -X POST 
-H "X-App-Id: c70a6f00-cf91-4756-9df5-47628850002b" 
-H "X-App-Token: 3266b9f8-e246-4f79-bdf0-833929b1380c" 
-H "Content-Type: application/json"
-d '{
	"customer": {
      "source_id": "erlich@bachmanity.com"
    }
}' "https://api.voucherify.io/v1/vouchers/BlackFriday2016/redemption"
{
  "id": "r_HRjYpjl76IIvTKMHem6Eenl2",
  "object": "redemption",
  "date": "2017-01-25T15:01:43Z",
  "customer_id": "cust_AKsPPnBsz9HpS7yME1MKa0Yi",
  "tracking_id": "erlich@bachmanity.com",
  "result": "SUCCESS",
  "voucher": {
    "code": "BlackFriday2016",
    "campaign": null,
    "category": null,
    "type": "DISCOUNT_VOUCHER",
    "discount": {
      "type": "PERCENT",
      "percent_off": 25
    },
    "gift": null,
    "start_date": null,
    "expiration_date": null,
    "publish": {
      "count": 0,
      "entries": []
    },
    "redemption": {
      "quantity": null,
      "redeemed_quantity": 1,
      "redemption_entries": []
    },
    "active": true,
    "additional_info": null,
    "metadata": null,
    "is_referral_code": false
  }
}
{
  "code": 400,
  "message": "redemption validation rules are violated",
  "details": "BlackFriday2016",
  "key": "redemption_rules_violated"
}

Postman collection

You can try it out yourself with this Postman collection Run in Postman

Make sure to change the credentials (X-App-Id and X-App-Token)

Questions?

We're always happy to help with code or other questions you might have! Search our site for more information or contact us through the live chat.