B7RDevelopers
ReferenceStore promotions
Reference / Store promotions

Store promotions

View .md

Ids, names, prices and times in the examples are samples. Read the real values from the API.

Reading needs the key area my_store:read and changing needs my_store:write beside it. The calls answer as the My Store calls do when B7R stores are not open to your account (409 feature_not_available), when B7R cannot tell (503 service_unavailable), and before you open a store in the B7R app (404 not_found with store_missing). A change counts against store_writes_per_minute (GET /v1/me?include=limits) and takes an Idempotency-Key; a call sent again with the same key answers what the first answered.

A floor is the lowest price the store allows a product, worked out from its cost and B7R’s settings: it is null, and the promotions say why, when it cannot be worked out right now.

Read what a code leaves as profit

GET/v1/my-store/promotions

For each product on the store, at most 1,000 (truncated: true when the store holds that many or more): its price, its floor, the profit on one item sold with no code, and the largest percent and fixed code that keep it at its floor. A code applies to the whole store, so the top-level max_percent and max_fixed are the largest the whole store allows: a code above them is refused.

When the floors cannot be worked out right now, the answer is available: false with the reason, no_active_carrier or pricing_unavailable; a code cannot be saved until they can.

Headers

Authorizationstringrequired

Bearer b7r_live_.... A key with the my_store:read area. X-B7R-Key works too; send one, never both.

Accept-Languagestring

ar for Arabic error titles; anything else gives English. Codes never change.

Answer

Errors

Request
curl https://api.b7r.app/v1/my-store/promotions \
  -H "Authorization: Bearer $B7R_API_KEY"
const res = await fetch("https://api.b7r.app/v1/my-store/promotions", {
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
  },
});
const data = await res.json();
import os, requests

res = requests.get(
    "https://api.b7r.app/v1/my-store/promotions",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
    },
    timeout=30,
)
data = res.json()
200 OK
{
  "available": true,
  "max_percent": 30,
  "max_fixed": "36.00",
  "products": [
    {
      "store_product_id": "3c4d5e6f-7a8b-4c9d-8e1f-2a3b4c5d6e7f",
      "product_id": "4d5e6f7a-8b9c-4d0e-9f2a-3b4c5d6e7f8a",
      "name": {
        "ar": "قميص الخط العربي",
        "en": "Calligraphy shirt"
      },
      "retail_price": "120.00",
      "floor_price": "84.00",
      "profit": "31.20",
      "max_percent": 30,
      "max_fixed": "36.00"
    }
  ],
  "truncated": false
}

List the discount codes

GET/v1/my-store/codes

Newest first, stopped and ended codes included, at most 1,000 (truncated: true when the list reached that many). value has two decimals: a percent for percent, SAR for fixed. uses counts the orders that used the code; active is false once you stopped it.

Headers

Authorizationstringrequired

Bearer b7r_live_.... A key with the my_store:read area. X-B7R-Key works too; send one, never both.

Accept-Languagestring

ar for Arabic error titles; anything else gives English. Codes never change.

Answer

dataarray of objectrequired

At most 1000 items.

Child fields
idstring (uuid)required
codestringrequired
kindstringrequired

One of percent, fixed.

valuestringrequired
starts_atstringrequired
ends_atstring or nullrequired
max_usesinteger or nullrequired
usesintegerrequired
min_orderstring or nullrequired
activebooleanrequired
truncatedbooleanrequired

Errors

Request
curl https://api.b7r.app/v1/my-store/codes \
  -H "Authorization: Bearer $B7R_API_KEY"
const res = await fetch("https://api.b7r.app/v1/my-store/codes", {
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
  },
});
const data = await res.json();
import os, requests

res = requests.get(
    "https://api.b7r.app/v1/my-store/codes",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
    },
    timeout=30,
)
data = res.json()
200 OK
{
  "data": [
    {
      "id": "6f7a8b9c-0d1e-4f2a-9b4c-5d6e7f8a9b0c",
      "code": "RAMADAN",
      "kind": "percent",
      "value": "10.00",
      "starts_at": "2026-11-20T00:00:00.000Z",
      "ends_at": null,
      "max_uses": 100,
      "uses": 3,
      "min_order": null,
      "active": true
    }
  ],
  "truncated": false
}

The calls below change the discount codes and free shipping. Each answers the code it changed, as the list gives it, or the threshold; {id} is the code’s id. One that is not on your store, or is on another account’s, answers 404 not_found, the same as one that does not exist.

If an answer is lost and you send the call again with a new key, a second code answers 409 my_store_rejected with code_taken, naming the code in existing_id. Read GET /v1/my-store/codes to see what happened. The same key always answers what the first call answered.

Create a discount code

POST/v1/my-store/codes

Every field is required; send null for one you leave empty. code is 2 to 40 characters with no spaces, unique on the store ignoring case (code_taken, with existing_id). value has at most two decimals: a percent above 0 and at most 100 for percent, SAR for fixed. starts_at null starts the code now; ends_at, max_uses and min_order null mean no end, no use limit and no minimum order.

