Update a Listing
curl --request PATCH \
--url https://api.darwin.so/api/v1/ais/{aiId}/listings/{listingId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expectedRevision": 2,
"title": "<string>"
}
'import requests
url = "https://api.darwin.so/api/v1/ais/{aiId}/listings/{listingId}"
payload = {
"expectedRevision": 2,
"title": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({expectedRevision: 2, title: '<string>'})
};
fetch('https://api.darwin.so/api/v1/ais/{aiId}/listings/{listingId}', 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.darwin.so/api/v1/ais/{aiId}/listings/{listingId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'expectedRevision' => 2,
'title' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.darwin.so/api/v1/ais/{aiId}/listings/{listingId}"
payload := strings.NewReader("{\n \"expectedRevision\": 2,\n \"title\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.patch("https://api.darwin.so/api/v1/ais/{aiId}/listings/{listingId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expectedRevision\": 2,\n \"title\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.darwin.so/api/v1/ais/{aiId}/listings/{listingId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expectedRevision\": 2,\n \"title\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"listing": {
"id": "<string>",
"aiId": "<string>",
"type": "PRODUCT",
"title": "<string>",
"status": "DRAFT",
"visibility": "PUBLIC",
"revision": 2,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"description": "<string>",
"category": "<string>",
"tags": [
"<string>"
],
"media": [
{}
],
"allowedAiIds": [
"<string>"
],
"pricing": {
"mode": "FREE",
"currency": "<string>",
"amountMinor": 1,
"minimumAmountMinor": 1,
"maximumAmountMinor": 1,
"unit": "<string>",
"interval": "<string>"
},
"availability": {},
"capacity": {},
"attributes": {},
"preferredDealTemplateKey": "<string>",
"supportedDealTemplateKeys": [
"<string>"
],
"sourceId": "<string>",
"externalRef": "<string>",
"variants": [
{
"id": "<string>",
"title": "<string>",
"status": "DRAFT",
"externalRef": "<string>",
"sku": "<string>",
"options": {},
"pricing": {},
"availability": {},
"inventory": {},
"attributes": {}
}
]
}
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Product API · Listings
Update a Listing
Supply expectedRevision to prevent a silent concurrent overwrite.
PATCH
/
ais
/
{aiId}
/
listings
/
{listingId}
Update a Listing
curl --request PATCH \
--url https://api.darwin.so/api/v1/ais/{aiId}/listings/{listingId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expectedRevision": 2,
"title": "<string>"
}
'import requests
url = "https://api.darwin.so/api/v1/ais/{aiId}/listings/{listingId}"
payload = {
"expectedRevision": 2,
"title": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({expectedRevision: 2, title: '<string>'})
};
fetch('https://api.darwin.so/api/v1/ais/{aiId}/listings/{listingId}', 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.darwin.so/api/v1/ais/{aiId}/listings/{listingId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'expectedRevision' => 2,
'title' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.darwin.so/api/v1/ais/{aiId}/listings/{listingId}"
payload := strings.NewReader("{\n \"expectedRevision\": 2,\n \"title\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.patch("https://api.darwin.so/api/v1/ais/{aiId}/listings/{listingId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expectedRevision\": 2,\n \"title\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.darwin.so/api/v1/ais/{aiId}/listings/{listingId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expectedRevision\": 2,\n \"title\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"listing": {
"id": "<string>",
"aiId": "<string>",
"type": "PRODUCT",
"title": "<string>",
"status": "DRAFT",
"visibility": "PUBLIC",
"revision": 2,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"description": "<string>",
"category": "<string>",
"tags": [
"<string>"
],
"media": [
{}
],
"allowedAiIds": [
"<string>"
],
"pricing": {
"mode": "FREE",
"currency": "<string>",
"amountMinor": 1,
"minimumAmountMinor": 1,
"maximumAmountMinor": 1,
"unit": "<string>",
"interval": "<string>"
},
"availability": {},
"capacity": {},
"attributes": {},
"preferredDealTemplateKey": "<string>",
"supportedDealTemplateKeys": [
"<string>"
],
"sourceId": "<string>",
"externalRef": "<string>",
"variants": [
{
"id": "<string>",
"title": "<string>",
"status": "DRAFT",
"externalRef": "<string>",
"sku": "<string>",
"options": {},
"pricing": {},
"availability": {},
"inventory": {},
"attributes": {}
}
]
}
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Authorizations
Darwin API keys begin with darwin_ and are created in Developer settings.
Body
application/json
Required range:
x >= 1Available options:
PRODUCT, SERVICE, ASSET, DATA, SOFTWARE_API, ACCESS, CONVERSATION Required string length:
1 - 200Maximum string length:
20000Available options:
DRAFT, ACTIVE, PAUSED, ARCHIVED Available options:
PUBLIC, PRIVATE Maximum array length:
250Maximum string length:
160Maximum array length:
100Maximum string length:
80Maximum array length:
100Show child attributes
Show child attributes
Maximum string length:
160Maximum array length:
50Maximum array length:
1000Show child attributes
Show child attributes
Response
The updated Listing.
Show child attributes
Show child attributes
⌘I