Skip to main content

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-id header to scope requests to a specific store.
  • Access is controlled through user-store relationships.

Headers


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 header
Requires Header: x-store-id
Assign or update multiple item prices for a given price list.

Path Parameters

Request Body

Item Price Object

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 errors
  • 401 Unauthorized: Missing or invalid authentication token
  • 403 Forbidden: No store access
  • 404 Not Found: Price list not found
  • 500 Internal Server Error: Server error

Example Request


Get Prices for a Product

GET /item-price/:priceListId/product/:productId Requires Authentication: Bearer token in Authorization header
Requires Header: x-store-id
Retrieve all item prices for a given product under a specific price list.

Path Parameters

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 token
  • 403 Forbidden: No store access
  • 404 Not Found: Price list not found or no items found for this product
  • 500 Internal Server Error: Server error

Example Request


Get All Item Prices by Price List

GET /item-price/:priceListId Requires Authentication: Bearer token in Authorization header
Requires Header: x-store-id
Retrieve all item prices grouped by product for a specific price list.

Path Parameters

Success Response

Logic Summary

  • Verifies the price list exists
  • Fetches all related itemPrice records, including product and item info
  • Groups results by product
  • Returns structured data for easier frontend display

Possible Errors

  • 401 Unauthorized: Missing or invalid authentication token
  • 403 Forbidden: No store access
  • 404 Not Found: Price list not found
  • 500 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 errors
  • 401 Unauthorized: Missing or invalid authentication token
  • 403 Forbidden: No access to the specified store
  • 404 Not Found: Price list not found or no items found for this product
  • 500 Internal Server Error: Server error

Error Response Format