Product Update
Product Update API is essential for updating product details utilized in features like price drop or back in stock alerts. If you're using these alert features, employ this API to communicate the latest product price and back in stock details. This enables timely notifications about any updates.
POST
https://api.pushengage.com/apiv1/products
Request Parameters
Parameter Name | Type | Required | Description |
---|---|---|---|
products | Product[] | Yes | An array of products to be updated. Refer to the product object section for more details. |
Response Object
Parameter Name | Type | Required | Description |
---|---|---|---|
success | Boolean | Yes | Specifies if the product update request was successful. Acceptable values are true or false . |
Product Object
Parameter Name | Parameter Type | Description |
---|---|---|
product_id | String | The ID associated with the product for alerts. |
price | Number | The updated price for the product. |
availability | String | Indicates the product's availability. It can be inStock if the product is available or outOfStock if it's not. The default value is inStock . |
variant_id | String | Optional. The ID for a specific product variant. Required only if variants were considered during alert setup. |
Example
Request
- cURL
- PHP
curl -X POST \
https://api.pushengage.com/apiv1/products \
-H 'Content-Type: application/json' \
-H 'api_key: <your_pushengage_api_key>' \
-d '{
"products": [
{
"product_id": "1",
"price": 100,
"availability": "outOfStock",
"variant_id": "variantID"
},
{
"product_id": "2",
"price": 100,
"availability": "inStock",
"variant_id": "variantId2"
}
]
}'
<?php
$product1 = array("product_id" => "1", "price" => 60, "availability" => "outOfStock", "variant_id" => "variantID");
$product2 = array("product_id" => "2", "price" => 100, "availability" => "inStock", "variant_id" => "variantID2");
$products = array(json_encode($product1), json_encode($product2),);
$request_payload = json_encode(array("products" => $products));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.pushengage.com/apiv1/products",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $request_payload,
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"api_key: <your_pushengage_api_key>;",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Response
- 200 OK
- 401 Unauthorized
- 400 Bad Request
{
"success": true
}
{
"success": false,
"error_code": "1001",
"message": "Invalid API Key"
}
{
"success": false,
"error": {
"name": "InvalidRequestException",
"message": "Error Message"
}
}