Search…
Coupons
Give your customers $10 or 10% off their order.

Coupon Object

Our coupons allow you to give your customers either a fixed amount or a particular percentage off their order. You can define when you want the coupon to be valid and how many times you want it to be able to be used.
Attribute
Type
Description
name
string
The name of the Coupon, e.g., Summer 2019.
code
string
The code for the Coupon. This could be used by your customer while creating an Order, e.g, SUM2019.
If the code is not defined, it will be given a 'human readable' code of 6 randomly generated characters.
percent_off
float
The percentage of discount on the order given by the Coupon as a decimal between 0.0 and 0.1, e.g. 0.25 = 25%.
amount_off
float
The amount off the price of the order given by the Coupon.
starting_date
object
Defines when a Coupon will become available for your customer. By default it's defined as the moment you create it.
ending_date
object
The Coupon will not be usable by your customer after this date.
max_redemptions
number
If it's defined, then the Coupon will be only usable n times.
used_count
number
The number of times the Coupon has been used.
The Coupon Object has two closely related fields, or types: percentage_off and amount_off . Only one can be defined while creating a new Coupon.
If you want to offer your customers a percentage off their total purchase as a discount, set the percentage_off to your desired percentage. Alternatively, set the amount_off for a fixed amount to be deducted from their total amount. Note: the currencyfield must be set when using amount_off.
Parameters
Request
Response
Body parameter
Type
Description
name
string
The name of a Coupon, e.g., Summer 2019
code
string
The code of a Coupon. This could be used by your customer while creating an Order, e.g, SUM2019.
If the code is not defined, it will be given a 'human readable' code of 6 randomly generated characters.
percent_off
float
The percentage of discount on the order given by the Coupon as a decimal between 0.0 and 0.1, e.g. 0.25 = 25%.
amount_off
float
The amount off the price of the order given by the Coupon.
starting_date
number
Defines when a coupon is gonna be available for your customer. By default it's defined as the moment you create it.
ending_date
number
The coupon will not be usable by your customer after this date.
max_redemptions
number
If it's defined, then the Coupon will be only usable n times.
1
POST /coupons HTTP/1.1
2
Content-Type: application/json
3
X-Builton-Api-Key: <builton-api-key>
4
Host: api.builton.dev
5
6
{
7
"name": "The Summer 2019",
8
"code": "SUM2019",
9
"amount_off": 20,
10
"currency": "EUR",
11
"starting_date": 1561967337,
12
"ending_date": 1567299599,
13
"max_redemptions": 10000
14
}
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"_id": {
6
"$oid": "5931697ed57ba271c0c7fr42"},
7
"created": {
8
"$date": 1496410494652},
9
"modified": {
10
"$date": 1496410494652},
11
"company": {
12
"$oid": "57ee9c71d76d431f8511142f"},
13
"active": true,
14
"delete": false,
15
"name": "The Summer 2019",
16
"code": "SUM2019",
17
"amount_off": 20,
18
"currency": "EUR",
19
"starting_date": {"$date": 1561967337},
20
"ending_date": {"$date": 1567299599},
21
"max_redemptions": 10000,
22
"used_count": 0
23
}
Copied!

Update a Coupon

If you decide to change the type of a Coupon, it's very simple: you just have to define the other type, percentage_off or amount_off, and BuiltOn removes the original field.
Remember, amount_off always requires that you set currency.
Parameters
Request
Response
Path Parameters
Type
Description
coupon_id
string
ID of the queried coupon.
Body Parameters
Type
Description
name
string
The name of a Coupon, e.g., Summer 2019.
code
string
The code of a Coupon. This could be used by your customer while creating an Order, e.g, SUM2019.
If the code is not defined, it will be given a 'human readable' code of 6 randomly generated characters.
percent_off
float
The percentage of discount on the order given by the Coupon as a decimal between 0.0 and 0.1, e.g. 0.25 = 25%.
amount_off
float
The amount off the price of the order given by the Coupon.
starting_date
number
Defines when a coupon is gonna be available for your customer. By default it's defined as the moment you create it.
ending_date
number
The coupon will not be usable by your customer after this date.
max_redemptions
number
If it's defined, then the Coupon will be only usable n times.
1
PUT /coupons/<coupon_id> HTTP/1.1
2
Content-Type: application/json
3
X-Builton-Api-Key: <builton-api-key>
4
Host: api.builton.dev
5
6
{
7
"percent_off": 0.25
8
}
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"_id": {
6
"$oid": "5931697ed57ba271c0c7fr42"},
7
"created": {
8
"$date": 1496410494652},
9
"modified": {
10
"$date": 1496410494652},
11
"company": {
12
"$oid": "57ee9c71d76d431f8511142f"},
13
"active": true,
14
"delete": false,
15
"name": "The Summer 2019",
16
"code": "SUM2019",
17
"percent_off": 0.25,
18
"currency": "EUR",
19
"starting_date": {"$date": 1561967337},
20
"ending_date": {"$date": 1567299599},
21
"max_redemptions": 10000,
22
"used_count": 0
23
}
Copied!

