Discounts
Discount codes, made through the admin's own form.
| Operation | Method and path | Scope |
|---|---|---|
| List discount codes | GET /discounts | discounts:read |
| Create a discount code | POST /discounts | discounts:write |
| Get a discount code | GET /discounts/{id} | discounts:read |
| Change a discount code | PATCH /discounts/{id} | discounts:publish |
| Switch a discount code off | POST /discounts/{id}/disable | discounts:publish |
List discount codes
GET https://kaizenaflow.com/api/admin/v1/discounts
The store's discount codes, newest first.
Operation:
discounts.listScope:
discounts:read, ordiscounts:write, which reads tooAnswers:
200, a page: the rows underdata, andnextfor the page after.Pages: at most 100 rows, 50 when
limitis left out; give an answer'snextas?after=for the page after.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer, 1 to 100 | no | Rows a page holds, at most 100; 50 when left out. A larger number gives 100. |
after | string, at most 200 characters | no | The next cursor of the page before; the first page when left out. |
updated_after | string (date-time) | no | Only what was made or changed after this time (ISO 8601 with its offset), for incremental sync. |
Answer
| Field | Type | Description |
|---|---|---|
data | list of objects | |
data[].id | string (uuid) | |
data[].code | string | |
data[].kind | one of percent, fixed, free_shipping | |
data[].percent | number or null | |
data[].amounts_minor | map of string to number | For a fixed amount off: the amount per market, in minor units of the market's currency. |
data[].active | boolean | |
data[].starts_at | string (date-time) or null | |
data[].ends_at | string (date-time) or null | |
data[].usage_limit | number or null | |
data[].created_at | string (date-time) | |
data[].updated_at | string (date-time) | |
next | string or null | The cursor of the next page, given as ?after=; null on the last page. |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 422 | invalid | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something went wrong on our side; nothing more was done. It is safe to try again. |
Example request
curl
curl 'https://kaizenaflow.com/api/admin/v1/discounts' \
-H "Authorization: Bearer $KAIZENA_TOKEN"JavaScript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/discounts", {
headers: {
Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
},
});
const answer = await response.json();Python
import json
import os
import urllib.request
request = urllib.request.Request(
"https://kaizenaflow.com/api/admin/v1/discounts",
headers={
"Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
},
)
with urllib.request.urlopen(request) as response:
answer = json.load(response)Create a discount code
POST https://kaizenaflow.com/api/admin/v1/discounts
Makes a discount code through the admin's own form and its checks: a percent, a fixed amount per market, or free shipping.
Operation:
discounts.createScope:
discounts:writeAnswers:
201, made: the answer underdata.Once only: with an
Idempotency-Keyheader.
Body
JSON, with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
code | string, 1 to 100 characters | yes | What shoppers type: 3 to 40 letters, digits, - or _. Kept in capitals, without spaces. |
kind | one of percent, fixed, free_shipping | yes | |
percent | integer, 1 to 100 | no | For percent: how much is taken off; 10 when left out. |
amounts | map of string to string | no | For fixed: the amount off per market code, written in the market's currency, such as { "NO": "100" }. |
min_subtotals | map of string to string | no | The least a basket must hold per market code, written in the market's currency. |
starts_at | string or null | no | When it starts, as the store's local time (YYYY-MM-DDTHH:mm); at once when left out. |
ends_at | string or null | no | When it ends, as the store's local time; never when left out. |
usage_limit | integer, 1 to 1,000,000 or null | no | How many times it may be used in all; no limit when left out. |
once_per_customer | boolean | no | |
active | boolean | no | False makes it switched off; on when left out. |
Answer
| Field | Type | Description |
|---|---|---|
data | object | |
data.id | string (uuid) |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 409 | conflict | Nothing was done: it clashes with how things are now (nothing left to send), or an Idempotency-Key is in use or was used for another request. |
| 422 | invalid | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something went wrong on our side; nothing more was done. It is safe to try again. |
Example request
curl
curl -X POST 'https://kaizenaflow.com/api/admin/v1/discounts' \
-H "Authorization: Bearer $KAIZENA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"code":"SPRING10","kind":"percent"}'JavaScript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/discounts", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"code": "SPRING10",
"kind": "percent"
}),
});
const answer = await response.json();Python
import json
import os
import urllib.request
request = urllib.request.Request(
"https://kaizenaflow.com/api/admin/v1/discounts",
method="POST",
headers={
"Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
"Content-Type": "application/json",
},
data=json.dumps({
"code": "SPRING10",
"kind": "percent",
}).encode(),
)
with urllib.request.urlopen(request) as response:
answer = json.load(response)Get a discount code
GET https://kaizenaflow.com/api/admin/v1/discounts/{id}
One discount code with how often it was used.
Operation:
discounts.getScope:
discounts:read, ordiscounts:write, which reads tooAnswers:
200, the answer underdata.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string (uuid) | yes | The thing's id in this store. |
Answer
| Field | Type | Description |
|---|---|---|
data | object | |
data.id | string (uuid) | |
data.code | string | |
data.kind | one of percent, fixed, free_shipping | |
data.percent | number or null | |
data.amounts_minor | map of string to number | For a fixed amount off: per market code, in minor units of the market's currency. |
data.min_subtotals_minor | map of string to number | |
data.active | boolean | |
data.starts_at | string (date-time) or null | |
data.ends_at | string (date-time) or null | |
data.usage_limit | number or null | |
data.once_per_customer | boolean | |
data.used | integer | Paid orders that used it. |
data.applies_to | one of everything, some | some: chosen products, categories or tags (set in the admin). |
data.for_some_customers | boolean | Only groups, named customers or a segment (set in the admin). |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | not_found | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something went wrong on our side; nothing more was done. It is safe to try again. |
Example request
curl
curl 'https://kaizenaflow.com/api/admin/v1/discounts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f' \
-H "Authorization: Bearer $KAIZENA_TOKEN"JavaScript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/discounts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f", {
headers: {
Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
},
});
const answer = await response.json();Python
import json
import os
import urllib.request
request = urllib.request.Request(
"https://kaizenaflow.com/api/admin/v1/discounts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f",
headers={
"Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
},
)
with urllib.request.urlopen(request) as response:
answer = json.load(response)Change a discount code
PATCH https://kaizenaflow.com/api/admin/v1/discounts/{id}
Changes only what is given, through the admin's own form and its checks; what it reaches and who may use it stay as set in the admin. Orders already placed keep what they got. A loyalty reward's code is changed with its reward.
Operation:
discounts.updateScope:
discounts:publishAnswers:
200, the answer underdata.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string (uuid) | yes | The thing's id in this store. |
Body
JSON, with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
code | string, 1 to 100 characters | no | |
percent | integer, 1 to 100 | no | For percent: how much is taken off. |
amounts | map of string to string | no | For fixed: the amount off per market code, written in the market's currency; replaces what is there. |
min_subtotals | map of string to string | no | |
starts_at | string or null | no | As the store's local time (YYYY-MM-DDTHH:mm), or ISO 8601; null: at once. |
ends_at | string or null | no | null: never. |
usage_limit | integer, 1 to 1,000,000 or null | no | |
once_per_customer | boolean | no | |
active | boolean | no |
Answer
| Field | Type | Description |
|---|---|---|
data | object | |
data.id | string (uuid) | |
data.code | string | |
data.kind | one of percent, fixed, free_shipping | |
data.percent | number or null | |
data.amounts_minor | map of string to number | For a fixed amount off: per market code, in minor units of the market's currency. |
data.min_subtotals_minor | map of string to number | |
data.active | boolean | |
data.starts_at | string (date-time) or null | |
data.ends_at | string (date-time) or null | |
data.usage_limit | number or null | |
data.once_per_customer | boolean | |
data.used | integer | Paid orders that used it. |
data.applies_to | one of everything, some | some: chosen products, categories or tags (set in the admin). |
data.for_some_customers | boolean | Only groups, named customers or a segment (set in the admin). |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | not_found | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | conflict | Nothing was done: it clashes with how things are now (nothing left to send), or an Idempotency-Key is in use or was used for another request. |
| 422 | invalid | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something went wrong on our side; nothing more was done. It is safe to try again. |
Example request
curl
curl -X PATCH 'https://kaizenaflow.com/api/admin/v1/discounts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f' \
-H "Authorization: Bearer $KAIZENA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"code":"SPRING10"}'JavaScript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/discounts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f", {
method: "PATCH",
headers: {
Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"code": "SPRING10"
}),
});
const answer = await response.json();Python
import json
import os
import urllib.request
request = urllib.request.Request(
"https://kaizenaflow.com/api/admin/v1/discounts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f",
method="PATCH",
headers={
"Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
"Content-Type": "application/json",
},
data=json.dumps({
"code": "SPRING10",
}).encode(),
)
with urllib.request.urlopen(request) as response:
answer = json.load(response)Switch a discount code off
POST https://kaizenaflow.com/api/admin/v1/discounts/{id}/disable
Switches the code off, as its form's switch does: shoppers can no longer use it; nothing else changes.
Operation:
discounts.disableScope:
discounts:publishAnswers:
200, the answer underdata.Once only: with an
Idempotency-Keyheader.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string (uuid) | yes | The thing's id in this store. |
Body
JSON, with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
body | object | yes |
Answer
| Field | Type | Description |
|---|---|---|
data | object | |
data.id | string (uuid) | |
data.code | string | |
data.kind | one of percent, fixed, free_shipping | |
data.percent | number or null | |
data.amounts_minor | map of string to number | For a fixed amount off: per market code, in minor units of the market's currency. |
data.min_subtotals_minor | map of string to number | |
data.active | boolean | |
data.starts_at | string (date-time) or null | |
data.ends_at | string (date-time) or null | |
data.usage_limit | number or null | |
data.once_per_customer | boolean | |
data.used | integer | Paid orders that used it. |
data.applies_to | one of everything, some | some: chosen products, categories or tags (set in the admin). |
data.for_some_customers | boolean | Only groups, named customers or a segment (set in the admin). |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | not_found | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | conflict | Nothing was done: it clashes with how things are now (nothing left to send), or an Idempotency-Key is in use or was used for another request. |
| 422 | invalid | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something went wrong on our side; nothing more was done. It is safe to try again. |
Example request
curl
curl -X POST 'https://kaizenaflow.com/api/admin/v1/discounts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/disable' \
-H "Authorization: Bearer $KAIZENA_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'JavaScript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/discounts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/disable", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
});
const answer = await response.json();Python
import json
import os
import urllib.request
request = urllib.request.Request(
"https://kaizenaflow.com/api/admin/v1/discounts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/disable",
method="POST",
headers={
"Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
"Content-Type": "application/json",
},
data=json.dumps({}).encode(),
)
with urllib.request.urlopen(request) as response:
answer = json.load(response)