Skip to content

API Endpoints

This page documents all available StockrHub API endpoints, organized by resource. All endpoints require authentication via Shopify session tokens (see Authentication).


Retrieves dashboard statistics, recent purchase orders, and active alerts.

GET /api/dashboard

Response:

{
"success": true,
"data": {
"stats": {
"totalProducts": 245,
"lowStockItems": 12,
"openPurchaseOrders": 3,
"pendingReceives": 1
},
"recentPOs": [
{
"id": 42,
"poNumber": "PO-00042",
"supplier": "Acme Supplies",
"status": "sent",
"total": 1250.00,
"createdAt": "2026-02-25T10:30:00Z"
}
],
"alerts": [
{
"id": 1,
"type": "low_stock",
"message": "Widget Blue SM is below reorder point",
"productId": "gid://shopify/Product/123",
"createdAt": "2026-02-27T08:00:00Z"
}
]
}
}

GET /api/suppliers

Response:

{
"success": true,
"data": [
{
"id": 1,
"name": "Acme Supplies",
"email": "[email protected]",
"phone": "+1-555-0100",
"leadTimeDays": 7,
"paymentTerms": "Net 30",
"createdAt": "2026-01-15T09:00:00Z"
}
]
}
POST /api/suppliers

Request:

{
"name": "Acme Supplies",
"email": "[email protected]",
"phone": "+1-555-0100",
"address": "123 Supply St, Commerce City, CO 80022",
"leadTimeDays": 7,
"paymentTerms": "Net 30",
"notes": "Preferred supplier for widgets"
}

Response:

{
"success": true,
"data": {
"id": 1,
"name": "Acme Supplies",
"email": "[email protected]",
"createdAt": "2026-02-28T12:00:00Z"
}
}
GET /api/suppliers/:id

Response:

{
"success": true,
"data": {
"id": 1,
"name": "Acme Supplies",
"email": "[email protected]",
"phone": "+1-555-0100",
"address": "123 Supply St, Commerce City, CO 80022",
"leadTimeDays": 7,
"paymentTerms": "Net 30",
"notes": "Preferred supplier for widgets",
"contacts": [],
"createdAt": "2026-01-15T09:00:00Z",
"updatedAt": "2026-02-20T14:30:00Z"
}
}
PUT /api/suppliers/:id

Request:

{
"name": "Acme Supplies Inc.",
"leadTimeDays": 5,
"paymentTerms": "Net 15"
}

Response:

{
"success": true,
"data": {
"id": 1,
"name": "Acme Supplies Inc.",
"updatedAt": "2026-02-28T12:00:00Z"
}
}
DELETE /api/suppliers/:id

Response:

{
"success": true,
"data": {
"message": "Supplier deleted successfully"
}
}
POST /api/suppliers/:id/contacts

Request:

{
"name": "Jane Smith",
"email": "[email protected]",
"phone": "+1-555-0101",
"role": "Sales Representative"
}

Response:

{
"success": true,
"data": {
"id": 1,
"supplierId": 1,
"name": "Jane Smith",
"email": "[email protected]",
"phone": "+1-555-0101",
"role": "Sales Representative"
}
}

GET /api/purchase-orders

Query parameters:

ParameterTypeDescription
statusstringFilter by status: draft, sent, partial, received, cancelled
supplierIdnumberFilter by supplier ID

Response:

{
"success": true,
"data": [
{
"id": 42,
"poNumber": "PO-00042",
"supplierId": 1,
"supplierName": "Acme Supplies",
"status": "sent",
"subtotal": 1150.00,
"tax": 100.00,
"total": 1250.00,
"lineItemCount": 5,
"createdAt": "2026-02-25T10:30:00Z",
"sentAt": "2026-02-25T11:00:00Z"
}
]
}
POST /api/purchase-orders

Request:

{
"supplierId": 1,
"notes": "Rush order for weekend sale",
"supplierNotes": "Please ship via express",
"lineItems": [
{
"productId": "gid://shopify/Product/123",
"variantId": "gid://shopify/ProductVariant/456",
"sku": "WIDGET-BLU-SM",
"title": "Widget Blue - Small",
"quantity": 50,
"costPrice": 12.50
},
{
"productId": "gid://shopify/Product/124",
"variantId": "gid://shopify/ProductVariant/789",
"sku": "WIDGET-RED-MD",
"title": "Widget Red - Medium",
"quantity": 30,
"costPrice": 14.00
}
]
}

Response:

