API reference · Products
Update variant stock by barcode
Updates the stock of the product found by Code and ProductSourceId, and the stock of its variants matched by barcode.
https://out.stockmount.com/api/Product/UpdateProductQuantityByBarcode
Each call updates a single product; you cannot send several products in one call. You can update several variants of that product in the same call with Variants.
The product is identified by Code + ProductSourceId, not by barcode; ProductId is ignored. The root-level Barcode field is not used. Barcodes are only used to match the variants in Variants.
Each item in Variants is matched to this product's variants by ProductVariantId, or by Barcode when no ID is given. A matched variant's stock is replaced by Quantity (0 if omitted). Variants not in the list are not touched.
The quantity you send replaces the product's available stock; the sold counter StockMount has kept so far is reset to zero. If the new product stock is below 1, the product's Status becomes 3, otherwise 2.
The product-level Quantity is written on every call. If you send only variant quantities without Quantity and do not set SetProductQuantityFromVariants to true, the product stock becomes 0. For products with variants, sending SetProductQuantityFromVariants: true is recommended.
Warning: although it is a stock endpoint, this endpoint overwrites the product's Price2–Price5 with the request values; if you omit them they become 0. If you use these prices, send their current values on every call. Price and MarketPrice are not changed.
CurrencyId is ignored by this endpoint; the product currency does not change.
Quantities are not validated; negative values are not rejected.
After every successful call, a stock update is queued for each active marketplace listing of the product (unless one of the same kind is already pending). Marketplaces are updated by background jobs, not during this call.
If the product is not found or does not belong to your account, the response is Result: false with ErrorCode: "70005" and ErrorMessage: "ProductNotFound". Database errors return ErrorCode 99999.
Accounts without an active Product package get error 70018; if the package cannot be verified, 99999 is returned.
Request fields
| Field | Type | Description |
|---|---|---|
ApiCode
required
|
string |
The API code returned by User/DoLogin.
|
Code
required
|
string |
Product code (SKU), up to 50 characters. The product is looked up by Code together with ProductSourceId. ProductId is ignored by this endpoint.
|
ProductSourceId
required
|
integer |
ID of the product source the product belongs to (GetProductSources). Code is looked up within this source.
|
Quantity
|
integer |
New stock quantity of the product. If omitted, 0 is written. Ignored when SetProductQuantityFromVariants is true and Variants has at least one item. Negative values are not rejected.
|
SetProductQuantityFromVariants
|
boolean |
If true, the product stock is computed as the sum of its variants: the new quantity for active variants in the list, the current available stock for all other variants (passive ones included). Has no effect when Variants is empty. Default false.
|
Price2
|
number |
Product additional price 2. Although this is a stock endpoint, it writes this field to the product; if omitted it becomes 0. Send the current value.
|
Price3
|
number |
Product additional price 3. Although this is a stock endpoint, it writes this field to the product; if omitted it becomes 0. Send the current value.
|
Price4
|
number |
Product additional price 4. Although this is a stock endpoint, it writes this field to the product; if omitted it becomes 0. Send the current value.
|
Price5
|
number |
Product additional price 5. Although this is a stock endpoint, it writes this field to the product; if omitted it becomes 0. Send the current value.
|
Variants
|
object[] | Variants to update. Only listed variants change; entries that do not match are skipped without an error. |
Variants[].
ProductVariantId
|
integer |
Variant ID. If omitted or 0, the variant is matched by Barcode.
|
Variants[].
Barcode
|
string |
Variant barcode. When ProductVariantId is not set, the variant is looked up by this barcode among this product's variants only. Leading and trailing spaces are trimmed.
|
Variants[].
Quantity
|
integer |
New stock quantity of the variant. If omitted, 0 is written. Negative values are not rejected.
|
Response fields (Response)
| Field | Type | Description |
|---|---|---|
ProductId
|
integer | ID of the updated product. |
Variants
|
object[] | Variants updated by this call. Empty array if you sent no variants. |
Variants[].
Code
|
string | Variant code. |
Variants[].
ProductVariantId
|
integer | Variant ID. |
Error codes for this endpoint
| Code | When |
|---|---|
70005 |
The product was not found or does not belong to your account (ErrorMessage: ProductNotFound). |
00003 |
Code is empty (ErrorMessage: "ProductId") or ProductSourceId is less than 1 (ErrorMessage: "ProductSourceId"). |
70018 |
Your account has no active Product package. |
99999 |
An unexpected server error occurred. |
For session errors (00001, 00006) and every other code see error codes.
Related endpoints
Example request
{
"ApiCode": "API_CODE",
"Code": "TSHIRT-RED",
"ProductSourceId": 3051,
"SetProductQuantityFromVariants": true,
"Price2": 329.9,
"Price3": 0,
"Price4": 0,
"Price5": 0,
"Variants": [
{
"Barcode": "8690000000017",
"Quantity": 15
},
{
"Barcode": "8690000000024",
"Quantity": 0
}
]
}
curl -X POST 'https://out.stockmount.com/api/Product/UpdateProductQuantityByBarcode' \
-H 'Content-Type: application/json' \
-d '{
"ApiCode": "API_CODE",
"Code": "TSHIRT-RED",
"ProductSourceId": 3051,
"SetProductQuantityFromVariants": true,
"Price2": 329.9,
"Price3": 0,
"Price4": 0,
"Price5": 0,
"Variants": [
{
"Barcode": "8690000000017",
"Quantity": 15
},
{
"Barcode": "8690000000024",
"Quantity": 0
}
]
}'
using System.Net.Http;
using System.Text;
using var http = new HttpClient();
var json = """
{
"ApiCode": "API_CODE",
"Code": "TSHIRT-RED",
"ProductSourceId": 3051,
"SetProductQuantityFromVariants": true,
"Price2": 329.9,
"Price3": 0,
"Price4": 0,
"Price5": 0,
"Variants": [
{
"Barcode": "8690000000017",
"Quantity": 15
},
{
"Barcode": "8690000000024",
"Quantity": 0
}
]
}
""";
var response = await http.PostAsync(
"https://out.stockmount.com/api/Product/UpdateProductQuantityByBarcode",
new StringContent(json, Encoding.UTF8, "application/json"));
var result = await response.Content.ReadAsStringAsync();
// Result == false ise ErrorCode ve ErrorMessage alanlarına bakın.
Console.WriteLine(result);
<?php
$body = <<<'JSON'
{
"ApiCode": "API_CODE",
"Code": "TSHIRT-RED",
"ProductSourceId": 3051,
"SetProductQuantityFromVariants": true,
"Price2": 329.9,
"Price3": 0,
"Price4": 0,
"Price5": 0,
"Variants": [
{
"Barcode": "8690000000017",
"Quantity": 15
},
{
"Barcode": "8690000000024",
"Quantity": 0
}
]
}
JSON;
$ch = curl_init('https://out.stockmount.com/api/Product/UpdateProductQuantityByBarcode');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!$result['Result']) {
echo $result['ErrorCode'] . ' ' . $result['ErrorMessage'];
}
import requests
payload = {
"ApiCode": "API_CODE",
"Code": "TSHIRT-RED",
"ProductSourceId": 3051,
"SetProductQuantityFromVariants": True,
"Price2": 329.9,
"Price3": 0,
"Price4": 0,
"Price5": 0,
"Variants": [
{
"Barcode": "8690000000017",
"Quantity": 15
},
{
"Barcode": "8690000000024",
"Quantity": 0
}
]
}
response = requests.post("https://out.stockmount.com/api/Product/UpdateProductQuantityByBarcode", json=payload, timeout=60)
result = response.json()
if not result["Result"]:
print(result["ErrorCode"], result["ErrorMessage"])
const payload = {
"ApiCode": "API_CODE",
"Code": "TSHIRT-RED",
"ProductSourceId": 3051,
"SetProductQuantityFromVariants": true,
"Price2": 329.9,
"Price3": 0,
"Price4": 0,
"Price5": 0,
"Variants": [
{
"Barcode": "8690000000017",
"Quantity": 15
},
{
"Barcode": "8690000000024",
"Quantity": 0
}
]
};
const response = await fetch("https://out.stockmount.com/api/Product/UpdateProductQuantityByBarcode", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
const result = await response.json();
if (!result.Result) {
console.error(result.ErrorCode, result.ErrorMessage);
}
Example response
{
"Result": true,
"Response": {
"ProductId": 184522,
"Variants": [
{
"Code": "TSHIRT-RED-M",
"ProductVariantId": 9120344
},
{
"Code": "TSHIRT-RED-L",
"ProductVariantId": 9120345
}
]
}
}
Try it
The request goes straight from your browser to out.stockmount.com. The ApiCode is not stored by this site; it is kept only while this tab is open.
Get an ApiCode before sending requests.
This endpoint changes real data in your account.
Recent requests
Requests sent from this tab; click one to load its body again.