A code applies to the whole store, so it is checked against the floor of every product on it: one that would take a product below its floor is refused with code_breaks_floor. GET /v1/my-store/promotions gives the largest percent and fixed code the store allows. A value refused at its field names it: invalid_code, invalid_value, invalid_window (at /body/ends_at), invalid_max_uses or invalid_min_order.

Headers

Authorizationstringrequired

Bearer b7r_live_.... A key with the my_store:write area. X-B7R-Key works too; send one, never both.

Idempotency-Keystringrequired

A new value per operation (up to 255 letters, digits, ., _, : or -; a UUID works), the same value on its retries. See Safe retries.

Content-Typestringrequired

application/json, when the request has a body.

Accept-Languagestring

ar for Arabic error titles; anything else gives English. Codes never change.

Body

codestringrequired

At most 40.

kindstringrequired

One of percent, fixed.

valuestringrequired
ends_atstring (date-time) or nullrequired
max_usesinteger or nullrequired
min_orderstring or nullrequired
starts_atstring (date-time) or nullrequired

Answer

codeobjectrequired
Child fields
idstring (uuid)required
codestringrequired
kindstringrequired

One of percent, fixed.

valuestringrequired
starts_atstringrequired
ends_atstring or nullrequired
max_usesinteger or nullrequired
usesintegerrequired
min_orderstring or nullrequired
activebooleanrequired

Errors

Request
curl -X POST https://api.b7r.app/v1/my-store/codes \
  -H "Authorization: Bearer $B7R_API_KEY" \
  -H "Idempotency-Key: $(uuidgen 2>/dev/null || node -e 'console.log(crypto.randomUUID())')" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "RAMADAN",
    "kind": "percent",
    "value": "10.00",
    "starts_at": null,
    "ends_at": null,
    "max_uses": 100,
    "min_order": null
  }'
const res = await fetch("https://api.b7r.app/v1/my-store/codes", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "code": "RAMADAN",
    "kind": "percent",
    "value": "10.00",
    "starts_at": null,
    "ends_at": null,
    "max_uses": 100,
    "min_order": null
  }),
});
const data = await res.json();
import os, requests, uuid

res = requests.post(
    "https://api.b7r.app/v1/my-store/codes",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "code": "RAMADAN",
        "kind": "percent",
        "value": "10.00",
        "starts_at": None,
        "ends_at": None,
        "max_uses": 100,
        "min_order": None
    },
    timeout=30,
)
data = res.json()
201 Created
{
  "code": {
    "id": "6f7a8b9c-0d1e-4f2a-9b4c-5d6e7f8a9b0c",
    "code": "RAMADAN",
    "kind": "percent",
    "value": "10.00",
    "starts_at": "2026-11-20T00:00:00.000Z",
    "ends_at": null,
    "max_uses": 100,
    "uses": 3,
    "min_order": null,
    "active": true
  }
}

Change a discount code

PATCH/v1/my-store/codes/{id}

Replaces the whole code, as the app’s edit does: send every field, as for creating it, and a field you do not change with the value GET /v1/my-store/codes gives. starts_at is required here: send back the one you read; null is refused at /body/starts_at (invalid_window). The code is checked against the floors again. The orders that already used it keep their discount.

Headers

Authorizationstringrequired

Bearer b7r_live_.... A key with the my_store:write area. X-B7R-Key works too; send one, never both.

If-Matchstring

The ETag header of your last read. If the product changed since, the answer is 412 precondition_failed and nothing changes.

Idempotency-Keystring

Optional on a PATCH; when sent, a retry with the same key answers the first result.

Content-Typestringrequired

application/json, when the request has a body.

Accept-Languagestring

ar for Arabic error titles; anything else gives English. Codes never change.

Path

idstring (uuid)required

Body

codestringrequired

At most 40.

kindstringrequired

One of percent, fixed.

valuestringrequired
ends_atstring (date-time) or nullrequired
max_usesinteger or nullrequired
min_orderstring or nullrequired
starts_atstring (date-time) or nullrequired

Answer

codeobjectrequired
Child fields
idstring (uuid)required
codestringrequired
kindstringrequired

One of percent, fixed.

valuestringrequired
starts_atstringrequired
ends_atstring or nullrequired
max_usesinteger or nullrequired
usesintegerrequired
min_orderstring or nullrequired
activebooleanrequired

Errors

Request
curl -X PATCH https://api.b7r.app/v1/my-store/codes/{id} \
  -H "Authorization: Bearer $B7R_API_KEY" \
  -H "If-Match: $ETAG" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "RAMADAN",
    "kind": "percent",
    "value": "15.00",
    "starts_at": "2026-11-20T00:00:00.000Z",
    "ends_at": null,
    "max_uses": 100,
    "min_order": null
  }'
