B7RDevelopers
GuidesPlace an order
Guides / Place an order

Place an order

View .md

You need a key with the orders:write area, a SKU to order and money in your wallet. Any SKU of any active product of your account works: a product you made through the API (Create a product) or in the app, published to a store or not. Read the SKUs from variants[].sku in GET /v1/products. The SKU of an archived product, or of a colour or size you removed from a product, is refused. B7R prints, packs and ships under your brand: the shipping label carries the brand of your account, and your shopper never hears from B7R. Placing an order charges your wallet: rehearse with POST /v1/orders/check first. Amounts, ids and limits in the examples are samples.

Collect the shopper's details

  • customer.name and customer.phone: a Saudi mobile, 05XXXXXXXX or +9665XXXXXXXX.
  • address: country SA, city, district and street; the 8-character short national address, the building and the postal code when you have them.
  • customer.email is optional. Unrecognized fields in customer are refused with 400. The answers to placing and cancelling show the shopper masked and shipping_address as null, always. A key with customers:read reads the shopper back with ?include=customer (Shopper details).

Pick the carrier

Leave out carrier_id to use your default carrier (default_carrier in GET /v1/me), or send one from GET /v1/carriers: home delivers the parcel to the address on the order; pickup means it is collected from B7R. The fee is part of the charge.

Check the order

POST /v1/orders/check runs every check and answers the money, whether your wallet would pay it now (payment_status_if_created), what a top-up must cover when it would not (missing_if_created, null when it would be paid), and what the key may still spend today (spend_left_today). Nothing is saved or charged. Each line names a SKU, a quantity and your shopper's price per piece (selling_price), kept for your records; the minimum price was checked when the product was made. A line holds 1 to 999 pieces, as in the app, and an order up to 50 lines.

Request
curl -X POST https://api.b7r.app/v1/orders/check \
  -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 '{
    "external_id": "ord-77120",
    "seller": {
      "id": "seller-1042",
      "name": "Najd Prints"
    },
    "customer": {
      "name": "Sara Alqahtani",
      "phone": "0551234567",
      "email": "sara@example.com"
    },
    "address": {
      "country": "SA",
      "city": "Riyadh",
      "district": "Al Malqa",
      "street": "Anas Bin Malik Road",
      "national_address": "RRRD2929",
      "building": "2929"
    },
    "lines": [
      {
        "sku": "B7R-TS-0042-BLK-M",
        "quantity": 2,
        "selling_price": "99.00"
      }
    ],
    "carrier_id": "9b1d3f5a-7c9e-4b1d-8f5a-6c8e0a2b4d6f"
  }'
const res = await fetch("https://api.b7r.app/v1/orders/check", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "external_id": "ord-77120",
    "seller": {
      "id": "seller-1042",
      "name": "Najd Prints"
    },
    "customer": {
      "name": "Sara Alqahtani",
      "phone": "0551234567",
      "email": "sara@example.com"
    },
    "address": {
      "country": "SA",
      "city": "Riyadh",
      "district": "Al Malqa",
      "street": "Anas Bin Malik Road",
      "national_address": "RRRD2929",
      "building": "2929"
    },
    "lines": [
      {
        "sku": "B7R-TS-0042-BLK-M",
        "quantity": 2,
        "selling_price": "99.00"
      }
    ],
    "carrier_id": "9b1d3f5a-7c9e-4b1d-8f5a-6c8e0a2b4d6f"
  }),
});
const data = await res.json();
import os, requests, uuid

