Create Shopping List
This POST API allows you to create new shopping lists for a specific company or customer or corporate company. This endpoint supports adding products and variants to the shopping list with specific quantities.
Endpoint Details
- URL:
/shoppingList/create - Method:
POST - Authentication: Bearer Token (required)
Authentication
You must provide a valid accessToken in the request headers to authenticate and access this endpoint.
Authentication Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be set to application/json. |
accessToken | string | A valid access token is required. |
Request Body
The request body must be in JSON format and should contain the details of the shopping list as follows:
| Field | Type | Description |
|---|---|---|
name | string | Name of the shopping list. |
company | string | The unique identifier of the company (optional if corporateCompany is provided). |
customer | string | The unique identifier of the customer (can be null or empty). |
corporateCompany | string | The unique identifier of the corporate company (optional if company is provided). |
isLocked | boolean | Indicates if the shopping list is locked from changes. |
status | string | Status of the shopping list (e.g., "pending", "approved", "rejected"). |
products | array | Array of product and variant objects with their quantities. |
Product Object (products[])
Each object in the products array should follow this structure:
| Field | Type | Description |
|---|---|---|
productId | string | Unique identifier for the product. |
variantId | string | Unique identifier for the product variant (optional). |
quantity | number | Quantity of the product or variant to be added. |
Sample Request Body
{
"name": "Weekend Groceries",
"company": "65ba028af764f931f1c7c18b",
"customer": null,
"corporateCompany": null,
"isLocked": false,
"status": "pending",
"products": [
{
"productId": "65b88ef6045a7d009e79c829",
"quantity": 2
},
{
"productId": "65b88ef6045a7d009e79c859",
"variantId": "65ba028af764f931f1c7c18b",
"quantity": 1
}
]
}
Response
Success Response
| Status Code | Description |
|---|---|
| 200 OK | The request was successful, and the new shopping list was created. |
Success Response Body Structure
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the request was successful. |
message | string | Message indicating the result of the operation. |
data | object | Contains the newly created shopping list details. |
Sample Response Body
{
"success": true,
"message": "ShoppingList created Successfully",
"data": {
"id": "7312abc1648b4f3a8dfd7e89",
"name": "Weekend Groceries",
"company": "65ba028af764f931f1c7c18b",
"customer": null,
"corporateCompany": null,
"isLocked": false,
"status": "pending",
"products": [
{
"productId": "65b88ef6045a7d009e79c829",
"quantity": 2
},
{
"productId": "65b88ef6045a7d009e79c859",
"variantId": "65ba028af764f931f1c7c18b",
"quantity": 1
}
],
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-01-15T10:00:00Z"
}
}
Error Responses
| Status Code | Description |
|---|---|
| 400 Bad Request | Invalid request format or missing data. |
| 401 Unauthorized | Invalid or missing access token. |
| 403 Forbidden | Access denied. |
| 500 Internal Server Error | Server encountered an error. |
Notes
- Ensure that the provided
companyID is correct and corresponds to an existing company. - Include all required fields in the request body to avoid validation errors.
- A valid access token is necessary for authentication to successfully create the shopping list.