{
"success": true,
"data": {
"id": 43,
"poNumber": "PO-00043",
"status": "draft",
"supplierId": 1,
"total": 1045.00,
"createdAt": "2026-02-28T12:00:00Z"
}
}
GET /api/purchase-orders/:id

Response:

{
"success": true,
"data": {
"id": 42,
"poNumber": "PO-00042",
"supplierId": 1,
"supplierName": "Acme Supplies",
"status": "sent",
"notes": "Rush order for weekend sale",
"supplierNotes": "Please ship via express",
"subtotal": 1150.00,
"tax": 100.00,
"total": 1250.00,
"lineItems": [
{
"id": 1,
"sku": "WIDGET-BLU-SM",
"title": "Widget Blue - Small",
"quantity": 50,
"costPrice": 12.50,
"receivedQuantity": 0,
"lineTotal": 625.00
}
],
"createdAt": "2026-02-25T10:30:00Z",
"sentAt": "2026-02-25T11:00:00Z"
}
}
PUT /api/purchase-orders/:id

Request:

{
"notes": "Updated internal notes",
"lineItems": [
{
"sku": "WIDGET-BLU-SM",
"quantity": 75,
"costPrice": 12.00
}
]
}
DELETE /api/purchase-orders/:id

Sends the PO as a PDF to the supplier’s email address and changes the status to sent.

POST /api/purchase-orders/:id/send

Response:

{
"success": true,
"data": {
"id": 42,
"status": "sent",
"sentAt": "2026-02-28T12:00:00Z"
}
}

Records received quantities for a purchase order.

POST /api/purchase-orders/:id/receive

Request:

{
"lineItems": [
{
"lineItemId": 1,
"quantityReceived": 50
},
{
"lineItemId": 2,
"quantityReceived": 20
}
]
}

Response:

{
"success": true,
"data": {
"id": 42,
"status": "partial",
"receivedAt": "2026-02-28T14:00:00Z"
}
}

GET /api/reorder/rules

Response:

{
"success": true,
"data": [
{
"id": 1,
"productId": "gid://shopify/Product/123",
"variantId": "gid://shopify/ProductVariant/456",
"sku": "WIDGET-BLU-SM",
"title": "Widget Blue - Small",
"reorderPoint": 20,
"reorderQuantity": 50,
"supplierId": 1,
"supplierName": "Acme Supplies"
}
]
}
POST /api/reorder/rules

Request:

{
"variantId": "gid://shopify/ProductVariant/456",
"reorderPoint": 20,
"reorderQuantity": 50,
"supplierId": 1
}

Response:

{
"success": true,
"data": {
"id": 1,
"variantId": "gid://shopify/ProductVariant/456",
"reorderPoint": 20,
"reorderQuantity": 50,
"supplierId": 1
}
}
PUT /api/reorder/rules/:id

Request:

{
"reorderPoint": 25,
"reorderQuantity": 60
}
DELETE /api/reorder/rules/:id

Returns products that are currently at or below their reorder point.

GET /api/reorder/suggestions

Response:

{
"success": true,
"data": [
{
"variantId": "gid://shopify/ProductVariant/456",
"sku": "WIDGET-BLU-SM",
"title": "Widget Blue - Small",
"currentStock": 15,
"reorderPoint": 20,
"reorderQuantity": 50,
"supplierId": 1,
"supplierName": "Acme Supplies"
}
]
}

GET /api/stock-levels

Query parameters:

ParameterTypeDescription
locationIdstringFilter by Shopify location ID
searchstringSearch by product title or SKU

Response:

{
"success": true,
"data": [
{
"variantId": "gid://shopify/ProductVariant/456",
"sku": "WIDGET-BLU-SM",
"title": "Widget Blue - Small",
"currentStock": 45,
"locationId": "gid://shopify/Location/1",
"locationName": "Warehouse"
}
]
}
PUT /api/stock-levels/bulk

Request:

{
"adjustments": [
{
"variantId": "gid://shopify/ProductVariant/456",
"locationId": "gid://shopify/Location/1",
"quantity": 100,
"reason": "Stock count adjustment"
},
{
"variantId": "gid://shopify/ProductVariant/789",
"locationId": "gid://shopify/Location/1",
"quantity": 50,
"reason": "Stock count adjustment"
}
]
}

Response:

{
"success": true,
"data": {
"adjusted": 2,
"message": "Stock levels updated successfully"
}
}

GET /api/stock-transfers

Response:

