Skip to content
MotherStock
All guides

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

  1. An Admin opens Settings › API keys, presses New key, names it after the system that will use it, and picks a role (below).
  2. Copy the key. It starts with ms_live_ and is shown once.
  3. 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.

RoleForScopes
Read onlyAI assistant questions, dashboardscatalog:read, inventory:read, orders:read, returns:read
Inventory syncSpreadsheet or tester syncRead only + inventory:write
Order notesHelpdesk or AI writing order notesRead only + orders:write
BookkeepingAccounting exports, profit questionsRead only + costs:read, profit:read
Full accessThe company's own systemsEvery scope
ScopeLets the key
catalog:readRead products, brands and types
inventory:readRead stock and units (serials)
orders:readRead orders, without buyer details
returns:readRead returns
orders:read_buyerRead buyer name and ship-to address on orders
costs:readRead unit and product cost
profit:readRead profit reports
inventory:writeAdd units, change bin and condition, mark sold
inventory:deleteDelete units
costs:writeSet unit cost
orders:writeAdd 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. Pass nextCursor back as cursor for the next page; it's null on the last one.
  • limit is 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 newest updatedAt you saw and match rows on id: 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-Key header 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, with Idempotent-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.

StatusWhen
401No key, or the key is wrong, revoked or expired. Also when the company is closed.
402The company's subscription needs attention on Billing in the app.
403The key doesn't have a scope the call needs. The message names it.
404The row isn't there, or belongs to another company. Also every call while the API is off for your company.
409A write with this Idempotency-Key is still running. Retry in a moment.
422A parameter or body field is wrong, or the change breaks a rule the app enforces. The message says which.
429Too 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

ParameterInTypeAbout
limitqueryintegerRows per page, 1 to 200. Default 50
cursorquerystring or nullnextCursor from the previous page. Up to 200 characters
updated_sincequerystring (date-time) or nullOnly 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.
skuquerystring or nullExact SKU. Up to 100 characters
qquerystring or nullSKU 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

ParameterInTypeAbout
product_idrequiredpathstring

Answer 200: Product

GET/brands

List Brands

Scopes: catalog:read

Answer 200: Brand[]

GET/types

List Types

Scopes: catalog:read

Answer 200: ProductType[]

GET/stock

List Stock

Units on hand per product: in stock and not reserved by an open order.

Scopes: inventory:read

ParameterInTypeAbout
limitqueryintegerRows per page, 1 to 200. Default 50
cursorquerystring or nullnextCursor from the previous page. Up to 200 characters
skuquerystring or nullExact 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

ParameterInTypeAbout
limitqueryintegerRows per page, 1 to 200. Default 50
cursorquerystring or nullnextCursor from the previous page. Up to 200 characters
updated_sincequerystring (date-time) or nullOnly 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.
productIdquerystring or nullUp to 50 characters
serialquerystring or nullExact serial or IMEI. Up to 100 characters
statusquerystringOne of: in_stock, sold, deleted, all. Default "all"

Answer 200: Page of Unit

GET/units/{unit_id}

Get Unit

Scopes: inventory:read

ParameterInTypeAbout
unit_idrequiredpathinteger

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

ParameterInTypeAbout
unit_idrequiredpathinteger

Answer 200: UnitHistory

Orders

Orders from your connected stores and their returns.

GET/orders

List Orders

Scopes: orders:read

ParameterInTypeAbout
limitqueryintegerRows per page, 1 to 200. Default 50
cursorquerystring or nullnextCursor from the previous page. Up to 200 characters
updated_sincequerystring (date-time) or nullOnly 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.
statusquerystring or nullExact status, e.g. pending or completed. Up to 50 characters
orderNoquerystring or nullUp 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

ParameterInTypeAbout
daysqueryintegerOrders placed in the last this many days. Default 7
statusquerystring or nullExact status, e.g. pending or completed. Up to 50 characters
limitqueryintegerDefault 25. 1 to 100

Answer 200: Order[]

GET/orders/{order_id}

Get Order

Scopes: orders:read

ParameterInTypeAbout
order_idrequiredpathstring

Answer 200: Order

GET/returns

List Returns

Scopes: returns:read

ParameterInTypeAbout
limitqueryintegerRows per page, 1 to 200. Default 50
cursorquerystring or nullnextCursor from the previous page. Up to 200 characters
updated_sincequerystring (date-time) or nullOnly 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

