Skip to content
Kaizena FlowDocs
Search

Search the docs

Discounts

Discount codes, made through the admin's own form.

OperationMethod and pathScope
List discount codesGET /discountsdiscounts:read
Create a discount codePOST /discountsdiscounts:write
Get a discount codeGET /discounts/{id}discounts:read
Change a discount codePATCH /discounts/{id}discounts:publish
Switch a discount code offPOST /discounts/{id}/disablediscounts:publish

List discount codes

GET https://kaizenaflow.com/api/admin/v1/discounts

The store's discount codes, newest first.

  • Operation: discounts.list

  • Scope: discounts:read, or discounts:write, which reads too

  • Answers: 200, a page: the rows under data, and next for the page after.

  • Pages: at most 100 rows, 50 when limit is left out; give an answer's next as ?after= for the page after.

Query parameters

NameTypeRequiredDescription
limitinteger, 1 to 100noRows a page holds, at most 100; 50 when left out. A larger number gives 100.
afterstring, at most 200 charactersnoThe next cursor of the page before; the first page when left out.
updated_afterstring (date-time)noOnly what was made or changed after this time (ISO 8601 with its offset), for incremental sync.

Answer

FieldTypeDescription
datalist of objects
data[].idstring (uuid)
data[].codestring
data[].kindone of percent, fixed, free_shipping
data[].percentnumber or null
data[].amounts_minormap of string to numberFor a fixed amount off: the amount per market, in minor units of the market's currency.
data[].activeboolean
data[].starts_atstring (date-time) or null
data[].ends_atstring (date-time) or null
data[].usage_limitnumber or null
data[].created_atstring (date-time)
data[].updated_atstring (date-time)
nextstring or nullThe cursor of the next page, given as ?after=; null on the last page.

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe 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.
422invalidNothing 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.
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething 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.

Body

JSON, with Content-Type: application/json.

FieldTypeRequiredDescription
codestring, 1 to 100 charactersyesWhat shoppers type: 3 to 40 letters, digits, - or _. Kept in capitals, without spaces.
kindone of percent, fixed, free_shippingyes
percentinteger, 1 to 100noFor percent: how much is taken off; 10 when left out.
amountsmap of string to stringnoFor fixed: the amount off per market code, written in the market's currency, such as { "NO": "100" }.
min_subtotalsmap of string to stringnoThe least a basket must hold per market code, written in the market's currency.
starts_atstring or nullnoWhen it starts, as the store's local time (YYYY-MM-DDTHH:mm); at once when left out.
ends_atstring or nullnoWhen it ends, as the store's local time; never when left out.
usage_limitinteger, 1 to 1,000,000 or nullnoHow many times it may be used in all; no limit when left out.
once_per_customerbooleanno
activebooleannoFalse makes it switched off; on when left out.

Answer

FieldTypeDescription
dataobject
data.idstring (uuid)

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe 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.
409conflictNothing 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.
422invalidNothing 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.
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething 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.

Path parameters

NameTypeRequiredDescription
idstring (uuid)yesThe thing's id in this store.

Answer

FieldTypeDescription
dataobject
data.idstring (uuid)
data.codestring
data.kindone of percent, fixed, free_shipping
data.percentnumber or null
data.amounts_minormap of string to numberFor a fixed amount off: per market code, in minor units of the market's currency.
data.min_subtotals_minormap of string to number
data.activeboolean
data.starts_atstring (date-time) or null
data.ends_atstring (date-time) or null
data.usage_limitnumber or null
data.once_per_customerboolean
data.usedintegerPaid orders that used it.
data.applies_toone of everything, somesome: chosen products, categories or tags (set in the admin).
data.for_some_customersbooleanOnly groups, named customers or a segment (set in the admin).

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe 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.
404not_foundNo such route, or nothing with that id in the token's store (another store's ids are simply not found).
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething 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.update

  • Scope: discounts:publish

  • Answers: 200, the answer under data.

Path parameters

NameTypeRequiredDescription
idstring (uuid)yesThe thing's id in this store.

Body

JSON, with Content-Type: application/json.

FieldTypeRequiredDescription
codestring, 1 to 100 charactersno
percentinteger, 1 to 100noFor percent: how much is taken off.
amountsmap of string to stringnoFor fixed: the amount off per market code, written in the market's currency; replaces what is there.
min_subtotalsmap of string to stringno
starts_atstring or nullnoAs the store's local time (YYYY-MM-DDTHH:mm), or ISO 8601; null: at once.
ends_atstring or nullnonull: never.
usage_limitinteger, 1 to 1,000,000 or nullno
once_per_customerbooleanno
activebooleanno

Answer

FieldTypeDescription
dataobject
data.idstring (uuid)
data.codestring
data.kindone of percent, fixed, free_shipping
data.percentnumber or null
data.amounts_minormap of string to numberFor a fixed amount off: per market code, in minor units of the market's currency.
data.min_subtotals_minormap of string to number
data.activeboolean
data.starts_atstring (date-time) or null
data.ends_atstring (date-time) or null
data.usage_limitnumber or null
data.once_per_customerboolean
data.usedintegerPaid orders that used it.
data.applies_toone of everything, somesome: chosen products, categories or tags (set in the admin).
data.for_some_customersbooleanOnly groups, named customers or a segment (set in the admin).

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe 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.
404not_foundNo such route, or nothing with that id in the token's store (another store's ids are simply not found).
409conflictNothing 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.
422invalidNothing 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.
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething 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.

Path parameters

NameTypeRequiredDescription
idstring (uuid)yesThe thing's id in this store.

Body

JSON, with Content-Type: application/json.

FieldTypeRequiredDescription
bodyobjectyes

Answer

FieldTypeDescription
dataobject
data.idstring (uuid)
data.codestring
data.kindone of percent, fixed, free_shipping
data.percentnumber or null
data.amounts_minormap of string to numberFor a fixed amount off: per market code, in minor units of the market's currency.
data.min_subtotals_minormap of string to number
data.activeboolean
data.starts_atstring (date-time) or null
data.ends_atstring (date-time) or null
data.usage_limitnumber or null
data.once_per_customerboolean
data.usedintegerPaid orders that used it.
data.applies_toone of everything, somesome: chosen products, categories or tags (set in the admin).
data.for_some_customersbooleanOnly groups, named customers or a segment (set in the admin).

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe 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.
404not_foundNo such route, or nothing with that id in the token's store (another store's ids are simply not found).
409conflictNothing 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.
422invalidNothing 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.
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething 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)

Made from the API contract, version 1.57This page as Markdown

Was this page helpful?