Docs · Developer API
Push orders, products and inventory into Kesper from any system — custom POS, Zapier, in-house scripts, platforms we don't natively support — and receive the changes you approve back through a signed webhook.
https://kesper-production.up.railway.app/api/ingest/orders and your catalog to /api/ingest/products. Agents and the "For you" cards pick it up on their next run.Every id, name, email and amount in the examples on this page is made up.
Every ingest call needs a Bearer header with your API key. Keys look like kesper_<48 hex chars> and are tied to a single store.
Authorization: Bearer kesper_<48hex>
Content-Type: application/jsonPlaintext keys are stored SHA-256-hashed at rest. If you lose a key, create a new one — there's no recovery path.
/api/ingest/ordersAuth: API key/api/ingest/productsAuth: API key/api/ingest/transactionsAuth: API key/api/ingest/inventoryAuth: API key/api/ingest/keysAuth: Session (in-dashboard)/api/ingest/keys?storeId=…Auth: Session (in-dashboard)/api/ingest/keys/:idAuth: Session (in-dashboard)/api/ingest/webhook?storeId=…Auth: Session (in-dashboard)/api/ingest/webhookAuth: Session, store owner/api/ingest/webhook/rotate-secretAuth: Session, store owner/api/ingest/webhook/testAuth: Session, store owner/api/ingest/webhook?storeId=…Auth: Session, store ownerBody is a JSON array of orders (1–1,000). Every row is checked; if any row is invalid the whole request is rejected with a list of per-row errors and nothing is written, so you can fix and resend the same batch.
[
{
"order_id": "EXAMPLE-1001",
"placed_at": "2026-03-01T14:30:00Z",
"total": 42.00,
"currency": "USD",
"status": "paid",
"customer_email": "customer@example.com",
"lines": [
{ "sku": "EX-MUG-1", "item_id": "EXAMPLE-P-1", "title": "Example Mug",
"qty": 2, "unit_price": 21.00, "unit_cost": 8.00 }
]
}
]order_id — required, text, up to 128 characters, unique in your store. Sending it again updates the order.placed_at — required, ISO 8601. Not before 2000-01-01 and not more than a day in the future.total — required, number ≥ 0. currency — optional 3-letter code.status — optional: open, paid, fulfilled, cancelled, refunded, voided. Cancelled and voided orders are ignored by analysis; refunded ones don't count as sales.lines — required, 1–500 items. Each needs qty (> 0) and unit_price (≥ 0), and at least one of sku, item_id, title. unit_cost is optional — send it when you know it.customer_email — Kesper hashes it (SHA-256 of the trimmed, lowercased address) and never stores the email; customer_key — that same hash computed by you (64 hex characters; a raw email here is rejected); or customer_id — your own customer id, which Kesper also hashes. Without one, repeat-customer analysis skips the order.Body is a JSON array of products (1–5,000), one row per sellable item (variant). Rows are matched by item_id, or by sku when you send no item_id. Fields you leave out keep their stored value; send null to clear one.
[
{
"item_id": "EXAMPLE-P-1",
"sku": "EX-MUG-1",
"title": "Example Mug",
"price": 24.00,
"cost": 9.00,
"quantity": 12,
"status": "active",
"currency": "USD",
"listed_at": "2025-11-02T09:00:00Z",
"product_id": "EXAMPLE-PRODUCT-7"
}
]item_id or sku — at least one, up to 128 characters. title — required the first time Kesper sees an item.price, cost — numbers ≥ 0. quantity — whole number on hand.status — active, draft, archived or out_of_stock. Draft and archived items are ignored.listed_at — when the item was first listed (ISO 8601). Needed for slow-mover suggestions./inventory endpoint too, it updates the same rows by SKU — so either leave item_id out or set it equal to the SKU.Send past orders through the same /api/ingest/orders endpoint, oldest or newest first, in batches of up to 1,000. Because orders are matched by order_id, a batch that fails halfway can simply be resent. Each response includes a history block with the earliest and latest order Kesper now holds for your store, so you can see how far back you've reached. Some suggestions need history: a slow-mover markdown needs 60 days of orders, a "running low" alert 14 days, and "repeat customers gone quiet" 120 days of orders that carry a customer.
Still supported. Body is a JSON array of transaction objects. Required fields: transaction_id, timestamp (ISO 8601), items (array), total. Each transaction is also stored as an order (its customer_email, if any, is hashed). New integrations should use /orders, which validates every field.
[
{
"transaction_id": "tx_example_001",
"timestamp": "2026-05-12T15:42:00Z",
"items": [
{
"sku": "latte_12oz",
"name": "12oz Latte",
"qty": 1,
"unit_price": 5.50,
"cost": 1.20,
"total": 5.50
}
],
"total": 5.50,
"payment_method": "card"
}
]Still supported. Body is a JSON array of inventory items. Required fields: sku, name, qty_on_hand. Each item is also stored as a product keyed by its SKU; a cost or sell price of 0 is treated as "not known".
[
{
"sku": "latte_12oz",
"name": "12oz Latte",
"qty_on_hand": 87,
"qty_on_order": 0,
"cost": 1.20,
"sell_price": 5.50,
"category": "Beverages",
"expiry_date": "2026-06-15",
"last_sold": "2026-05-12T15:42:00Z"
}
]Replace $KEY with your plaintext API key.
# Send one order
curl -X POST https://kesper-production.up.railway.app/api/ingest/orders \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '[{"order_id":"EXAMPLE-1001","placed_at":"2026-03-01T14:30:00Z","total":42,"customer_email":"customer@example.com","lines":[{"sku":"EX-MUG-1","title":"Example Mug","qty":2,"unit_price":21}]}]'
# Send or update a product
curl -X POST https://kesper-production.up.railway.app/api/ingest/products \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '[{"item_id":"EXAMPLE-P-1","sku":"EX-MUG-1","title":"Example Mug","price":24,"cost":9,"quantity":12,"listed_at":"2025-11-02T09:00:00Z"}]'
# Legacy: push an inventory snapshot
curl -X POST https://kesper-production.up.railway.app/api/ingest/inventory \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '[{"sku":"latte","name":"12oz Latte","qty_on_hand":87,"qty_on_order":0,"cost":1.2,"sell_price":5.5,"category":"Beverages"}]'Success is HTTP 200 with a small JSON body:
// POST /api/ingest/orders
{ "ok": true, "received": 2, "upserted": 2, "source": "api", "storeId": "your_store_id",
"history": { "first_order_at": "2025-01-04T10:12:00.000Z", "last_order_at": "2026-03-01T14:30:00.000Z", "orders_stored": 2 } }
// POST /api/ingest/products — actionable_via is "webhook" once a webhook is registered
{ "ok": true, "received": 1, "upserted": 1, "source": "api", "storeId": "your_store_id", "actionable_via": null }Errors always carry an error message. On /orders and /products they also carry a code, and validation failures list every problem by row index and field (up to 100; error_count is the total):
HTTP 400
{
"error": "2 problems in 3 rows. Nothing was written — fix them and resend the batch.",
"code": "validation_failed",
"error_count": 2,
"errors": [
{ "index": 1, "field": "placed_at", "message": "must be an ISO 8601 date-time, e.g. 2026-03-01T14:30:00Z" },
{ "index": 2, "field": "lines[0].qty", "message": "must be greater than 0" }
]
}401 Bearer API key required — missing Authorization header.401 Invalid or revoked API key — key not found or revoked.400 invalid_body — the body isn't a non-empty JSON array.400 too_many_rows — more than 1,000 orders or 5,000 products; split the batch.400 validation_failed — see errors; nothing was written.400 Item N is missing required fields — legacy endpoints only.429 Ingest rate limited — max 120 requests per minute per key. Back off and retry.RateLimit-* response headers are returned so you can pace your client.Kesper's agents can suggest changes to products you sent through the API — a new price, a corrected stock count, clearer product copy. Nothing changes until the store owner approves it in Kesper. When they do, Kesper sends a signed POST to the HTTPS URL registered under Settings → Store webhook and your system applies the change.
Idempotency-Key is the Kesper action id. Apply each key at most once — after a timeout Kesper can't know whether you applied the change, and says so to the owner.action.update_price, action.set_inventory, action.update_product_content, and ping (the Settings test button). Apply the after value of each entry in data.changes to the item in data.item.POST /kesper/webhook HTTP/1.1
Host: hooks.example.com
Content-Type: application/json
User-Agent: Kesper-Webhooks/1.0
Kesper-Event: action.update_price
Kesper-Delivery: dlv_0123456789abcdef0123
Kesper-Timestamp: 1773415451
Kesper-Signature: v1=<hex HMAC-SHA256 of "<timestamp>.<raw body>">
Idempotency-Key: act_0123456789abcdef
{
"id": "evt_0123456789abcdef0123",
"type": "action.update_price",
"api_version": "2026-11-15",
"created_at": "2026-03-13T15:24:11.000Z",
"store_id": "your_store_id",
"data": {
"action": { "id": "act_0123456789abcdef", "type": "api.update_price",
"title": "Change price of Example Mug from 20.00 to 24.50 USD",
"approved_by": "Example Owner", "approved_at": "2026-03-13T15:24:10.000Z" },
"item": { "item_id": "EXAMPLE-P-1", "sku": "EX-MUG-1", "title": "Example Mug" },
"changes": [ { "field": "price", "label": "Price", "before": 20, "after": 24.5 } ],
"currency": "USD"
}
}action.set_inventory sends a quantity change (an absolute on-hand count). action.update_product_content sends any of title, description_html, seo_title, seo_description; Kesper only stores the title, so other fields' before reads "(not stored in Kesper)".
Compute HMAC-SHA256(secret, timestamp + "." + raw_body) as hex, prefix it with v1=, and compare it to Kesper-Signature in constant time. Use the raw request bytes — re-serialised JSON won't match. Refuse timestamps more than 5 minutes from your clock. The secret (whsec_…) is shown once when you register or rotate it.
import crypto from "node:crypto";
import express from "express";
const app = express();
const SECRET = process.env.KESPER_WEBHOOK_SECRET; // whsec_...
app.post("/kesper/webhook", express.raw({ type: "application/json" }), (req, res) => {
const timestamp = req.get("Kesper-Timestamp") ?? "";
const signature = req.get("Kesper-Signature") ?? "";
const body = req.body.toString("utf8"); // raw bytes, not re-serialised JSON
const expected = "v1=" + crypto.createHmac("sha256", SECRET).update(`${timestamp}.${body}`).digest("hex");
const fresh = /^\d+$/.test(timestamp) && Math.abs(Date.now() / 1000 - Number(timestamp)) <= 300;
const valid = fresh && signature.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
if (!valid) return res.status(401).end();
const event = JSON.parse(body);
// Apply event.data.changes to event.data.item once per Idempotency-Key, then:
res.status(200).json({ received: true });
});import hashlib, hmac, os, time
from flask import Flask, abort, request
app = Flask(__name__)
SECRET = os.environ["KESPER_WEBHOOK_SECRET"].encode() # whsec_...
@app.post("/kesper/webhook")
def kesper_webhook():
timestamp = request.headers.get("Kesper-Timestamp", "")
signature = request.headers.get("Kesper-Signature", "")
body = request.get_data() # raw bytes
expected = "v1=" + hmac.new(SECRET, timestamp.encode() + b"." + body, hashlib.sha256).hexdigest()
if not timestamp.isdigit() or abs(time.time() - int(timestamp)) > 300:
abort(401)
if not hmac.compare_digest(signature, expected):
abort(401)
event = request.get_json()
# Apply event["data"]["changes"] to event["data"]["item"] once per Idempotency-Key, then:
return {"received": True}, 200Data you send lands in the same store as Kesper's native connectors (Shopify, Square, Clover, Toast, CSV), so the agents treat it the same way on their next run:
Every number on a suggestion comes from the data you sent; with too little data, Kesper makes no suggestion. An item sold through several channels counts as one item only when the SKUs match exactly. With a webhook registered, price and stock suggestions for your API products come with a one-tap button; without one, they tell you what to change in your own system.
Questions about the API, schemas, or integration patterns? Email business@kesper.io.