Price List API Documentation
This document describes the price list management endpoints for creating, reading, updating, and deleting price lists in the optical store system.Endpoint Details
Base URL:https://joptic.jethings.com
Required Headers
Authentication
All endpoints require user authentication. The user ID is extracted from the JWT token (req.user.sub), and store access is validated via the @StoreId() decorator.
Rate Limiting
Endpoints are protected with rate limiting:- GET endpoints: 60 requests per minute (long throttle)
- POST endpoints: 10 requests per minute (medium throttle)
- PUT endpoints: 20 requests per minute (medium throttle)
- DELETE endpoints: 3 requests per minute (short throttle)
Get All Price Lists
Retrieve a paginated list of price lists for the current store. Endpoint:GET /price-lists
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
search | string | No | — | Search term to filter price lists by name |
page | number | No | 1 | Page number (min: 1) |
limit | number | No | 10 | Items per page (min: 1, max: 100) |
sortBy | string | No | createdAt | Field to sort by |
sortOrder | string | No | desc | Sort order: “asc” or “desc” |
isActive | boolean | No | — | Filter by active status (currently not implemented) |
Success Response
Response Fields
id(string) - Unique identifier for the price liststoreId(string) - ID of the store that owns this price listname(string) - Name of the price listcreatedAt(Date) - Timestamp when the price list was createdcustomers(number) - Number of customers associated (currently always 0)isActive(boolean) - Whether the price list is activeitemsCount(number) - Total number of items with prices in this list
Results are paginated for performance. Search is case-insensitive and matches price list names. Default sorting is by creation date (newest first).
Example Request
Possible Errors
401 Unauthorized- Missing or invalid authentication token403 Forbidden- User does not have access to the store500 Internal Server Error- Server error
Create Price List
Create a new price list for the current store. Endpoint:POST /price-lists
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✅ Yes | Name of the price list (max: 255) |
isBuying | boolean | No | Whether this is a buying/purchase price list (default: false) |
isSelling | boolean | No | Whether this is a selling price list (default: false) |
description | string | No | Description of the price list (max: 1000) |
Request Body Example
Success Response
Example Request
A price list can be both buying and selling (set both flags to
true). The price list is automatically set as active upon creation and automatically linked to the current store. User must have access to the store (validated via user-store relation).Possible Errors
400 Bad Request- Validation errors (missing name, invalid field values)401 Unauthorized- Missing or invalid authentication token403 Forbidden- User does not have access to the store500 Internal Server Error- Server error
Update Price List
Update an existing price list. Endpoint:PUT /price-lists/:id
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | ✅ Yes | The price list ID |
Request Body
All fields are optional (partial updates supported):| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | New name for the price list (max: 255) |
isActive | boolean | No | Whether the price list should be active |
isBuying | boolean | No | Whether this is a buying price list |
isSelling | boolean | No | Whether this is a selling price list |
description | string | No | New description (max: 1000) |
Request Body Example
Success Response
Example Request
Only provided fields are updated (partial updates supported). The
updatedAt timestamp is automatically set. Price list must exist, otherwise returns 404.Possible Errors
400 Bad Request- Validation errors401 Unauthorized- Missing or invalid authentication token404 Not Found- Price list with the given ID does not exist500 Internal Server Error- Server error
Delete Multiple Price Lists
Delete one or more price lists by their IDs. Endpoint:DELETE /price-lists
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
ids | array<string> | ✅ Yes | Array of price list IDs to delete |
Request Body Example
Success Response
Example Request
Possible Errors
400 Bad Request- No IDs provided or empty array401 Unauthorized- Missing or invalid authentication token404 Not Found- No valid price lists found to delete500 Internal Server Error- Server error
Common Concepts
Price List Types
Price lists can be categorized by their purpose:Buying Price Lists
Buying Price Lists
Buying Price Lists (
isBuying: true)- Used for purchasing items from suppliers
- Represents the cost at which items are bought
- Example: “Wholesale Buying Prices”, “Supplier Prices”
Selling Price Lists
Selling Price Lists
Selling Price Lists (
isSelling: true)- Used for selling items to customers
- Represents the price at which items are sold
- Example: “Retail Prices”, “Customer Prices”
Both Types
Both Types
Both (
isBuying: true, isSelling: true)- Can be used for both buying and selling
- Less common but supported
Price List States
Active
Active (
Price list is currently in use
isActive: true)Price list is currently in use
Inactive
Inactive (
Price list is disabled but not deleted
isActive: false)Price list is disabled but not deleted
Store Association
- Each price list is associated with a specific store
- Users can only access price lists for stores they have access to
- Price lists are automatically linked to the store when created
Error Responses
All endpoints may return standard HTTP error codes:400 Bad Request- Invalid request parameters or body403 Forbidden- User does not have access to the store404 Not Found- Resource not found (price list, store, etc.)429 Too Many Requests- Rate limit exceeded500 Internal Server Error- Server error
Error Response Format
Usage Examples
Example 1: Get all price lists with pagination
Example 2: Search for price lists
Example 3: Create a buying price list
Example 4: Create a selling price list
Example 5: Update price list name and status
Example 6: Delete multiple price lists
Best Practices
Naming Conventions
Naming Conventions
- Use descriptive names that indicate the purpose (e.g., “Wholesale Buying”, “Retail Selling”)
- Include the price list type in the name for clarity
Price List Organization
Price List Organization
- Create separate price lists for buying and selling
- Use descriptions to provide additional context
- Keep inactive price lists for historical reference
Bulk Operations
Bulk Operations
- Use pagination when fetching large lists
- Delete operations are rate-limited, so batch deletions carefully
Error Handling
Error Handling
- Always check for 404 errors when updating/deleting
- Handle rate limit errors (429) with exponential backoff
- Validate request bodies before sending
Security
Security
- Store access is automatically validated
- Users can only manage price lists for stores they have access to
- Price list IDs are validated to prevent unauthorized access
Related Endpoints
After creating price lists, you can manage item prices using:- Item Price Endpoints (
/item-price) - Set prices for individual items - Lens Pricing Endpoints (
/lens-pricing) - Specialized endpoints for lens pricing by clusters
See the respective documentation files for more information about item pricing and lens pricing endpoints.
Version History
- v1.0 - Initial implementation with CRUD operations
- v1.1 - Added
isBuyingandisSellingflags for price list categorization - v1.2 - Added search functionality and improved pagination