Item Price API
Audience: Frontend engineers managing item prices within price lists.- Base URL:
https://jethings-backend.fly.dev - Content-Type:
application/json
Conventions
- All responses are JSON.
- Errors follow standard HTTP status codes with
{ message: string }body. - Unless noted, successful responses are
200 OK. - All endpoints require authentication via Bearer token.
- All endpoints require
x-store-idheader to scope requests to a specific store. - Access is controlled through user-store relationships.
Headers
| Header | Type | Required | Description |
|---|---|---|---|
x-store-id | string | ✅ | Store ID associated with the current request |
Authorization | string | ✅ | Bearer token for authentication (e.g., Bearer <token>) |
Overview
The Item Price API manages item pricing within a specific price list. It allows creating, updating, and retrieving item prices for a given price list or product. Base URL:/item-price
This API works with price lists created through the Price List API.
Set or Update Item Prices
POST/item-price/:priceListId
Requires Authentication: Bearer token in Authorization headerRequires Header:
x-store-id
Assign or update multiple item prices for a given price list.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
priceListId | string | ✅ | ID of the price list |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
productId | string | No | ID of the product |
itemPrices | array | ✅ | Array of item price objects |
Item Price Object
| Field | Type | Required | Description |
|---|---|---|---|
itemId | string | ✅ | ID of the item |
itemPrice | number | ✅ | Price for the item |
Request Body Example
Success Response
Logic Summary
- Checks if the price list exists
- For each item:
- If a price already exists, it updates it
- Otherwise, inserts a new price record
- Returns updated or newly created item prices
Possible Errors
400 Bad Request: Invalid input or validation errors401 Unauthorized: Missing or invalid authentication token403 Forbidden: No store access404 Not Found: Price list not found500 Internal Server Error: Server error
Example Request
Get Prices for a Product
GET/item-price/:priceListId/product/:productId
Requires Authentication: Bearer token in Authorization headerRequires Header:
x-store-id
Retrieve all item prices for a given product under a specific price list.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
priceListId | string | ✅ | ID of the price list |
productId | string | ✅ | ID of the product |
Success Response
Logic Summary
- Verifies price list existence
- Fetches all items related to the product
- Finds associated prices (if any) for each item
- Returns a combined result of items and prices
Possible Errors
401 Unauthorized: Missing or invalid authentication token403 Forbidden: No store access404 Not Found: Price list not found or no items found for this product500 Internal Server Error: Server error
Example Request
Get All Item Prices by Price List
GET/item-price/:priceListId
Requires Authentication: Bearer token in Authorization headerRequires Header:
x-store-id
Retrieve all item prices grouped by product for a specific price list.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
priceListId | string | ✅ | ID of the price list |
Success Response
Logic Summary
- Verifies the price list exists
- Fetches all related
itemPricerecords, including product and item info - Groups results by product
- Returns structured data for easier frontend display
Possible Errors
401 Unauthorized: Missing or invalid authentication token403 Forbidden: No store access404 Not Found: Price list not found500 Internal Server Error: Server error
Example Request
DTOs Overview
ItemPricesDto
Business Logic
Item Price Service Logic
ItemPriceService.setProductItemPrices(priceListId, itemPrices)
- Validates
priceListId - Iterates over
itemPrices - Uses
Promise.all()to handle multiple updates/inserts concurrently - Returns updated list of all items with their prices
ItemPriceService.getProductItemPrices(priceListId, productId)
- Validates both IDs
- Fetches product items
- Joins prices for each item
- Returns a full breakdown per product
ItemPriceService.getAllItemPricesByPriceList(priceListId)
- Fetches all item prices linked to a price list
- Groups them by product
- Returns products with their items and respective prices
Error Responses
Common Error Codes
400 Bad Request: Invalid request data or validation errors401 Unauthorized: Missing or invalid authentication token403 Forbidden: No access to the specified store404 Not Found: Price list not found or no items found for this product500 Internal Server Error: Server error