Edit a collection
This endpoint will let you edit an existing collection of products in your catalog.
To use this API, you must connect a number that uses the free version of WhatsApp Business. This API does not need a WhatsApp Business API account to work.
You will need the collection ID you want to edit to do this. You can obtain it by finding the collection in your list of collections.
You will also need the product IDs of the products you want to add or remove from the collection. You can get them in your list of products.
Just like with the app, each modification you make will go through a verification process made by WhatsApp that can take between a few minutes to a few hours.
Available fields
Field | Description |
---|---|
add_product_ids | The list of product IDs you want to add to this collection. It can be empty |
remove_product_ids | The list of product IDs you want to remove to this collection. It can be empty |
Invocation
Make a PUT
request to https://api.p.2chat.io/open/whatsapp/catalog/collection/<collection-id>
and specify any of the following fields in the request body:
In the following examples, we are using 268305749345797
as the collection ID we are editing, with 7096834393683427
as the product ID to remove and 6498277906923281
to add.
Request body
For each request, you must specify the phone number you connected to 2Chat that has the product you want to edit inside its catalog.
{
"from_number": "+595981461442",
"collection": {
"remove_product_ids": [ "7096834393683427" ],
"add_product_ids": [ "6498277906923281" ]
}
}
- cURL
- Python
- NodeJS
curl --location --request PUT 'https://api.p.2chat.io/open/whatsapp/catalog/collection/268305749345797' \
--header 'X-User-API-Key: your_api_key_here' \
--data '{
"from_number": "+595981461442",
"collection": {
"remove_product_ids": [ "7096834393683427" ],
"add_product_ids": [ "6498277906923281" ]
}
}'
import requests
url = "https://api.p.2chat.io/open/whatsapp/catalog/collection/268305749345797"
payload = json.dumps({
"from_number": "+595981461442",
"collection": {
"remove_product_ids": [ "7096834393683427" ],
"add_product_ids": [ "6498277906923281" ]
}
})
headers = {
'X-User-API-Key': 'your_api_key_here'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
let data = JSON.stringify({
"from_number": "+595981461442",
"collection": {
"remove_product_ids": [ "7096834393683427" ],
"add_product_ids": [ "6498277906923281" ]
}
});
var config = {
method: 'PUT',
url: 'https://api.p.2chat.io/open/whatsapp/catalog/collection/268305749345797',
headers: {
'X-User-API-Key': 'your_api_key_here'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Response
The collection ID changes every time you edit it. Make sure to update new requests with the new ID.
{
"success": true
}