ParameterInTypeAbout
return_idrequiredpathstring

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

ParameterInTypeAbout
unit_idrequiredpathinteger

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

ParameterInTypeAbout
unit_idrequiredpathinteger

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

ParameterInTypeAbout
unit_idrequiredpathinteger

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

ParameterInTypeAbout
unit_idrequiredpathinteger

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

ParameterInTypeAbout
order_idrequiredpathstring

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

ParameterInTypeAbout
intervalquerystringDate range by order date, as on the screens. One of: 7days, 14days, 30days, mtd, ytd, all. Default "30days"
rowsqueryintegerRows 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

ParameterInTypeAbout
intervalquerystringDate range by order date, as on the screens. One of: 7days, 14days, 30days, mtd, ytd, all. Default "30days"
rowsqueryintegerRows 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

ParameterInTypeAbout
unit_idrequiredpathinteger

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

FieldTypeAbout
productIdstringUp to 50 characters
unitsNewUnit[]Up to 500 items

AddUnitsResult

FieldTypeAbout
dataUnit[]

Brand

FieldTypeAbout
idinteger
namestring

BuyList

FieldTypeAbout
groupsBuyListGroup[]
coverLookbackDaysinteger

BuyListGroup

FieldTypeAbout
supplierstring
totalCostoptionalstring or null
itemsBuyListItem[]

BuyListItem

FieldTypeAbout
productIdstring
skustring
namestring
availableinteger
lowStockAtinteger
soldRecentinteger
daysOfCoveroptionalnumber or null
suggestedQtyinteger
alsoFromoptionalstring[]
unitCostoptionalstring or null
totalCostoptionalstring or null
amazonoptionalobject or nullAmazon price check when connected. Never sent to AI assistants.

Buyer

FieldTypeAbout
nameoptionalstring or null
address1optionalstring or null
address2optionalstring or null
address3optionalstring or null
cityoptionalstring or null
stateoptionalstring or null
zipoptionalstring or null
countryoptionalstring or null

LowStock

FieldTypeAbout
dataLowStockRow[]
coverLookbackDaysinteger

LowStockRow

FieldTypeAbout
productIdstring
skustring
namestring
availableintegerUnits in stock and not reserved by an open order.
lowStockAtintegerFlagged low at this many available units or fewer.
soldRecentintegerUnits sold in the last coverLookbackDays days.
daysOfCoveroptionalnumber or nullDays the available units last at the recent rate of sale; null when none sold.

MarkSold

FieldTypeAbout
orderNooptionalstring or nullWhere it sold, e.g. a marketplace order number. Up to 100 characters
soldAtoptionalstring (date-time) or nullWhen it sold, with a time zone. Defaults to now.

NewOrderNote

FieldTypeAbout
notestringUp to 2000 characters
lineIdoptionalstring or nullThe order line; needed when the order has more than one. Up to 50 characters

NewUnit

FieldTypeAbout
serialstringUp to 100 characters
binoptionalstring or nullUp to 50 characters
conditionoptionalstring or nullA Condition option's name, e.g. "A Stock". Up to 100 characters
costoptionalnumber or string or nullNeeds the costs:write scope.

Order

FieldTypeAbout
idstring
orderNooptionalstring or null
statusstring
marketplaceoptionalstring or null
storeIdoptionalstring or null
orderedAtoptionalstring (date-time) or null
shipByoptionalstring (date) or null
deliverByoptionalstring (date) or null
completedAtoptionalstring (date-time) or null
cancelledAtoptionalstring (date-time) or null
totaloptionalstring or null
currencyoptionalstring or null
trackingNumberoptionalstring or null
carrieroptionalstring or null
deliveredAtoptionalstring (date-time) or null
updatedAtstring (date-time)
buyeroptionalBuyer or nullOnly with the orders:read_buyer scope.
linesoptionalOrderLine[] or nullOn GET /orders/{id} only.
packagesoptionalPackage[] or nullOn GET /orders/{id} only.

OrderLine

FieldTypeAbout
idstring
skuoptionalstring or null
nameoptionalstring or null
qtyinteger
unitPriceoptionalstring or null
serialsoptionalstring[]Serials packed on this line.
packedboolean
cancelledboolean
returnedboolean

OrderNote

FieldTypeAbout
idstring
orderIdstring
lineIdstring
notestring
authorstring
createdAtstring (date-time)