{
"success": true,
"data": [
{
"id": 1,
"sourceLocationId": "gid://shopify/Location/1",
"sourceLocationName": "Warehouse",
"destinationLocationId": "gid://shopify/Location/2",
"destinationLocationName": "Retail Store",
"status": "pending",
"itemCount": 3,
"createdAt": "2026-02-27T09:00:00Z"
}
]
}
POST /api/stock-transfers

Request:

{
"sourceLocationId": "gid://shopify/Location/1",
"destinationLocationId": "gid://shopify/Location/2",
"items": [
{
"variantId": "gid://shopify/ProductVariant/456",
"quantity": 10
},
{
"variantId": "gid://shopify/ProductVariant/789",
"quantity": 5
}
],
"notes": "Restocking retail store for weekend"
}

Response:

{
"success": true,
"data": {
"id": 2,
"status": "pending",
"createdAt": "2026-02-28T12:00:00Z"
}
}
GET /api/stock-transfers/:id
PUT /api/stock-transfers/:id

Updates the status of a stock transfer (e.g., mark as completed).

Request:

{
"status": "completed"
}

GET /api/stock-counts

Response:

{
"success": true,
"data": [
{
"id": 1,
"locationId": "gid://shopify/Location/1",
"locationName": "Warehouse",
"status": "draft",
"itemCount": 15,
"createdAt": "2026-02-26T08:00:00Z"
}
]
}
POST /api/stock-counts

Request:

{
"locationId": "gid://shopify/Location/1",
"items": [
{
"variantId": "gid://shopify/ProductVariant/456",
"countedQuantity": 48
},
{
"variantId": "gid://shopify/ProductVariant/789",
"countedQuantity": 22
}
]
}

Response:

{
"success": true,
"data": {
"id": 2,
"status": "draft",
"locationId": "gid://shopify/Location/1",
"createdAt": "2026-02-28T12:00:00Z"
}
}
GET /api/stock-counts/:id

Submit or modify a stock count.

PUT /api/stock-counts/:id

Request:

{
"status": "submitted",
"items": [
{
"variantId": "gid://shopify/ProductVariant/456",
"countedQuantity": 47
}
]
}

GET /api/reports/procurement-spend

Query parameters:

ParameterTypeDescription
startDatestringStart date (ISO 8601)
endDatestringEnd date (ISO 8601)
supplierIdnumberFilter by supplier

Response:

{
"success": true,
"data": {
"totalSpend": 15420.00,
"orderCount": 12,
"bySupplier": [
{
"supplierId": 1,
"supplierName": "Acme Supplies",
"spend": 8500.00,
"orderCount": 7
}
],
"byMonth": [
{
"month": "2026-01",
"spend": 6200.00
},
{
"month": "2026-02",
"spend": 9220.00
}
]
}
}
GET /api/reports/sales-velocity

Query parameters:

ParameterTypeDescription
periodstringTime period: 7d, 30d, 90d

Response:

{
"success": true,
"data": [
{
"variantId": "gid://shopify/ProductVariant/456",
"sku": "WIDGET-BLU-SM",
"title": "Widget Blue - Small",
"unitsSold": 120,
"avgDailySales": 4.0,
"currentStock": 45,
"daysOfStockRemaining": 11
}
]
}
GET /api/reports/adjustments

Query parameters:

ParameterTypeDescription
startDatestringStart date (ISO 8601)
endDatestringEnd date (ISO 8601)

Response:

{
"success": true,
"data": [
{
"id": 1,
"variantId": "gid://shopify/ProductVariant/456",
"sku": "WIDGET-BLU-SM",
"previousQuantity": 50,
"newQuantity": 48,
"adjustment": -2,
"reason": "Stock count adjustment",
"createdAt": "2026-02-27T10:00:00Z"
}
]
}

GET /api/alerts

Response:

{
"success": true,
"data": [
{
"id": 1,
"type": "low_stock",
"message": "Widget Blue SM is below reorder point (15 / 20)",
"productId": "gid://shopify/Product/123",
"read": false,
"createdAt": "2026-02-27T08:00:00Z"
},
{
"id": 2,
"type": "po_overdue",
"message": "PO-00038 from Acme Supplies is overdue by 3 days",
"purchaseOrderId": 38,
"read": false,
"createdAt": "2026-02-26T00:00:00Z"
}
]
}
POST /api/alerts/configure

Request:

{
"lowStockAlerts": true,
"overduePoAlerts": true,
"alertThresholdPercent": 10
}

Response:

{
"success": true,
"data": {
"message": "Alert configuration updated"
}
}