Inventory Inventory API
A simple and powerful API to programmatically access and manage your inventory data. This guide is designed to be understood by both human developers and AI agents. For example if you have an e-commerce website, you can directly load your products, and once sold, your API can update the quantity in your inventory.

Base URL

All API requests should be made to the following base URL:

https://us-central1-studio-9300027708-1f0ae.cloudfunctions.net/getInventory

Authentication

The API uses a Bearer Token for authentication. You must include your personal API key in the `Authorization` header for all requests. You can generate and manage your API key from your profile page.

Authorization: Bearer YOUR_API_KEY_HERE

Endpoints

GETFetch Inventory Items

Retrieves a list of all inventory items that have been explicitly marked for inclusion in the API. If the business has enabled custom item fields (SKU, cost price, reorder level, supplier, expiry date, or their own fields), each item includes them in an optional `fields` object.

Example Request

curl -X GET "https://us-central1-studio-9300027708-1f0ae.cloudfunctions.net/getInventory" \
     -H "Authorization: Bearer YOUR_API_KEY_HERE"

Success Response (200 OK)

Returns a JSON array of `InventoryItem` objects.

[
  {
    "id": "1N3RTWf049jLR8jyN4p5",
    "name": "potato",
    "description": "A root vegetable",
    "quantity": 2,
    "includeInApi": true,
    "createdAt": "2026-02-04T16:46:21.372Z",
    "updatedAt": "2026-02-05T16:04:34.537Z"
  },
  {
    "id": "X0qno0rSbD9CnrirCudG",
    "name": "carrot",
    "description": "A fresh carrot",
    "quantity": 6,
    "price": 90,
    "includeInApi": true,
    "fields": { "sku": "CAR-001", "costPrice": 45, "expiryDate": "2026-08-01" },
    "createdAt": "2026-02-04T16:46:21.522Z",
    "updatedAt": "2026-02-05T16:42:02.945Z"
  }
]

POSTUpdate Item Quantities

Updates the quantity of one or more items, typically after a sale. The request body must be a JSON object containing an `items` array. Each object in the array must have an `itemId` and the `quantity` to subtract.

Every update is also recorded in your Activity Log (attributed to “Developer API”), so API-driven stock movements show up alongside scans and edits — and can trigger any AI Alert rules you’ve set up (low stock, item watches, and so on).

For batch-tracked items (the optional `batches` array), quantity subtractions are applied FEFO — First Expired, First Out: the soonest-expiring batch is consumed first, the item's `fields.expiryDate` rolls forward to the next-soonest batch automatically, and the Activity Log records exactly which lots were consumed.

Request Body

{
  "items": [
    { "itemId": "ID_OF_ITEM_1", "quantity": 1 },
    { "itemId": "ID_OF_ITEM_2", "quantity": 5 }
  ]
}

Example Request

curl -X POST "https://us-central1-studio-9300027708-1f0ae.cloudfunctions.net/getInventory" \
     -H "Authorization: Bearer YOUR_API_KEY_HERE" \
     -H "Content-Type: application/json" \
     -d '{
           "items": [
             { "itemId": "1N3RTWf049jLR8jyN4p5", "quantity": 1 },
             { "itemId": "X0qno0rSbD9CnrirCudG", "quantity": 2 }
           ]
         }'

Success Response (200 OK)

{
  "success": true,
  "message": "2 item(s) updated successfully."
}

Error Responses

400 Bad Request - Insufficient stock for the requested quantity.

Bad Request: Insufficient stock for item "potato".

404 Not Found - One of the provided `itemId` values does not exist.

Bad Request: Item with ID "INVALID_ID_HERE" not found.

Data Models

InventoryItem Object

The structure for a single item in your inventory.

{
  "id": "X0qno0rSbD9CnrirCudG",
  "name": "carrot",
  "description": "A fresh carrot",
  "quantity": 6,
  "price": 90,
  "barcode": "6441494753334",
  "userId": "H1S3hTMYYeZoP7SHuhaPMfjggqR2",
  "imageUrl": "https://path/to/image.jpg",
  "includeInApi": true,
  "fields": {
    "sku": "CAR-001",
    "costPrice": 45,
    "reorderLevel": 10,
    "supplier": "Pandacat Inc.",
    "expiryDate": "2026-08-01"
  },
  "batches": [
    { "id": "a1b2c3d4", "qty": 4, "expiryDate": "2026-08-01", "lotNumber": "A123" },
    { "id": "e5f6g7h8", "qty": 2, "expiryDate": "2026-08-15" }
  ],
  "createdAt": "2026-02-04T16:46:21.522Z",
  "updatedAt": "2026-02-05T16:42:02.945Z"
}