Create Shopping List
Creates a new shopping list for a company (optionally for a specific customer) or for a corporate company.
HTTP Request
- URL:
/shoppingList/create - Method:
POST - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope:
READ_WRITE_SHOPPINGLIST
Request Body
The request body must be JSON and contain the following fields. Send either company or corporateCompany.
| Field | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Name of the shopping list. |
products | Array | Yes | Products to add to the list. See below. |
company | String | Conditional | ID of the company. Required if corporateCompany is not sent. |
corporateCompany | String | Conditional | ID of the corporate company. Required if company is not sent. |
customer | String | No | ID of the customer who owns the list. |
isLocked | Boolean | No | Whether the list is locked against changes. Default is false. |
status | String | No | pending, approved or rejected. Default is pending. |
Product Object
| Field | Type | Required | Description |
|---|---|---|---|
productId | String | Yes | ID of the product. |
variantId | String | No | ID of the product variant. |
quantity | Number | No | Quantity of the product. |
cURL Example
curl --location '<BASE_URL>/shoppingList/create' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Monthly Site Supplies",
"company": "65ba028af764f931f1c7c18b",
"customer": "66d07121db294e0b70180bf6",
"products": [
{
"productId": "65b88ef5045a7d009e79974b",
"quantity": 4
},
{
"productId": "66b4a01249e6ce3d41c428fa",
"variantId": "66d5a286fcb786834cebb16a",
"quantity": 20
}
]
}'
Response
- 200 OK: The shopping list was created successfully.
- 400 Bad Request: The access token is missing or invalid, does not have the required scope, or the request body is not valid (for example, the company was not found).
Sample JSON Response
{
"success": true,
"message": "ShoppingList created Successfully",
"data": {
"_id": "6722d1a4b7c3e85f2a9d0b10",
"name": "Monthly Site Supplies",
"company": "65ba028af764f931f1c7c18b",
"customer": "66d07121db294e0b70180bf6",
"corporateCompany": null,
"isLocked": false,
"status": "pending",
"products": [
{
"_id": "6722d1a4b7c3e85f2a9d0b11",
"productId": "65b88ef5045a7d009e79974b",
"quantity": 4
},
{
"_id": "6722d1a4b7c3e85f2a9d0b12",
"productId": "66b4a01249e6ce3d41c428fa",
"variantId": "66d5a286fcb786834cebb16a",
"quantity": 20
}
],
"metaFields": [],
"createdBy": {
"id": "6650c2e9f1a3b84d2e7a9c01",
"name": "ERP Integration",
"type": "api"
},
"order": 0,
"createdAt": "2024-10-31T08:20:52.417Z",
"updatedAt": "2024-10-31T08:20:52.417Z"
}
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request was successful. |
message | String | Result message. |
data | Object | The new shopping list. _id is the shopping list ID. |
Shopping List Data
The shopping list fields are described in Get Single Shopping List.
Notes
- Products or variants that are not found in your catalog are skipped.