res = requests.post(
    "https://api.b7r.app/v1/orders/check",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "external_id": "ord-77120",
        "seller": {
            "id": "seller-1042",
            "name": "Najd Prints"
        },
        "customer": {
            "name": "Sara Alqahtani",
            "phone": "0551234567",
            "email": "sara@example.com"
        },
        "address": {
            "country": "SA",
            "city": "Riyadh",
            "district": "Al Malqa",
            "street": "Anas Bin Malik Road",
            "national_address": "RRRD2929",
            "building": "2929"
        },
        "lines": [
            {
                "sku": "B7R-TS-0042-BLK-M",
                "quantity": 2,
                "selling_price": "99.00"
            }
        ],
        "carrier_id": "9b1d3f5a-7c9e-4b1d-8f5a-6c8e0a2b4d6f"
    },
    timeout=30,
)
data = res.json()
200 OK
{
  "money": {
    "lines_total": {
      "net": "120.00",
      "vat": "0.00",
      "gross": "120.00",
      "currency": "SAR"
    },
    "shipping": {
      "net": "25.00",
      "vat": "0.00",
      "gross": "25.00",
      "currency": "SAR"
    },
    "total": {
      "net": "145.00",
      "vat": "0.00",
      "gross": "145.00",
      "currency": "SAR"
    }
  },
  "payment_status_if_created": "paid",
  "missing_if_created": null,
  "lines": [
    {
      "sku": "B7R-TS-0042-BLK-M",
      "quantity": 2,
      "unit_cost": {
        "net": "60.00",
        "vat": "0.00",
        "gross": "60.00",
        "currency": "SAR"
      }
    }
  ],
  "spend_left_today": {
    "amount": "1855.00",
    "currency": "SAR"
  }
}

Place it, once

Send the same body to POST /v1/orders. Two things make it safe to retry: your external_id (one order per value, ever) and the Idempotency-Key (the same key and body answer the first result). Make the key once per order and store it with your order before the first try.

Request
curl -X POST https://api.b7r.app/v1/orders \
  -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 '{
    "external_id": "ord-77120",
    "seller": {
      "id": "seller-1042",
      "name": "Najd Prints"
    },
    "customer": {
      "name": "Sara Alqahtani",
      "phone": "0551234567",
      "email": "sara@example.com"
    },
    "address": {
      "country": "SA",
      "city": "Riyadh",
      "district": "Al Malqa",
      "street": "Anas Bin Malik Road",
      "national_address": "RRRD2929",
      "building": "2929"
    },
    "lines": [
      {
        "sku": "B7R-TS-0042-BLK-M",
        "quantity": 2,
        "selling_price": "99.00"
      }
    ],
    "carrier_id": "9b1d3f5a-7c9e-4b1d-8f5a-6c8e0a2b4d6f"
  }'
const res = await fetch("https://api.b7r.app/v1/orders", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "external_id": "ord-77120",
    "seller": {
      "id": "seller-1042",
      "name": "Najd Prints"
    },
    "customer": {
      "name": "Sara Alqahtani",
      "phone": "0551234567",
      "email": "sara@example.com"
    },
    "address": {
      "country": "SA",
      "city": "Riyadh",
      "district": "Al Malqa",
      "street": "Anas Bin Malik Road",
      "national_address": "RRRD2929",
      "building": "2929"
    },
    "lines": [
      {
        "sku": "B7R-TS-0042-BLK-M",
        "quantity": 2,
        "selling_price": "99.00"
      }
    ],
    "carrier_id": "9b1d3f5a-7c9e-4b1d-8f5a-6c8e0a2b4d6f"
  }),
});
const data = await res.json();
import os, requests, uuid