Delete a Coupon

Parameters
Request
Response
Path Parameters
Type
Description
coupon_id
string
ID of the queried Coupon.
1
DELETE /coupons/<coupon_id> HTTP/1.1
2
Content-Type: application/json
3
X-Builton-Api-Key: <builton-api-key>
4
Host: api.builton.dev
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"_id": {
6
"$oid": "5931697ed57ba271c0c7fr42"},
7
"created": {
8
"$date": 1496410494652},
9
"modified": {
10
"$date": 1496410494652},
11
"company": {
12
"$oid": "57ee9c71d76d431f8511142f"},
13
"active": false,
14
"delete": true,
15
"name": "The Summer 2019",
16
"code": "SUM2019",
17
"percent_off": 0.25,
18
"currency": "EUR",
19
"starting_date": {"$date": 1561967337},
20
"ending_date": {"$date": 1567299599},
21
"max_redemptions": 10000,
22
"used_count": 0
23
}
Copied!

Retrieve a Coupon

Parameters
Request
Response
Path Parameters
Type
Description
coupon_id
string
The Coupon's ID.
1
GET /coupons/<coupon_id> HTTP/1.1
2
Content-Type: application/json
3
X-Builton-Api-Key: <builton-api-key>
4
Host: api.builton.dev
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"_id": {
6
"$oid": "5931697ed57ba271c0c7fr42"},
7
"created": {
8
"$date": 1496410494652},
9
"modified": {
10
"$date": 1496410494652},
11
"company": {
12
"$oid": "57ee9c71d76d431f8511142f"},
13
"active": true,
14
"delete": false,
15
"name": "The Summer 2019",
16
"code": "SUM2019",
17
"percent_off": 0.25,
18
"currency": "EUR",
19
"starting_fate": {"$date": 1561967337},
20
"ending_date": {"$date": 1567299599},
21
"max_redemptions": 10000,
22
"used_count": 0
23
}
Copied!

Get a list of Coupons

Parameters
Request
Response
Query Parameters
Type
Description
size
number
Number of items to retrieve. Default is 10.
page
number
Which page to retrieve. Default is 0.
date_filter
number
Date field used to filter results. Default is CREATED.
from_date
number
Start date, timestamp format. Default is None.
to_date
number
End date, timestamp format. Default is None.
sort
string
Field used for sorting results. Default is by name.
included_deleted
boolean
Also retrieves the deleted ones. Default is False.
active
boolean
Retrieves items in a specific active status. Default is None.
1
GET /coupons HTTP/1.1
2
Content-Type: application/json
3
X-Builton-Api-Key: <builton-api-key>
4
Host: api.builton.dev
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
[
5
{
6
"_id": {
7
"$oid": "5931697ed57ba271c0c7fr42"},
8
"created": {
9
"$date": 1496410494652},
10
"modified": {
11
"$date": 1496410494652},
12
"company": {
13
"$oid": "57ee9c71d76d431f8511142f"},
14
"active": true,
15
"delete": false,
16
"name": "The Summer 2019",
17
"code": "SUM2019",
18
"percent_off": 0.25,
19
"currency": "EUR",
20
"starting_date": {"$date": 1561967337},
21
"ending_date": {"$date": 1567299599},
22
"max_redemptions": 10000,
23
"used_count": 0
24
}
25
]
Copied!

Search Coupons

Parameters
Request
Response
Query Parameters
Type
Description
query
string
The search query; code, name or id.
size
number
Number of items to retrieve. Default is 10.
page
number
Which page to retrieve. Default is 0.
date_filter
number
Date field used to filter results. Default is CREATED.
from_date
number
Start date, timestamp format. Default is None.
to_date
number
End date, timestamp format. Default is None.
sort
string
Field used for sorting results. Default is by name.
included_deleted
boolean
Also retrieves the deleted ones. Default is False.
active
boolean
Retrieves items in a specific active status.Default is None.
1
GET /coupons/search HTTP/1.1
2
Content-Type: application/json
3
X-Builton-Api-Key: <builton-api-key>
4
Host: api.builton.dev
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
[
5
{
6
"_id": {
7
"$oid": "5931697ed57ba271c0c7fr42"},
8
"created": {
9
"$date": 1496410494652},
10
"modified": {
11
"$date": 1496410494652},
12
"company": {
13
"$oid": "57ee9c71d76d431f8511142f"},
14
"active": true,
15
"delete": false,
16
"name": "The Summer 2019",
17
"code": "SUM2019",
18
"percent_off": 0.25,
19
"currency": "EUR",
20
"starting_date": {"$date": 1561967337},
21
"ending_date": {"$date": 1567299599},
22
"max_redemptions": 10000,
23
"used_count": 0
24
}
25
]
Copied!