Skip to main content

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

HeaderTypeDescription
Content-TypestringMust be set to application/json.
accessTokenstringA 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:

FieldTypeDescription
namestringName of the shopping list.
companystringThe unique identifier of the company (optional if corporateCompany is provided).
customerstringThe unique identifier of the customer (can be null or empty).
corporateCompanystringThe unique identifier of the corporate company (optional if company is provided).
isLockedbooleanIndicates if the shopping list is locked from changes.
statusstringStatus of the shopping list (e.g., "pending", "approved", "rejected").
productsarrayArray of product and variant objects 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 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 CodeDescription
200 OKThe request was successful, and the new shopping list was created.

Success Response Body Structure

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

Notes

  • Ensure that the provided company ID 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.