Docs · Developer API

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.

Base URLhttps://kesper-production.up.railway.app
On this page

01In 30 seconds

  1. Sign in to your Kesper dashboard → Settings → Developer API Keys.
  2. Click New key, give it a label, copy the plaintext (it's only shown once).
  3. POST your orders to /api/ingest/orders and your catalog to /api/ingest/products. Agents and the "For you" cards pick it up on their next run.
  4. Optional: register a webhook under Settings → Store webhook so the changes you approve in Kesper (a price, a stock count, product copy) are sent to your system.

Every id, name, email and amount in the examples on this page is made up.

02Authentication

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/json

Plaintext keys are stored SHA-256-hashed at rest. If you lose a key, create a new one — there's no recovery path.

03Endpoints

POST
/api/ingest/ordersAuth: API key
Send orders (new or historical). Upserted by order_id, so resending is safe. Max 1,000 per request.
POST
/api/ingest/productsAuth: API key
Send your catalog: price, cost, stock, status, listing date. Upserted by item_id (or sku). Max 5,000 per request.
POST
/api/ingest/transactionsAuth: API key
Legacy: POS-style sales transactions. Still supported; also stored as orders. Max 1,000 per request.
POST
/api/ingest/inventoryAuth: API key
Legacy: inventory snapshot. Still supported; also stored as products (keyed by sku). Max 5,000 items per request.
POST
/api/ingest/keysAuth: Session (in-dashboard)
Create a new API key. Returns plaintext once; save it immediately.
GET
/api/ingest/keys?storeId=…Auth: Session (in-dashboard)
List API keys for a store (suffixes + metadata only — no plaintext).
DELETE
/api/ingest/keys/:idAuth: Session (in-dashboard)
Soft-revoke a key. Future requests with it return 401 immediately.
GET
/api/ingest/webhook?storeId=…Auth: Session (in-dashboard)
The store's webhook URL, secret suffix and last delivery. Never returns the secret.
PUT
/api/ingest/webhookAuth: Session, store owner
Register or replace the webhook URL ({ storeId, url }). The first registration returns the signing secret once.
POST
/api/ingest/webhook/rotate-secretAuth: Session, store owner
Issue a new signing secret (shown once). The old one stops working immediately.
POST
/api/ingest/webhook/testAuth: Session, store owner
Send a signed ping event to your webhook and report the result.
DELETE
/api/ingest/webhook?storeId=…Auth: Session, store owner
Remove the webhook. Kesper stops offering one-tap changes for API products.

04Orders — POST /api/ingest/orders

Body 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.

json · example values
[
  {
    "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 (optional, pick one): 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.

05Products — POST /api/ingest/products

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.

json · example values
[
  {
    "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.
  • If you use the legacy /inventory endpoint too, it updates the same rows by SKU — so either leave item_id out or set it equal to the SKU.

06Backfilling history

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.

07Transactions (legacy)

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.

json · example values
[
  {
    "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"
  }
]

08Inventory (legacy)

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".

json · example values
[
  {
    "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"
  }
]

09curl examples

Replace $KEY with your plaintext API key.

bash
# 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"}]'

10Responses & errors

Success is HTTP 200 with a small JSON body:

json · example values
// 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):

json · example values
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.

11Limits

  • 120 requests/minute per API key on the ingest endpoints.
  • 1,000 orders (each up to 500 lines) or 5,000 products per request.
  • 1,000 transactions / 5,000 inventory items per request on the legacy endpoints.
  • Request bodies up to 10 MB.
  • Standard RateLimit-* response headers are returned so you can pace your client.

12Webhooks — receiving approved changes

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.

  • Answer with any 2xx within 8 seconds once you've applied it. Anything else, a redirect, or no answer marks the change as failed in Kesper, with your status code.
  • The URL must be public HTTPS on the standard port. Private, internal and loopback addresses are refused, both when you register and on every delivery. Redirects are not followed.
  • 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.
  • Events: 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.
http · example values
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)".

13Verifying signatures

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.

node.js (express)
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 });
});
python (flask)
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}, 200

14What happens after you push

Data 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:

  • FRIDAY rolls transactions into the daily store state.
  • SCROOGE flags items priced below cost or under your target margin.
  • PEPPER suggests markdowns for items with stock and no sales in 60 days.
  • PROPHET warns when a fast seller is about to run out.
  • OASIS spots repeat customers who've gone quiet.
  • MONICA includes the relevant signals in tomorrow's brief.

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.

15Support

Questions about the API, schemas, or integration patterns? Email business@kesper.io.