Add a product image
This endpoint will let you add extra images to an existing product in your catalog. This does not let you change the default image of the product but you can achieve that with the Edit Product endpoint.
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.
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.
You will need the product IDs of these products to make modifications to your catalog.
Available fields
Field | Description |
---|---|
image_urls | Up to 2 URLs pointing to the images you want to add. This field can't be empty |
Invocation
Make a POST
request to https://api.p.2chat.io/open/whatsapp/catalog/product/image/<product-id>
to add additional product images and specify the following request body:
Request body
For each request, you must specify the phone number you connected to 2Chat where the product you are adding images to exists.
{
"from_number": "+595981461442",
"product": {
"image_urls": [
"https://2chat.co/img/2chat-logo.png",
"https://2chat.co/img/2chat-logo.png"
]
}
}
In the following examples, we are using 6489529801134316
as the product ID.
- cURL
- Python
- NodeJS
curl --location --request POST 'https://api.p.2chat.io/open/whatsapp/catalog/product/image/6489529801134316' \
--header 'X-User-API-Key: your_api_key_here' \
--data '{
"from_number": "+595981461442",
"product": {
"image_urls": [
"https://2chat.co/img/2chat-logo.png",
"https://2chat.co/img/2chat-logo.png"
]
}
}'
import requests
url = "https://api.p.2chat.io/open/whatsapp/catalog/product/image/6489529801134316"
payload = json.dumps({
"from_number": "+595981461442",
"product": {
"image_urls": [
"https://2chat.co/img/2chat-logo.png",
"https://2chat.co/img/2chat-logo.png"
]
}
})
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",
"product": {
"image_urls": [
"https://2chat.co/img/2chat-logo.png",
"https://2chat.co/img/2chat-logo.png"
]
}
});
var config = {
method: 'POST',
url: 'https://api.p.2chat.io/open/whatsapp/catalog/product/image/6489529801134316',
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
}