Back to API Docs

UI Handoff: Curated Product Copy Flow (Inventory Item Create)

Date: 2026-03-06
Audience: React Native developers + QA

Endpoint

Request Body (current schema)

{
  "inventory_id": 1,
  "storage_box_id": 1,
  "product_id": 123,
  "current_quantity": 5,
  "min_stock": 1,
  "lot_number": "LOT-001",
  "expiration_date": "2026-12-31",
  "notes": "Batch notes"
}

min_stock is the preferred field for UI requests. It is stored in the inventory/storage-box/product stock-alert mapping. minimum_quantity is still accepted by the backend for backward compatibility.

Required fields:

  1. inventory_id
  2. storage_box_id
  3. product_id

New Behavior

If product_id belongs to another user (curator product) and current user has access via curated list:

  1. Backend copies that product to current user.
  2. Copied product is set to managing_status = "both".
  3. Inventory item is created using copied product id.

If product_id is already owned by current user:

  1. No copy is created.
  2. Inventory item uses same product id.

Response Notes

Response shape is unchanged, but nested product values may differ:

  1. product.id can be a new copied id (for curated source products).
  2. product.managing_status may be "both".
  3. product.created_by.id should be current user for copied products.

Example Response: own product (no copy)

{
  "id": 11,
  "inventory": { "id": 1, "name": "Main Inventory" },
  "storage_box": { "id": 1, "name": "Main Box" },
  "product": {
    "id": 21,
    "managing_status": "self_managed",
    "created_by": { "id": 5, "email": "user@example.com" }
  },
  "current_quantity": 5,
  "min_stock": 1,
  "minimum_quantity": 1,
  "lot_number": "LOT-001"
}

Example Response: curated product (copied)

{
  "id": 12,
  "inventory": { "id": 1, "name": "Main Inventory" },
  "storage_box": { "id": 1, "name": "Main Box" },
  "product": {
    "id": 45,
    "managing_status": "both",
    "created_by": { "id": 5, "email": "user@example.com" }
  },
  "current_quantity": 5,
  "min_stock": 1,
  "minimum_quantity": 1,
  "lot_number": "LOT-002"
}

React Native Checklist

  1. Always send Authorization: Bearer <access_token>.
  2. Send inventory_id, storage_box_id, product_id (not old keys inventory, storage_box, product).
  3. Prefer sending min_stock; backend still accepts minimum_quantity.
  4. The persisted threshold now lives in /api/inventory-stock-alerts/ for the inventory_id + storage_box_id + product_id combination.
  5. After create, use returned nested product.id for next actions.
  6. Treat managing_status enum as: catalogued | self_managed | both.
  7. If create fails with 400, verify user access to inventory/storage box/product.

QA Test Cases

  1. Own product -> item created with same product.id.
  2. Curated subscribed product -> item created with copied product.id, managing_status=both.
  3. Repeat curated add -> should reuse existing copied product (no unnecessary duplicate copy).
  4. Expired/inactive curated subscription -> product_id should be rejected.

Swagger / API Docs