Update Listing Inventory
curl --request PUT \
--url https://api.treet-test.co/v1/listings/{id}/inventory \
--header 'Content-Type: application/json' \
--header 'X-Treet-Authentication-Key: <api-key>' \
--header 'X-Treet-Client-Id: <api-key>' \
--data '
{
"action": "SET_INVENTORY",
"oldInventory": 5,
"newInventory": 3
}
'import requests
url = "https://api.treet-test.co/v1/listings/{id}/inventory"
payload = {
"action": "SET_INVENTORY",
"oldInventory": 5,
"newInventory": 3
}
headers = {
"X-Treet-Client-Id": "<api-key>",
"X-Treet-Authentication-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'X-Treet-Client-Id': '<api-key>',
'X-Treet-Authentication-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({action: 'SET_INVENTORY', oldInventory: 5, newInventory: 3})
};
fetch('https://api.treet-test.co/v1/listings/{id}/inventory', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.treet-test.co/v1/listings/{id}/inventory",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'action' => 'SET_INVENTORY',
'oldInventory' => 5,
'newInventory' => 3
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Treet-Authentication-Key: <api-key>",
"X-Treet-Client-Id: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.treet-test.co/v1/listings/{id}/inventory"
payload := strings.NewReader("{\n \"action\": \"SET_INVENTORY\",\n \"oldInventory\": 5,\n \"newInventory\": 3\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-Treet-Client-Id", "<api-key>")
req.Header.Add("X-Treet-Authentication-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.treet-test.co/v1/listings/{id}/inventory")
.header("X-Treet-Client-Id", "<api-key>")
.header("X-Treet-Authentication-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"action\": \"SET_INVENTORY\",\n \"oldInventory\": 5,\n \"newInventory\": 3\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.treet-test.co/v1/listings/{id}/inventory")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-Treet-Client-Id"] = '<api-key>'
request["X-Treet-Authentication-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": \"SET_INVENTORY\",\n \"oldInventory\": 5,\n \"newInventory\": 3\n}"
response = http.request(request)
puts response.read_body{
"id": "550e8400-e29b-41d4-a716-446655440000",
"availableInventory": 3
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Listings API
Update Inventory
Updates the available inventory for a listing. Supports two actions: setting inventory to an exact value (SET_INVENTORY) or adjusting it by a delta (ADJUST_INVENTORY). If inventory reaches 0, the listing is automatically closed.
PUT
/
v1
/
listings
/
{id}
/
inventory
Update Listing Inventory
curl --request PUT \
--url https://api.treet-test.co/v1/listings/{id}/inventory \
--header 'Content-Type: application/json' \
--header 'X-Treet-Authentication-Key: <api-key>' \
--header 'X-Treet-Client-Id: <api-key>' \
--data '
{
"action": "SET_INVENTORY",
"oldInventory": 5,
"newInventory": 3
}
'import requests
url = "https://api.treet-test.co/v1/listings/{id}/inventory"
payload = {
"action": "SET_INVENTORY",
"oldInventory": 5,
"newInventory": 3
}
headers = {
"X-Treet-Client-Id": "<api-key>",
"X-Treet-Authentication-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'X-Treet-Client-Id': '<api-key>',
'X-Treet-Authentication-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({action: 'SET_INVENTORY', oldInventory: 5, newInventory: 3})
};
fetch('https://api.treet-test.co/v1/listings/{id}/inventory', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.treet-test.co/v1/listings/{id}/inventory",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'action' => 'SET_INVENTORY',
'oldInventory' => 5,
'newInventory' => 3
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Treet-Authentication-Key: <api-key>",
"X-Treet-Client-Id: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.treet-test.co/v1/listings/{id}/inventory"
payload := strings.NewReader("{\n \"action\": \"SET_INVENTORY\",\n \"oldInventory\": 5,\n \"newInventory\": 3\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-Treet-Client-Id", "<api-key>")
req.Header.Add("X-Treet-Authentication-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.treet-test.co/v1/listings/{id}/inventory")
.header("X-Treet-Client-Id", "<api-key>")
.header("X-Treet-Authentication-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"action\": \"SET_INVENTORY\",\n \"oldInventory\": 5,\n \"newInventory\": 3\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.treet-test.co/v1/listings/{id}/inventory")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-Treet-Client-Id"] = '<api-key>'
request["X-Treet-Authentication-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": \"SET_INVENTORY\",\n \"oldInventory\": 5,\n \"newInventory\": 3\n}"
response = http.request(request)
puts response.read_body{
"id": "550e8400-e29b-41d4-a716-446655440000",
"availableInventory": 3
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Path Parameters
The listing ID.
Body
application/json
Inventory update action
The inventory update operation to perform.
SET_INVENTORY— sets inventory to an exact value. RequiresoldInventoryandnewInventory.ADJUST_INVENTORY— adjusts inventory by a delta. RequiresinventoryAdjustment.
Available options:
SET_INVENTORY, ADJUST_INVENTORY The expected current inventory count. The update will only proceed if the listing's current inventory matches this value.
*Required if action is SET_INVENTORY
Required range:
x >= 0The inventory value to set.
*Required if action is SET_INVENTORY
Required range:
x >= 0The amount to add (positive) or subtract (negative) from the current inventory.
*Required if action is ADJUST_INVENTORY

