The store API: update a product's or a size's price, and the compare-at price
The reference for the price address of the ArabyBot store API: the price, the compare-at price, a variant's price, the response, and the refusals.
On this page 7
The short answer
With a POST request to the price address under the product id, carrying the new price, with a key that has write access. The compare-at price can be sent with it, and is kept only if it is greater than the price. If you send a variant id, only that size's price changes. The new price shows in the store straight away.
Also asked as: «اغير اسعار المنتجات في المتجر بالكود» · «update product price via api»
The address and authentication
POST https://app.arabybot.com/store_api/v1/products/{id}/price Send the store key in the header Authorization: Bearer abst_… or X-Api-Key. This address changes data, so it needs a key with write access; a read key is refused with status 403. You create the key in the store settings.
The fields
price(required) The new price, a non-negative number, rounded to two decimal places.compare_at_price(optional) The compare-at price. Kept if greater than the price, otherwise cleared. For the product, not for a variant.variant_id(optional) The variant id; if sent, only that size's price changes.
An example request
cURL
curl -X POST https://app.arabybot.com/store_api/v1/products/88/price \
-H "Authorization: Bearer abst_YOUR_WRITE_KEY" \
-H "Content-Type: application/json" \
-d '{ "price": 249, "compare_at_price": 299 }' PHP
$ch = curl_init('https://app.arabybot.com/store_api/v1/products/88/price');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer abst_YOUR_WRITE_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'price' => 249,
'compare_at_price' => 299,
]),
]);
$answer = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch); Python
import requests
r = requests.post(
'https://app.arabybot.com/store_api/v1/products/88/price',
headers={
"Authorization": "Bearer abst_YOUR_WRITE_KEY",
},
json={
"price": 249,
"compare_at_price": 299,
},
timeout=30,
)
print(r.status_code, r.json()) Node.js
// Node.js 18+
const r = await fetch('https://app.arabybot.com/store_api/v1/products/88/price', {
method: 'POST',
headers: {"Authorization": "Bearer abst_YOUR_WRITE_KEY", "Content-Type": "application/json"},
body: JSON.stringify({
"price": 249,
"compare_at_price": 299
}),
});
console.log(r.status, await r.json());
The response
200
{ "ok": true, "product_id": 88, "variant_id": null, "price": 249.0, "compare_at_price": 299.0 } variant_idin the response is null when you changed the product's own price.
The refusals
Every refusal comes back as JSON with "ok": false and the code in error:
- 403
read_only_key: The key can read only; create a key with write access in the store settings. - 422
bad_price: The price is missing, not a number, negative or above the ceiling. - 404
not_found: No product with this id in the store, or the variant is not one of its own. - 401
unauthorized: The key is missing, wrong or revoked. - 402
store_plan_closed: The store plan has ended; renew it. - 429: More than 120 requests in a minute.
- 500
server_error: A failure on our side; try again.
The limits
120 requests a minute from one IP address; passing that returns status 429. A store can have up to five keys. A key sees only its own store, and the store's plan must be active.
All store API addresses · All APIs for developers
Frequently asked questions
How do I set a discount that shows in the store?
Send the discounted price in price and the original price in compare_at_price. The original price is kept only if it is greater than the new price.
Can I change one size's price without the others?
Yes. Send its id in variant_id, and only its price changes.
Read next
Try the agent before you pay anything
The agent that will answer your customers is the one answering you now: ask it from the chat button here or on WhatsApp. Your account is free with no credit card, and the free trial on your own number or page is activated after you contact our team on customer-service WhatsApp.