Update Shopping List
This PUT API allows you to update the details of an existing shopping list, including changes to products and their quantities.
Endpoint Details
- URL:
/shoppingList/update/{shopping_list_id} - Method:
PUT - Authentication: Bearer Token (required)
Path Parameters
| Parameter | Type | Description |
|---|---|---|
shopping_list_id | string | The unique identifier of the shopping list to update. |
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 should be in JSON format and must contain updated details for the shopping list:
| Field | Type | Description |
|---|---|---|
name | string | Updated name of the shopping list. |
company | string | Unique identifier of the company (optional if corporateCompany is provided). |
customer | string | Unique identifier of the customer (can be null or empty). |
corporateCompany | string | Unique identifier of the corporate company (optional if company is provided). |
isLocked | boolean | Whether the shopping list should be locked from further changes. |
status | string | Updated status of the shopping list (e.g., "pending", "approved", "rejected"). |
products | array | Array of updated products and variants 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 in the shopping list. |
Sample Request Body
{
"name": "Weekly Shopping Update",
"company": "65ba028af764f931f1c7c18b",
"customer": "66d07121db294e0b70180bf6",
"corporateCompany": null,
"isLocked": false,
"status": "pending",
"products": [
{
"productId": "65b88ef6045a7d009e79c829",
"quantity": 3
},
{
"productId": "65b88ef6045a7d009e79c859",
"variantId": "66d5a286fcb786834cebb168",
"quantity": 2
}
]
}
Response
Success Response
| Status Code | Description |
|---|---|
| 200 OK | The request was successful, and the shopping list details were updated. |
Success Response Body Structure
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the request was successful. |
message | string | Message indicating the result of the update. |
data | object | Contains the updated details of the shopping list. |
Sample Response Body
{
"success": true,
"message": "ShoppingList updated Successfully",
"data": {
"id": "7312abc1648b4f3a8dfd7e89",
"name": "Weekly Shopping Update",
"company": "65ba028af764f931f1c7c18b",
"customer": "66d07121db294e0b70180bf6",
"corporateCompany": null,
"isLocked": false,
"status": "pending",
"products": [
{
"productId": "65b88ef6045a7d009e79c829",
"quantity": 3
},
{
"productId": "65b88ef6045a7d009e79c859",
"variantId": "66d5a286fcb786834cebb168",
"quantity": 2
}
],
"createdAt": "2024-01-10T12:00:00Z",
"updatedAt": "2024-01-15T14: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. |
| 404 Not Found | Shopping list not found. |
| 500 Internal Server Error | Server encountered an error. |
Notes
- Ensure that the
shopping_list_idin the URL matches the ID of the shopping list you wish to update. - Include all required fields in the request body to avoid validation errors.
- A valid access token is necessary for authentication to successfully update the shopping list.