Skip to content

API Overview

The Storelayer API is JSON over HTTPS at https://api.storelayer.io. Almost every route is project-scoped (/projects/{projectId}/…) and authenticated with a project API key. The API reference is generated from the live OpenAPI document and owns the full endpoint contracts; this page covers the conventions they share.

TopicConvention
Base URLhttps://api.storelayer.io
AuthAuthorization: Bearer <api key> — see authentication
BodiesJSON with Content-Type: application/json; field names are camelCase
Success{ "success": true, "data": … }
Errors{ "success": false, "error": { "code": <number>, "message": "…" } }
IDsYour customer IDs are yours (userId); Storelayer-generated IDs are prefixed strings such as prj_…, evt_…
TimestampsISO 8601 UTC strings, e.g. 2026-10-11T13:26:04.619Z; send the same format for fields like expiresAt
Money in cartsInteger minor units: $25.00 → 2500. Promotion cart prices are rejected if not integers
Wallet amountsAsset units (points, stamps), not money

Use integer minor units for money everywhere, including your own event payloads and catalog prices — only cart fields enforce it, so mixed units in events and rules fail silently.

Error codes are numeric and stable; check error.code, not the message.

StatusCodeMeaning
4001001Bad request (e.g. missing project ID)
4011002Missing, invalid, or expired credential
4031003Credential cannot access this project
4031004API key missing a required scope
4041000Route or resource not found
4091004Resource already exists (generic conflict)
400 / 5001005Operation failed; message carries the reason (400) or Internal server error (500)

Domains add their own codes in the same envelope — for example 2500 user already exists, 2502 user not found, 2600 invalid wallet input, 2601 insufficient balance.

Request validation failures have a different shape. When a body, query, or path parameter fails schema validation, the response is 400 with error as an array of issues and the rejected input echoed back:

{
"success": false,
"error": [
{ "code": "too_small", "path": ["firstName"], "message": "Too small: expected string to have >=1 characters" }
],
"data": { "userId": "cus_1001", "firstName": "" }
}

Handle both: Array.isArray(body.error) means validation issues; otherwise read body.error.code. Promotion cart evaluation can also return error.code as the string "VALIDATION_ERROR", so don’t assume codes are always numbers.

Two styles exist; check the endpoint in the reference.

StyleQuery paramsDefaultsUsed by (examples)
Offsetlimit, offsetlimit=50, max 100, offset=0Customers, wallet transactions/assets, promotions list, referrals, catalog
Pagepage (from 1), pageSizepageSize max 100Promotion coupons and usage

List responses commonly return { "items": [...], "total": <number> } inside data. Page until you have total items.

POST /ingest/events returns 201 with { "id": "evt_…", "status": "accepted" } before rules run. Effects (wallet credits, referral completion, integrations) happen afterwards; inspect them through Workflows. Synchronous endpoints (wallet earn/spend/modify, promotion evaluation) return their result directly.

TagUse it for
Projects, Project ConfigProject metadata; currency, timezone, settings
API KeysCreate, list, rename, revoke project keys
TeamProject members, roles, invitations
External UsersRegister and manage customers by your userId
WalletBalances, earn, spend, modify, assets, transactions
EventsPOST /ingest/events
RulesRule CRUD, testing conditions, evaluating, cloning to another project
Resources, Resources v2Data sources rules and promotions can read (/resources is current)
WorkflowsRuns produced by events — what matched, what executed
Promotions, Promotions - Coupons, Promotions - Usage, Promotions - StatsDiscount definitions, coupon codes, redemptions, reporting, cart evaluation
ReferralsReferral config, codes, attribution, leaderboard
IntegrationsOutbound HTTP/Slack/Telegram/etc. connections used by rule actions
StorageProject custom tables
Catalog, StoresProducts/categories; stores and facilities
Internal ToolsThe tool catalog used by agents and the MCP server
Support, SurveysTickets and surveys, including public submission routes

To read one contract without loading the whole spec:

Terminal window
curl -s https://api.storelayer.io/openapi.json | jq '.paths["/projects/{projectId}/promotions/evaluate"].post'
  • If a guide and the reference disagree on a request shape, trust the reference and report the discrepancy.
  • Retries: wallet earn/spend are not idempotent. After a timeout, check transactions before retrying.