Package

FieldTypeAbout
trackingNumberstring
carrieroptionalstring or null
statusoptionalstring or null
deliveredAtoptionalstring (date-time) or null

Page of Order

FieldTypeAbout
dataOrder[]
nextCursoroptionalstring or nullPass as cursor for the next page; null on the last page.

Page of Product

FieldTypeAbout
dataProduct[]
nextCursoroptionalstring or nullPass as cursor for the next page; null on the last page.

Page of Return

FieldTypeAbout
dataReturn[]
nextCursoroptionalstring or nullPass as cursor for the next page; null on the last page.

Page of StockRow

FieldTypeAbout
dataStockRow[]
nextCursoroptionalstring or nullPass as cursor for the next page; null on the last page.

Page of Unit

FieldTypeAbout
dataUnit[]
nextCursoroptionalstring or nullPass as cursor for the next page; null on the last page.

PnlLine

FieldTypeAbout
keystring
labelstring
amountoptionalnumber or null
sourcestringactual, estimate or missing.
noteoptionalstring or null

Product

FieldTypeAbout
idstring
skustring
namestring
brandoptionalstring or null
typeoptionalstring or null
modeloptionalstring or null
modelNooptionalstring or null
statusstring
lowStockAtoptionalinteger or nullFlagged low at this many available units or fewer.
onHandintegerUnits in stock and not reserved by an open order.
costoptionalstring or nullDefault cost. Only with the costs:read scope.
updatedAtstring (date-time)

ProductType

FieldTypeAbout
idinteger
namestring

Report

FieldTypeAbout
titlestring
startstring (date)
endstring (date)
cardsReportCard[]
sectionsReportSection[]
notesoptionalstring[]

ReportCard

FieldTypeAbout
labelstring
valueoptionalnumber or integer or string or null
kindstring

ReportColumn

FieldTypeAbout
keystring
labelstring
kindstring

ReportSection

FieldTypeAbout
idstring
titlestring
columnsReportColumn[]
rowsobject of number or integer or string or null[]One object per row, keyed by column key.
totalRowsintegerRows before the per-section limit.
noteoptionalstring or null
takeawayoptionalstring or null

Return

FieldTypeAbout
idstringThe order line's id.
orderIdstring
orderNooptionalstring or null
skuoptionalstring or null
nameoptionalstring or null
shippedSerialsoptionalstring[]
returnedSerialoptionalstring or null
conditionoptionalstring or null
returnedboolean
returnedAtoptionalstring (date-time) or null
refundedAtoptionalstring (date-time) or null
statusCodeoptionalinteger or nullThe return status code shown on the Returns page.
updatedAtstring (date-time)

StockRow

FieldTypeAbout
productIdstring
skustring
namestring
onHandinteger
updatedAtstring (date-time)

Unit

FieldTypeAbout
idinteger
productIdstring
serialstring
binoptionalstring or null
conditionoptionalstring or null
statusstringin_stock, sold or deleted.
addedAtoptionalstring (date-time) or null
updatedAtstring (date-time)
costoptionalstring or nullUnit cost. Only with the costs:read scope.

UnitChange

FieldTypeAbout
binoptionalstring or nullEmpty string clears the bin. Up to 50 characters
conditionoptionalstring or nullA Condition option's name; empty clears it. Up to 100 characters
costoptionalnumber or string or nullNeeds the costs:write scope.

UnitEvent

FieldTypeAbout
actionstringWhat happened, e.g. imported, sold, returned, restocked, unit_updated.
labelstring
atoptionalstring (date-time) or null
orderIdoptionalstring or null
detailoptionalstring or nullShort note, e.g. the invoice or order number.
changedoptionalstring[] or nullFields changed (unit_updated only). Cost only with costs:read.

UnitHistory

FieldTypeAbout
unitUnit
eventsUnitEvent[]Newest first.

UnitPnl

FieldTypeAbout
unitIdinteger
serialstring
salesUnitSale[]Every sale of this unit, newest first.

UnitSale

FieldTypeAbout
orderNooptionalstring or null
orderIdstring
marketplaceoptionalstring or null
soldOnoptionalstring (date) or null
linesPnlLine[]
grossProfitnumber
netProfitoptionalnumber or nullNull when a line is left out for AI assistants.
completeboolean
finalboolean
notesoptionalstring[]