Add a collection to your catalog
This endpoint will return a list of products a given WhatsApp Business number has published on their account. You can list products that belong to your own WhatsApp account or any other WhatsApp Business account.
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 may need the product IDs of these products to make modifications to your catalog.
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.
Request body
For each request, you must specify the phone number you connected to 2Chat that you want to use as the client.
The name of a collection can't be changed once created. To change it, you must delete the entire collection and add it back with the right name.
{
"from_number": "+595981461442",
"collection": {
"name": "Shoes",
"product_ids": [ "9846351425439378" ]
}
}
Getting a list of products
If you want to get a list of your products, make a GET request to https://api.p.2chat.io/open/whatsapp/catalog/collection
without specifying any phone number.
If you instead want to list products that belong to another WhatsApp Business account, you can add that phone number to the URL to get them. For exmple: https://api.p.2chat.io/open/whatsapp/catalog/products/+595981461442
.
Use +595981461442 as an example of a live working set of products you can query
Invocation
- cURL
- Python
- NodeJS
curl --location --request POST 'https://api.p.2chat.io/open/whatsapp/catalog/collection' \
--header 'X-User-API-Key: your_api_key_here' \
--data '{
"from_number": "+595981461442"
}'
import requests
url = "https://api.p.2chat.io/open/whatsapp/catalog/collection"
payload = json.dumps({
"from_number": "+595981461442"
})
headers = {
'X-User-API-Key': 'your_api_key_here'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
let data = JSON.stringify({
"from_number": "+595981461442"
});
var config = {
method: 'POST',
url: 'https://api.p.2chat.io/open/whatsapp/catalog/collection',
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
{
"success": true
}