Skip to main content

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

ParameterTypeDescription
shopping_list_idstringThe 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

HeaderTypeDescription
Content-TypestringMust be set to application/json.
accessTokenstringA valid access token is required.

Request Body

The request body should be in JSON format and must contain updated details for the shopping list:

FieldTypeDescription
namestringUpdated name of the shopping list.
companystringUnique identifier of the company (optional if corporateCompany is provided).
customerstringUnique identifier of the customer (can be null or empty).
corporateCompanystringUnique identifier of the corporate company (optional if company is provided).
isLockedbooleanWhether the shopping list should be locked from further changes.
statusstringUpdated status of the shopping list (e.g., "pending", "approved", "rejected").
productsarrayArray of updated products and variants with their quantities.

Product Object (products[])

Each object in the products array should follow this structure:

FieldTypeDescription
productIdstringUnique identifier for the product.
variantIdstringUnique identifier for the product variant (optional).
quantitynumberQuantity 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 CodeDescription
200 OKThe request was successful, and the shopping list details were updated.

Success Response Body Structure

FieldTypeDescription
successbooleanIndicates if the request was successful.
messagestringMessage indicating the result of the update.
dataobjectContains 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 CodeDescription
400 Bad RequestInvalid request format or missing data.
401 UnauthorizedInvalid or missing access token.
403 ForbiddenAccess denied.
404 Not FoundShopping list not found.
500 Internal Server ErrorServer encountered an error.

Notes

  • Ensure that the shopping_list_id in 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.