API reference
Read and update your MotherStock products, stock, units, orders and returns from your own systems. Every call uses an API key, sees only your company's data, and only what the key's scopes allow.
Switched on per company. Email [email protected] to switch the API on for yours, then an Admin makes a key as below.
Quick start
- An Admin opens Settings › API keys, presses New key, names it after the system that will use it, and picks a role (below).
- Copy the key. It starts with
ms_live_and is shown once. - Call the API with the key as a bearer token:
curl https://api.motherstock.app/v1/me \ -H "Authorization: Bearer ms_live_…"
GET /me answers with the key's name, company and scopes, so it's the quickest way to check a new key.
Prefer to click? The live API explorer lists every call below. Press Authorize, paste your key, and try any call from your browser. It runs against your live data, so a write or delete there is real.
API keys
- Base URL:
https://api.motherstock.app/v1 - A key belongs to your company, not to the person who made it, so it keeps working when people come and go. The page records who made it.
- Keys don't expire unless whoever makes one sets an end date. Revoke one any time on the same page.
- Nobody can give a key more than their own role has. Writes, deletes, cost, profit and buyer details also need an Admin.
- Use one key per system, so you can see each one's calls and revoke one without touching the others.
- AI assistants use the same API through the MotherStock MCP server; see Connect an AI assistant.
Scopes and roles
Each endpoint below lists the scopes it needs. A key's role is a named set of scopes; Custom lets an Admin tick them one by one.
| Role | For | Scopes |
|---|---|---|
| Read only | AI assistant questions, dashboards | catalog:read, inventory:read, orders:read, returns:read |
| Inventory sync | Spreadsheet or tester sync | Read only + inventory:write |
| Order notes | Helpdesk or AI writing order notes | Read only + orders:write |
| Bookkeeping | Accounting exports, profit questions | Read only + costs:read, profit:read |
| Full access | The company's own systems | Every scope |
| Scope | Lets the key |
|---|---|
catalog:read | Read products, brands and types |
inventory:read | Read stock and units (serials) |
orders:read | Read orders, without buyer details |
returns:read | Read returns |
orders:read_buyer | Read buyer name and ship-to address on orders |
costs:read | Read unit and product cost |
profit:read | Read profit reports |
inventory:write | Add units, change bin and condition, mark sold |
inventory:delete | Delete units |
costs:write | Set unit cost |
orders:write | Add order notes |
Without costs:read, cost fields are left out of every answer. Without orders:read_buyer, orders come without the buyer's name and address.
Lists and paging
- Lists answer
{ "data": [...], "nextCursor": "..." }, oldest change first. PassnextCursorback ascursorfor the next page; it'snullon the last one. limitis 1 to 200 rows a page, 50 if you leave it out.- To keep a copy in sync, poll with
updated_since(ISO 8601 with a time zone). Start each poll 5 minutes before the newestupdatedAtyou saw and match rows onid: a change made in a longer step can show up a little late, and a repeated row is the same row again. - Field names are camelCase. Times are ISO 8601. Money is a decimal string, such as "129.50".
Writes
- Send an
Idempotency-Keyheader on a POST (1 to 100 letters, digits, dots, dashes, underscores or colons). A retry with the same key and body gets the first answer back for 24 hours, withIdempotent-Replayed: true; the same key with a different body is 422. Only a successful answer is kept, so a failed call can simply be retried. - Adding units is all or none: one bad row refuses the call and lists every problem. Up to 500 units a call.
- Writes follow the app's own rules: a phone serial must be 15 digits, a serial can't be added twice, and a sold unit's cost never changes.
- Every change shows in the unit's history and the audit log as "API key: name".
- Deleting a unit can't be undone through the API.
Errors
Errors answer { "detail": "..." } with a message you can show a person.
| Status | When |
|---|---|
| 401 | No key, or the key is wrong, revoked or expired. Also when the company is closed. |
| 402 | The company's subscription needs attention on Billing in the app. |
| 403 | The key doesn't have a scope the call needs. The message names it. |
| 404 | The row isn't there, or belongs to another company. Also every call while the API is off for your company. |
| 409 | A write with this Idempotency-Key is still running. Retry in a moment. |
| 422 | A parameter or body field is wrong, or the change breaks a rule the app enforces. The message says which. |
| 429 | Too many bad keys from your address: wait for the Retry-After header. AI assistants also get it above 60 calls a minute. |
The OpenAPI file behind this page: openapi.json. Load it into Postman, Insomnia or a code generator, or try calls in the live API explorer.
Endpoints
Key
Check the key you're calling with.
GET/me
Key Me
Scopes: any live key
Answer 200: object
GET/token
Token Check
Is this token live? The MCP server asks before serving an AI app connection, so an expired one gets HTTP 401 and the app refreshes it (AI assistant plan PR 13). Not counted as a call.
Scopes: any live key
Answer 200: object
Catalog
Products, brands, types and stock counts.
GET/products
List Products
Scopes: catalog:read
| Parameter | In | Type | About |
|---|---|---|---|
limit | query | integer | Rows per page, 1 to 200. Default 50 |
cursor | query | string or null | nextCursor from the previous page. Up to 200 characters |
updated_since | query | string (date-time) or null | Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late. |
sku | query | string or null | Exact SKU. Up to 100 characters |
q | query | string or null | SKU or name contains this text (any case). Up to 100 characters |
Answer 200: Page of Product
GET/products/{product_id}
Get Product
Scopes: catalog:read
| Parameter | In | Type | About |
|---|---|---|---|
product_idrequired | path | string |
Answer 200: Product
GET/stock
List Stock
Units on hand per product: in stock and not reserved by an open order.
Scopes: inventory:read
| Parameter | In | Type | About |
|---|---|---|---|
limit | query | integer | Rows per page, 1 to 200. Default 50 |
cursor | query | string or null | nextCursor from the previous page. Up to 200 characters |
sku | query | string or null | Exact SKU. Up to 100 characters |
Answer 200: Page of StockRow
GET/stock/low
List Low Stock
Products down to their low-stock level, fewest first, with days of cover (as on Reports > Low stock). Nobody's "dismiss" applies here: a key belongs to the company, not a person.
Scopes: inventory:read
Answer 200: LowStock
Units
Each unit (serial) you hold or held, and what happened to it.
GET/units
List Units
Scopes: inventory:read
| Parameter | In | Type | About |
|---|---|---|---|
limit | query | integer | Rows per page, 1 to 200. Default 50 |
cursor | query | string or null | nextCursor from the previous page. Up to 200 characters |
updated_since | query | string (date-time) or null | Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late. |
productId | query | string or null | Up to 50 characters |
serial | query | string or null | Exact serial or IMEI. Up to 100 characters |
status | query | string | One of: in_stock, sold, deleted, all. Default "all" |
Answer 200: Page of Unit
GET/units/{unit_id}
Get Unit
Scopes: inventory:read
| Parameter | In | Type | About |
|---|---|---|---|
unit_idrequired | path | integer |
Answer 200: Unit
GET/units/{unit_id}/history
Get Unit History
The unit and what happened to it, newest first. No people's names or emails; changed fields only (never the old or new values), and cost changes only with costs:read.
Scopes: inventory:read
| Parameter | In | Type | About |
|---|---|---|---|
unit_idrequired | path | integer |
Answer 200: UnitHistory
Orders
Orders from your connected stores and their returns.
GET/orders
List Orders
Scopes: orders:read
| Parameter | In | Type | About |
|---|---|---|---|
limit | query | integer | Rows per page, 1 to 200. Default 50 |
cursor | query | string or null | nextCursor from the previous page. Up to 200 characters |
updated_since | query | string (date-time) or null | Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late. |
status | query | string or null | Exact status, e.g. pending or completed. Up to 50 characters |
orderNo | query | string or null | Up to 100 characters |
Answer 200: Page of Order
GET/orders/recent
List Recent Orders
Newest orders first by order date, for questions like "what sold this week". For syncing, page through GET /orders with updated_since instead.
Scopes: orders:read
| Parameter | In | Type | About |
|---|---|---|---|
days | query | integer | Orders placed in the last this many days. Default 7 |
status | query | string or null | Exact status, e.g. pending or completed. Up to 50 characters |
limit | query | integer | Default 25. 1 to 100 |
Answer 200: Order[]
GET/orders/{order_id}
Get Order
Scopes: orders:read
| Parameter | In | Type | About |
|---|---|---|---|
order_idrequired | path | string |
Answer 200: Order
GET/returns
List Returns
Scopes: returns:read
| Parameter | In | Type | About |
|---|---|---|---|
limit | query | integer | Rows per page, 1 to 200. Default 50 |
cursor | query | string or null | nextCursor from the previous page. Up to 200 characters |
updated_since | query | string (date-time) or null | Only rows changed after this time (ISO 8601 with a time zone). When polling, start 5 minutes before the newest updatedAt you saw and match rows on id: a change made in a longer database step can show up a little late. |
Answer 200: Page of Return
GET/returns/{return_id}
Get Return
Scopes: returns:read
| Parameter | In | Type | About |
|---|---|---|---|
return_idrequired | path | string |
Answer 200: Return
Writes
Add and change units, and add order notes. POSTs take an Idempotency-Key.
POST/units
Add Units
Add serials to one product, all or none: any bad row refuses the call and lists every problem.
Scopes: inventory:write
Body: AddUnits
Answer 201: AddUnitsResult
PATCH/units/{unit_id}
Change Unit
Change bin, condition and (with costs:write) cost. Fields left out stay as they are.
Scopes: inventory:write
| Parameter | In | Type | About |
|---|---|---|---|
unit_idrequired | path | integer |
Body: UnitChange
Answer 200: Unit
DELETE/units/{unit_id}
Delete Unit
The app's soft delete. Sold units stay on their order. The API can't undo a delete.
Scopes: inventory:delete
| Parameter | In | Type | About |
|---|---|---|---|
unit_idrequired | path | integer |
Answer 200: Unit
POST/units/{unit_id}/sold
Mark Sold
A unit sold outside the app (e.g. a store the app doesn't pull orders from). A unit on an order in the app is sold when that order is packed, so it is refused here.
Scopes: inventory:write
| Parameter | In | Type | About |
|---|---|---|---|
unit_idrequired | path | integer |
Body: MarkSold or null
Answer 200: Unit
POST/units/{unit_id}/in-stock
Mark In Stock
Undo sold. A unit sold on an order in the app comes back through a return instead.
Scopes: inventory:write
| Parameter | In | Type | About |
|---|---|---|---|
unit_idrequired | path | integer |
Answer 200: Unit
POST/orders/{order_id}/notes
Add Order Note
A note on an order line, shown in the app as written by "API key: name".
Scopes: orders:write
| Parameter | In | Type | About |
|---|---|---|---|
order_idrequired | path | string |
Body: NewOrderNote
Answer 201: OrderNote
Reports
The profit reports from the app. Need the profit:read scope.
GET/reports/sales
Sales Report
Sales & Gross Profit and its breakdowns (Reports > Profit breakdown) for the range.
Scopes: profit:read
| Parameter | In | Type | About |
|---|---|---|---|
interval | query | string | Date range by order date, as on the screens. One of: 7days, 14days, 30days, mtd, ytd, all. Default "30days" |
rows | query | integer | Rows per section at most. Default 50 |
Answer 200: Report
GET/reports/money-losers
Money Losers
Units sold at a loss, by supplier, model and marketplace, worst first (Reports > Money losers).
Scopes: profit:read
| Parameter | In | Type | About |
|---|---|---|---|
interval | query | string | Date range by order date, as on the screens. One of: 7days, 14days, 30days, mtd, ytd, all. Default "30days" |
rows | query | integer | Rows per section at most. Default 50 |
Answer 200: Report
GET/units/{unit_id}/pnl
Unit Pnl
The unit's Unit P&L for every sale, newest first, as on the unit page.
Scopes: profit:read
| Parameter | In | Type | About |
|---|---|---|---|
unit_idrequired | path | integer |
Answer 200: UnitPnl
GET/reports/buy-list
Buy List
What to reorder, grouped by the supplier each product last came from, with costs (Reports > Buy list).
Scopes: profit:read
Answer 200: BuyList
Shapes
Every body and answer above, field by field. Field names are camelCase.
AddUnits
| Field | Type | About |
|---|---|---|
productId | string | Up to 50 characters |
units | NewUnit[] | Up to 500 items |
AddUnitsResult
| Field | Type | About |
|---|---|---|
data | Unit[] |
Brand
| Field | Type | About |
|---|---|---|
id | integer | |
name | string |
BuyList
| Field | Type | About |
|---|---|---|
groups | BuyListGroup[] | |
coverLookbackDays | integer |
BuyListGroup
| Field | Type | About |
|---|---|---|
supplier | string | |
totalCostoptional | string or null | |
items | BuyListItem[] |
BuyListItem
| Field | Type | About |
|---|---|---|
productId | string | |
sku | string | |
name | string | |
available | integer | |
lowStockAt | integer | |
soldRecent | integer | |
daysOfCoveroptional | number or null | |
suggestedQty | integer | |
alsoFromoptional | string[] | |
unitCostoptional | string or null | |
totalCostoptional | string or null | |
amazonoptional | object or null | Amazon price check when connected. Never sent to AI assistants. |
Buyer
| Field | Type | About |
|---|---|---|
nameoptional | string or null | |
address1optional | string or null | |
address2optional | string or null | |
address3optional | string or null | |
cityoptional | string or null | |
stateoptional | string or null | |
zipoptional | string or null | |
countryoptional | string or null |
LowStock
| Field | Type | About |
|---|---|---|
data | LowStockRow[] | |
coverLookbackDays | integer |
LowStockRow
| Field | Type | About |
|---|---|---|
productId | string | |
sku | string | |
name | string | |
available | integer | Units in stock and not reserved by an open order. |
lowStockAt | integer | Flagged low at this many available units or fewer. |
soldRecent | integer | Units sold in the last coverLookbackDays days. |
daysOfCoveroptional | number or null | Days the available units last at the recent rate of sale; null when none sold. |
MarkSold
| Field | Type | About |
|---|---|---|
orderNooptional | string or null | Where it sold, e.g. a marketplace order number. Up to 100 characters |
soldAtoptional | string (date-time) or null | When it sold, with a time zone. Defaults to now. |
NewOrderNote
| Field | Type | About |
|---|---|---|
note | string | Up to 2000 characters |
lineIdoptional | string or null | The order line; needed when the order has more than one. Up to 50 characters |
NewUnit
| Field | Type | About |
|---|---|---|
serial | string | Up to 100 characters |
binoptional | string or null | Up to 50 characters |
conditionoptional | string or null | A Condition option's name, e.g. "A Stock". Up to 100 characters |
costoptional | number or string or null | Needs the costs:write scope. |
Order
| Field | Type | About |
|---|---|---|
id | string | |
orderNooptional | string or null | |
status | string | |
marketplaceoptional | string or null | |
storeIdoptional | string or null | |
orderedAtoptional | string (date-time) or null | |
shipByoptional | string (date) or null | |
deliverByoptional | string (date) or null | |
completedAtoptional | string (date-time) or null | |
cancelledAtoptional | string (date-time) or null | |
totaloptional | string or null | |
currencyoptional | string or null | |
trackingNumberoptional | string or null | |
carrieroptional | string or null | |
deliveredAtoptional | string (date-time) or null | |
updatedAt | string (date-time) | |
buyeroptional | Buyer or null | Only with the orders:read_buyer scope. |
linesoptional | OrderLine[] or null | On GET /orders/{id} only. |
packagesoptional | Package[] or null | On GET /orders/{id} only. |
OrderLine
| Field | Type | About |
|---|---|---|
id | string | |
skuoptional | string or null | |
nameoptional | string or null | |
qty | integer | |
unitPriceoptional | string or null | |
serialsoptional | string[] | Serials packed on this line. |
packed | boolean | |
cancelled | boolean | |
returned | boolean |
OrderNote
| Field | Type | About |
|---|---|---|
id | string | |
orderId | string | |
lineId | string | |
note | string | |
author | string | |
createdAt | string (date-time) |
Package
| Field | Type | About |
|---|---|---|
trackingNumber | string | |
carrieroptional | string or null | |
statusoptional | string or null | |
deliveredAtoptional | string (date-time) or null |
Page of Order
| Field | Type | About |
|---|---|---|
data | Order[] | |
nextCursoroptional | string or null | Pass as cursor for the next page; null on the last page. |
Page of Product
| Field | Type | About |
|---|---|---|
data | Product[] | |
nextCursoroptional | string or null | Pass as cursor for the next page; null on the last page. |
Page of Return
| Field | Type | About |
|---|---|---|
data | Return[] | |
nextCursoroptional | string or null | Pass as cursor for the next page; null on the last page. |
Page of StockRow
| Field | Type | About |
|---|---|---|
data | StockRow[] | |
nextCursoroptional | string or null | Pass as cursor for the next page; null on the last page. |
Page of Unit
| Field | Type | About |
|---|---|---|
data | Unit[] | |
nextCursoroptional | string or null | Pass as cursor for the next page; null on the last page. |
PnlLine
| Field | Type | About |
|---|---|---|
key | string | |
label | string | |
amountoptional | number or null | |
source | string | actual, estimate or missing. |
noteoptional | string or null |
Product
| Field | Type | About |
|---|---|---|
id | string | |
sku | string | |
name | string | |
brandoptional | string or null | |
typeoptional | string or null | |
modeloptional | string or null | |
modelNooptional | string or null | |
status | string | |
lowStockAtoptional | integer or null | Flagged low at this many available units or fewer. |
onHand | integer | Units in stock and not reserved by an open order. |
costoptional | string or null | Default cost. Only with the costs:read scope. |
updatedAt | string (date-time) |
ProductType
| Field | Type | About |
|---|---|---|
id | integer | |
name | string |
Report
| Field | Type | About |
|---|---|---|
title | string | |
start | string (date) | |
end | string (date) | |
cards | ReportCard[] | |
sections | ReportSection[] | |
notesoptional | string[] |
ReportCard
| Field | Type | About |
|---|---|---|
label | string | |
valueoptional | number or integer or string or null | |
kind | string |
ReportColumn
| Field | Type | About |
|---|---|---|
key | string | |
label | string | |
kind | string |
ReportSection
| Field | Type | About |
|---|---|---|
id | string | |
title | string | |
columns | ReportColumn[] | |
rows | object of number or integer or string or null[] | One object per row, keyed by column key. |
totalRows | integer | Rows before the per-section limit. |
noteoptional | string or null | |
takeawayoptional | string or null |
Return
| Field | Type | About |
|---|---|---|
id | string | The order line's id. |
orderId | string | |
orderNooptional | string or null | |
skuoptional | string or null | |
nameoptional | string or null | |
shippedSerialsoptional | string[] | |
returnedSerialoptional | string or null | |
conditionoptional | string or null | |
returned | boolean | |
returnedAtoptional | string (date-time) or null | |
refundedAtoptional | string (date-time) or null | |
statusCodeoptional | integer or null | The return status code shown on the Returns page. |
updatedAt | string (date-time) |
StockRow
| Field | Type | About |
|---|---|---|
productId | string | |
sku | string | |
name | string | |
onHand | integer | |
updatedAt | string (date-time) |
Unit
| Field | Type | About |
|---|---|---|
id | integer | |
productId | string | |
serial | string | |
binoptional | string or null | |
conditionoptional | string or null | |
status | string | in_stock, sold or deleted. |
addedAtoptional | string (date-time) or null | |
updatedAt | string (date-time) | |
costoptional | string or null | Unit cost. Only with the costs:read scope. |
UnitChange
| Field | Type | About |
|---|---|---|
binoptional | string or null | Empty string clears the bin. Up to 50 characters |
conditionoptional | string or null | A Condition option's name; empty clears it. Up to 100 characters |
costoptional | number or string or null | Needs the costs:write scope. |
UnitEvent
| Field | Type | About |
|---|---|---|
action | string | What happened, e.g. imported, sold, returned, restocked, unit_updated. |
label | string | |
atoptional | string (date-time) or null | |
orderIdoptional | string or null | |
detailoptional | string or null | Short note, e.g. the invoice or order number. |
changedoptional | string[] or null | Fields changed (unit_updated only). Cost only with costs:read. |
UnitHistory
| Field | Type | About |
|---|---|---|
unit | Unit | |
events | UnitEvent[] | Newest first. |
UnitPnl
| Field | Type | About |
|---|---|---|
unitId | integer | |
serial | string | |
sales | UnitSale[] | Every sale of this unit, newest first. |
UnitSale
| Field | Type | About |
|---|---|---|
orderNooptional | string or null | |
orderId | string | |
marketplaceoptional | string or null | |
soldOnoptional | string (date) or null | |
lines | PnlLine[] | |
grossProfit | number | |
netProfitoptional | number or null | Null when a line is left out for AI assistants. |
complete | boolean | |
final | boolean | |
notesoptional | string[] |