res = requests.post(
    "https://api.b7r.app/v1/orders",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "external_id": "ord-77120",
        "seller": {
            "id": "seller-1042",
            "name": "Najd Prints"
        },
        "customer": {
            "name": "Sara Alqahtani",
            "phone": "0551234567",
            "email": "sara@example.com"
        },
        "address": {
            "country": "SA",
            "city": "Riyadh",
            "district": "Al Malqa",
            "street": "Anas Bin Malik Road",
            "national_address": "RRRD2929",
            "building": "2929"
        },
        "lines": [
            {
                "sku": "B7R-TS-0042-BLK-M",
                "quantity": 2,
                "selling_price": "99.00"
            }
        ],
        "carrier_id": "9b1d3f5a-7c9e-4b1d-8f5a-6c8e0a2b4d6f"
    },
    timeout=30,
)
data = res.json()
201 Created
{
  "id": "B26112200042",
  "external_id": "ord-77120",
  "channel": "api",
  "store_order_id": null,
  "store_order_number": null,
  "paid_by": "wallet",
  "status": "created",
  "payment_status": "paid",
  "funding": null,
  "seller": {
    "id": "seller-1042",
    "name": "Najd Prints"
  },
  "carrier_id": "9b1d3f5a-7c9e-4b1d-8f5a-6c8e0a2b4d6f",
  "delivery_method": "home",
  "money": {
    "lines_total": {
      "net": "120.00",
      "vat": "0.00",
      "gross": "120.00",
      "currency": "SAR"
    },
    "shipping": {
      "net": "25.00",
      "vat": "0.00",
      "gross": "25.00",
      "currency": "SAR"
    },
    "total": {
      "net": "145.00",
      "vat": "0.00",
      "gross": "145.00",
      "currency": "SAR"
    }
  },
  "sale": null,
  "shipments": [],
  "cancellation": null,
  "allowed_actions": [
    "cancel"
  ],
  "invoice": null,
  "created_at": "2026-11-22T12:30:11.902Z",
  "line_items": [
    {
      "id": "5b8c0d3e-4f6a-4b7c-9d8e-0f1a2b3c4d5e",
      "sku": "B7R-TS-0042-BLK-M",
      "quantity": 2,
      "unit_cost": {
        "net": "60.00",
        "vat": "0.00",
        "gross": "60.00",
        "currency": "SAR"
      },
      "selling_price": {
        "amount": "99.00",
        "currency": "SAR"
      }
    }
  ],
  "customer": {
    "name": "S***",
    "phone": "*********567"
  },
  "shipping_address": null
}
Retry without a double charge
import crypto from "node:crypto";

// The key is made once per order and stored with it, so every retry of
// this order sends the same key and the same body.
export async function placeOrder(myOrder, orderBody) {
  const idempotencyKey = myOrder.b7rIdempotencyKey ?? crypto.randomUUID();
  await db.orders.update(myOrder.id, { b7rIdempotencyKey: idempotencyKey });

  for (let attempt = 1; attempt <= 5; attempt++) {
    const res = await fetch("https://api.b7r.app/v1/orders", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.B7R_API_KEY}`,
        "Idempotency-Key": idempotencyKey,
        "Content-Type": "application/json",
      },
      body: JSON.stringify(orderBody),
    });
    const data = await res.json();
    if (res.ok) return data; // 201: the order, charged once
    if (!data.retryable) throw new Error(`${data.code} ${data.request_id}`);
    const wait = Number(res.headers.get("Retry-After")) || 2 ** attempt;
    await new Promise((r) => setTimeout(r, wait * 1000));
  }
  throw new Error("No answer after 5 tries: retry later with the same key");
}

Read what the wallet did

  • payment_status: paid: the wallet paid money.total (lines plus shipping) at once.
  • payment_status: not_paid: the balance was short. The order waits as not paid and is paid by itself after a top-up in the app: waiting orders are paid oldest first, and you get order.payment_changed. funding.missing is a top-up of this amount that is sure to pay it and every older unpaid order. The figure is as of the read, and the minimum top-up the app sets still applies. funding.top_up_url opens your wallet in the app. funding is null on any order that does not wait on your wallet.
  • Each order keeps its price: later cost changes never touch it.

When it is refused

AnswerWhat to do
422 order_rejectedEach bad line is listed by index with a code. sku_not_found: no product of your account has this SKU. sku_unavailable: the product is archived, or the colour was removed by you, or the size or colour was retired by B7R. product_blocked: the design is taken down or sent back for changes (see Design review). Fix the lines and place it again with a new Idempotency-Key.
403 verification_requiredYour account does not meet a verification requirement; errors names the missing groups (email, phone, personal, business, vat). Complete them in the app under Settings, then Verification, and send the same request again with the same Idempotency-Key. Nothing was charged. A retry with the same Idempotency-Key within 24 hours answers that order; a new request for an external_id already placed may answer 403 while the account is blocked, so read that order with GET /v1/orders?external_id=.
503 service_unavailableB7R could not read your verification status. Nothing was charged; retry with the same Idempotency-Key.
409 order_existsThis external_id was used before. Read that order; never place it twice.
422 spend_cap_reachedThe key's spending cap for today (Riyadh time) is reached. Wait for tomorrow.
422 unpaid_backlog_fullToo many orders wait for a top-up. Top up the wallet in the app.
429 order_limit_reachedToday's order limit is reached. Retry after Retry-After seconds.

Done: the order is placed and paid. Next: Track an order.

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