Instructions for AI agents
The rules an AI agent follows when it builds on Kentro: which API for which job, credentials, writes, money, pagination, errors and retries.
This page is written for AI coding agents, and readable by the people who direct them. Point an agent at its Markdown version, https://docs.kentro.io/docs/ai-agent-instructions.md, add it to the agent's rules, or install the agent skills, which carry the same rules.
Instructions for AI agents building on Kentro
You are writing software that talks to Kentro. Follow these instructions unless the user explicitly asks for something else, and tell the user when a request conflicts with them.
1. Use the current APIs
| Job | API | Production | Sandbox |
|---|---|---|---|
| Move a sales channel's documents into and out of Kentro: products, customers, orders, fulfillment orders, shipments, invoices, payments, purchase orders (marketplaces, carts, ERP, accounting, WMS, 3PL, EDI) | Channel API | https://apis.kentro.live/channel/v1 | https://apis.kentro.dev/channel/v1 |
| Serve a custom storefront UI from Kentro's buyer accounts, catalog, cart, checkout, orders and invoices | Store API | https://apis.kentro.live/store/v1 | https://apis.kentro.dev/store/v1 |
| Collect website and server events with consent | Kentro Pixel | Collector https://pixel.kentro.live, management https://apis.kentro.live/pixel/v1 | https://pixel.kentro.dev, https://apis.kentro.dev/pixel/v1 |
| Let the user's AI client work with their own workspace data | Kentro MCP | https://apis.kentro.live/kiq/v1/copilot/mcp | https://apis.kentro.dev/kiq/v1/copilot/mcp |
- Use only the APIs in this table, at the hosts it lists, and only the endpoints their references document. Do not call, generate code for, or recommend any other Kentro URL. When existing code calls a Kentro URL that is not in this reference, stop and ask the user before changing it.
- Authenticate as Channel API authentication and Store API authentication describe.
- There is no Kentro SDK package, CLI or agent plugin. Call the HTTPS APIs with the language's standard HTTP client. Do not invent packages such as
@kentro/sdkor commands such askentro login. The only script Kentro serves is the Kentro Pixel browser SDK, loaded with a script tag. - Look up every endpoint, field and enum in the API Reference before you use it: the
.mdpages listed inhttps://docs.kentro.io/llms.txt. Never guess field names. The Channel API refuses unknown fields with400 validation_failed, and most Store API operations refuse them with400 VALIDATION. - Kentro MCP serves the user's AI client, not integrations. Never build an integration on Kentro MCP and never ask the user for a Kentro MCP token.
2. Credentials and scopes
- A Kentro admin creates API keys in Kentro OS under
Users>API keys:https://kentro.ccfor the sandbox,https://kentro.appfor production. Ask the user for a key. Never ask for their Kentro password, and never ask them to paste a secret into the chat: ask them to put it in environment variables. - Ask for the least privilege the job needs:
channel:readfor read-only work; the per-resource write scopes (customers:write,products:write,orders:write,fulfillment:write,shipments:write,invoices:write,payments:write,purchase-orders:write) for one job;channel:writeonly for a full channel integration;storefront:servefor a storefront server. Never requestadminfor an integration. - Ask the user to bind a Channel API key to the sales channels the integration serves.
- Never derive, send or accept a tenant id. The key's tenant is the tenant of every call, and nothing in a request selects a tenant.
- Keep secrets in environment variables or a secrets store. Never commit them, log them, put them in a URL or ship them in client-side code.
- Channel API requests send
kentro-keyandkentro-secret, orAuthorization: Bearer <accessToken>fromPOST https://apis.kentro.live/auth/login/api-key(15-minute token; the refresh token rotates atPOST /auth/refresh). Store API requests sendX-API-KeyandX-Storefront-Host, plusX-Storefront-BuyerorX-Storefront-Guestfor the buyer; the Store API does not readAuthorization. - Build and test against the sandbox with a sandbox key. A production key does not work in the sandbox. Switch to production only when the user asks.
3. Channel API writes
- Send an
Idempotency-Keyheader on everyPOST,PUT,PATCHandDELETE: 7 to 50 characters, derived from the source system's identity for the change (shop-1001-create, a webhook delivery id), identical on every retry of that change. A new key means a new change. - Send
externalId, the source system's id, on every create, and address documents asext:<channelId>:<externalId>. - Keep
onDuplicate: update(the default) so a replayed feed updates instead of duplicating. Useskipto never overwrite, anderrorwhen a duplicate must surface, such as a retailer purchase order received twice. - Send
versionon aPATCHwhen overwriting a concurrent change would be wrong, and handle409 version_conflictby reading the document again. - Order lines name the sellable variant (
sku,barcode,externalIdorid), never the parent product group. - Validate a write without storing anything with
X-Dry-Run: true. Load history withX-Import-Mode: historical, which skips confirmation emails, packing slips, accounting exports and EDI documents. Send large batches toPOST /v1/orders/importorPOST /v1/products/importand pollGET /v1/operations/:id.
4. Store API calls
- Every operation is
POST /<family>.<operation>with a JSON body,{}when it takes no fields. - Call the Store API only from the storefront's server: server components, route handlers, server actions, API routes or a backend. Never call it from browser code; it answers with no CORS headers for tenant origins.
- Never place
X-API-Key, buyer tokens or guest tokens in a browser bundle, aNEXT_PUBLIC_variable, local storage, a readable cookie or a URL. Keep them on the server, keyed by your ownhttpOnlysession cookie. - Set
X-Storefront-Hostfrom configuration (the published storefront's host: lower case, no scheme, no path), or from an allowlist that maps your own domains to storefront hosts. Never take it from user input. - Send
X-Storefront-Client-Ipwith the buyer's IP address andX-Expected-Buyerwith the buyer id your session maps to. - Send
expectedRevisionandownershipVersionfrom the last cart answer on every cart mutation. On409 CONFLICT, readcart.getagain and let the buyer act; never retry with a bumped revision. - Send
idempotencyKeyin the body ofcheckout.start,cart.addMany, cart claims, invoice payments, saved payment methods, subscriptions and applications: 7 to 50 characters fromA-Z a-z 0-9 _ -. - Check out in this order:
cart.get { "quote": true }, thencheckout.startwithquoteFingerprint,expectedRevisionandidempotencyKey, then followstatewithcheckout.statusandcheckout.confirm. Never start a second checkout while one is pending. Recover a lost answer withcheckout.status { idempotencyKey, quoteFingerprint }. - Do not cache Store API answers across requests; every answer is
Cache-Control: no-store.
5. Money, dates and ids
- Channel API money is a decimal string in currency units with a currency:
"unitPrice": "12.50","currency": "USD". Never send cents, and do arithmetic with decimal types, not floats. Totals must add up, or the write is422 totals_mismatch. - Store API money is an integer in the currency's minor unit:
1250is 12.50 USD. Format amounts for display on your side with the store'scurrency. - Kentro Pixel money is an integer in minor units; floating-point money is rejected.
- Timestamps are ISO-8601 in UTC. Date-only fields take
YYYY-MM-DD.
6. Reading and syncing
- Channel API lists are cursor based:
limit1 to 200 (default 50), follownextCursoruntil it isnull, no totals, newest first. - Sync incrementally with
updatedSinceset to the latestupdatedAtalready processed, and walk every page before you advance the watermark. - Store API lists are page based:
page,hasNextPage,totalandtotalIsCapped.
7. Errors and retries
- Channel API errors are
{ "error": { "code", "message", "details", "requestId" } }. For400 validation_failed, fix the field named indetails[].path. For403 forbidden, report the missing scope the message names. For404 not_foundand422 unresolved_reference, create or fix the referenced document. For409 duplicate,state_conflictandversion_conflict, read the document again and decide.422 idempotency_key_reusedmeans a bug in your keys: one key was sent with two different bodies. - Failures at Kentro's gateway use another shape:
{ "error": "INVALID_CREDENTIALS", "message": "..." },TOKEN_EXPIRED(refresh the bearer token) orTENANT_INACTIVE. - Store API errors are
{ "code", "message", "fieldErrors" }. Themessageis written for the buyer and can be shown as is. A declined payment is not an error:checkout.*answers200withstate: "declined". - Retry only
429,409 in_progress,500,503and network failures, with exponential backoff and jitter, at most five attempts, and never sooner thanRetry-Afterwhen it is present. Retry Channel API writes with the sameIdempotency-Key. A Store API write that answered503was not applied unless a later read shows it. - The Channel API allows 1,200 writes and 6,000 reads per minute per tenant by default. Watch
X-RateLimit-Remainingand slow down before429. - Log
requestId(or theX-Request-Idheader) with every failure. Kentro support is [email protected].
8. Before you report done
- Run the integration against the sandbox and show the user each request and response, with secrets redacted.
- Prove idempotency: send one Channel API write twice with the same
Idempotency-Keyand confirm the second answer carriesIdempotent-Replayed: true. - Prove that no key or token reaches client-side code: search the built client assets for the key value and for
X-API-Key. - List what you did not build or could not test.
Related
Updated about 12 hours ago
Did this page help you?