const res = await fetch("https://api.b7r.app/v1/my-store/codes/{id}", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
    "If-Match": etag, // the ETag header of your last read
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "code": "RAMADAN",
    "kind": "percent",
    "value": "15.00",
    "starts_at": "2026-11-20T00:00:00.000Z",
    "ends_at": null,
    "max_uses": 100,
    "min_order": null
  }),
});
const data = await res.json();
import os, requests

res = requests.patch(
    "https://api.b7r.app/v1/my-store/codes/{id}",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
        "If-Match": etag,  # the ETag header of your last read
    },
    json={
        "code": "RAMADAN",
        "kind": "percent",
        "value": "15.00",
        "starts_at": "2026-11-20T00:00:00.000Z",
        "ends_at": None,
        "max_uses": 100,
        "min_order": None
    },
    timeout=30,
)
data = res.json()
200 OK
{
  "code": {
    "id": "6f7a8b9c-0d1e-4f2a-9b4c-5d6e7f8a9b0c",
    "code": "RAMADAN",
    "kind": "percent",
    "value": "10.00",
    "starts_at": "2026-11-20T00:00:00.000Z",
    "ends_at": null,
    "max_uses": 100,
    "uses": 3,
    "min_order": null,
    "active": true
  }
}

Stop a discount code

POST/v1/my-store/codes/{id}/deactivate

Shoppers can no longer use it; the orders that used it keep their record, and it stays in the list with active: false.

Headers

Authorizationstringrequired

Bearer b7r_live_.... A key with the my_store:write area. X-B7R-Key works too; send one, never both.

Idempotency-Keystringrequired

A new value per operation (up to 255 letters, digits, ., _, : or -; a UUID works), the same value on its retries. See Safe retries.

Content-Typestringrequired

application/json, when the request has a body.

Accept-Languagestring

ar for Arabic error titles; anything else gives English. Codes never change.

Path

idstring (uuid)required

Answer

codeobjectrequired
Child fields
idstring (uuid)required
codestringrequired
kindstringrequired

One of percent, fixed.

valuestringrequired
starts_atstringrequired
ends_atstring or nullrequired
max_usesinteger or nullrequired
usesintegerrequired
min_orderstring or nullrequired
activebooleanrequired

Errors

Request
curl -X POST https://api.b7r.app/v1/my-store/codes/{id}/deactivate \
  -H "Authorization: Bearer $B7R_API_KEY" \
  -H "Idempotency-Key: $(uuidgen 2>/dev/null || node -e 'console.log(crypto.randomUUID())')"
const res = await fetch("https://api.b7r.app/v1/my-store/codes/{id}/deactivate", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
  },
});
const data = await res.json();
import os, requests, uuid

res = requests.post(
    "https://api.b7r.app/v1/my-store/codes/{id}/deactivate",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    timeout=30,
)
data = res.json()
200 OK
{
  "code": {
    "id": "6f7a8b9c-0d1e-4f2a-9b4c-5d6e7f8a9b0c",
    "code": "RAMADAN",
    "kind": "percent",
    "value": "10.00",
    "starts_at": "2026-11-20T00:00:00.000Z",
    "ends_at": null,
    "max_uses": 100,
    "uses": 3,
    "min_order": null,
    "active": false
  }
}

Set free shipping

PATCH/v1/my-store/free-shipping

threshold is the order total, in SAR with at most two decimals and above 0, from which shipping is free on your store; null switches free shipping off. Another value is refused at /body/threshold (invalid_threshold).

Headers

Authorizationstringrequired

Bearer b7r_live_.... A key with the my_store:write area. X-B7R-Key works too; send one, never both.

If-Matchstring

The ETag header of your last read. If the product changed since, the answer is 412 precondition_failed and nothing changes.

Idempotency-Keystring

Optional on a PATCH; when sent, a retry with the same key answers the first result.

Content-Typestringrequired

application/json, when the request has a body.

Accept-Languagestring

ar for Arabic error titles; anything else gives English. Codes never change.

Body

thresholdstring or nullrequired

Answer

free_shipping_thresholdstring or nullrequired

Errors

Request
curl -X PATCH https://api.b7r.app/v1/my-store/free-shipping \
  -H "Authorization: Bearer $B7R_API_KEY" \
  -H "If-Match: $ETAG" \
  -H "Content-Type: application/json" \
  -d '{
    "threshold": "250.00"
  }'
const res = await fetch("https://api.b7r.app/v1/my-store/free-shipping", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
    "If-Match": etag, // the ETag header of your last read
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "threshold": "250.00"
  }),
});
const data = await res.json();
import os, requests

res = requests.patch(
    "https://api.b7r.app/v1/my-store/free-shipping",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
        "If-Match": etag,  # the ETag header of your last read
    },
    json={
        "threshold": "250.00"
    },
    timeout=30,
)
data = res.json()
200 OK
{
  "free_shipping_threshold": "250.00"
}

Titles and headings of every page. llms-full.txt holds the full text.