Preview studio offer margin
Requires margins:read. The preview uses server catalog and provider-cost evidence. Unknown or stale cost facts remain explicitly marked in cost_status and are never replaced with caller-supplied costs.
curl --request POST \
--url https://api.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sellable": {
"id": "<string>",
"quantity": 50,
"digital_configuration_id": "<string>",
"prepared_asset_assignment_ids": [
"<string>"
],
"variant_id": "<string>"
},
"event_id": "<string>",
"recipient": {
"athlete_event_entry_id": "<string>",
"guardian_id": "<string>"
}
}
'import requests
url = "https://api.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview"
payload = {
"sellable": {
"id": "<string>",
"quantity": 50,
"digital_configuration_id": "<string>",
"prepared_asset_assignment_ids": ["<string>"],
"variant_id": "<string>"
},
"event_id": "<string>",
"recipient": {
"athlete_event_entry_id": "<string>",
"guardian_id": "<string>"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sellable: {
id: '<string>',
quantity: 50,
digital_configuration_id: '<string>',
prepared_asset_assignment_ids: ['<string>'],
variant_id: '<string>'
},
event_id: '<string>',
recipient: {athlete_event_entry_id: '<string>', guardian_id: '<string>'}
})
};
fetch('https://api.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview', 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.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sellable' => [
'id' => '<string>',
'quantity' => 50,
'digital_configuration_id' => '<string>',
'prepared_asset_assignment_ids' => [
'<string>'
],
'variant_id' => '<string>'
],
'event_id' => '<string>',
'recipient' => [
'athlete_event_entry_id' => '<string>',
'guardian_id' => '<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.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview"
payload := strings.NewReader("{\n \"sellable\": {\n \"id\": \"<string>\",\n \"quantity\": 50,\n \"digital_configuration_id\": \"<string>\",\n \"prepared_asset_assignment_ids\": [\n \"<string>\"\n ],\n \"variant_id\": \"<string>\"\n },\n \"event_id\": \"<string>\",\n \"recipient\": {\n \"athlete_event_entry_id\": \"<string>\",\n \"guardian_id\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sellable\": {\n \"id\": \"<string>\",\n \"quantity\": 50,\n \"digital_configuration_id\": \"<string>\",\n \"prepared_asset_assignment_ids\": [\n \"<string>\"\n ],\n \"variant_id\": \"<string>\"\n },\n \"event_id\": \"<string>\",\n \"recipient\": {\n \"athlete_event_entry_id\": \"<string>\",\n \"guardian_id\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sellable\": {\n \"id\": \"<string>\",\n \"quantity\": 50,\n \"digital_configuration_id\": \"<string>\",\n \"prepared_asset_assignment_ids\": [\n \"<string>\"\n ],\n \"variant_id\": \"<string>\"\n },\n \"event_id\": \"<string>\",\n \"recipient\": {\n \"athlete_event_entry_id\": \"<string>\",\n \"guardian_id\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"cost_status": "verified",
"currency": "USD",
"generated_at": "2023-11-07T05:31:56Z",
"lines": [
{
"cost_status": "verified",
"normal_selling_cents": 1,
"quantity": 2,
"sellable_id": "<string>",
"contribution_cents": 123,
"contribution_percent": 123,
"discount_cents": 1,
"promo_selling_cents": 1,
"provider_cost_cents": 1
}
],
"normal_subtotal_cents": 1,
"offer_id": "<string>",
"revision": 123,
"contribution_cents": 123,
"contribution_percent": 123,
"discount_cents": 1,
"exclusions": [
"<string>"
],
"promo_subtotal_cents": 1
}{
"code": "<string>",
"docs_url": "<string>",
"error": "<string>",
"message": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"docs_url": "<string>",
"error": "<string>",
"message": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"docs_url": "<string>",
"error": "<string>",
"message": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"docs_url": "<string>",
"error": "<string>",
"message": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"docs_url": "<string>",
"error": "<string>",
"message": "<string>",
"request_id": "<string>"
}Authorizations
Batch Relay scoped API key or an anonymous Test Mode session. Scope names document required capabilities. Anonymous sessions are sandbox-only and do not authorize studio, event, billing, or Live Mode operations.
Headers
Untrusted optional analytics hint naming the calling client surface. It never affects authorization, routing, pricing, or behavior.
1 - 100Untrusted optional analytics hint naming the calling client version. It never affects authorization, routing, pricing, or behavior.
1 - 100Untrusted optional analytics hint naming the invocation mode. It never affects authorization, routing, pricing, or behavior.
1 - 100Path Parameters
Stable public studio ID beginning with stu_. The API never selects a studio implicitly; a local CLI profile name is not a studio ID.
5 - 256^stu_[A-Za-z0-9_-]+$Body
Response
Offer margin preview
verified, unknown, incomplete, stale "USD"Show child attributes
Show child attributes
x >= 0Omitted when any line promotion price is unknown.
x >= 0Omitted when any line promotion price is unknown.
x >= 0curl --request POST \
--url https://api.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sellable": {
"id": "<string>",
"quantity": 50,
"digital_configuration_id": "<string>",
"prepared_asset_assignment_ids": [
"<string>"
],
"variant_id": "<string>"
},
"event_id": "<string>",
"recipient": {
"athlete_event_entry_id": "<string>",
"guardian_id": "<string>"
}
}
'import requests
url = "https://api.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview"
payload = {
"sellable": {
"id": "<string>",
"quantity": 50,
"digital_configuration_id": "<string>",
"prepared_asset_assignment_ids": ["<string>"],
"variant_id": "<string>"
},
"event_id": "<string>",
"recipient": {
"athlete_event_entry_id": "<string>",
"guardian_id": "<string>"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sellable: {
id: '<string>',
quantity: 50,
digital_configuration_id: '<string>',
prepared_asset_assignment_ids: ['<string>'],
variant_id: '<string>'
},
event_id: '<string>',
recipient: {athlete_event_entry_id: '<string>', guardian_id: '<string>'}
})
};
fetch('https://api.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview', 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.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sellable' => [
'id' => '<string>',
'quantity' => 50,
'digital_configuration_id' => '<string>',
'prepared_asset_assignment_ids' => [
'<string>'
],
'variant_id' => '<string>'
],
'event_id' => '<string>',
'recipient' => [
'athlete_event_entry_id' => '<string>',
'guardian_id' => '<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.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview"
payload := strings.NewReader("{\n \"sellable\": {\n \"id\": \"<string>\",\n \"quantity\": 50,\n \"digital_configuration_id\": \"<string>\",\n \"prepared_asset_assignment_ids\": [\n \"<string>\"\n ],\n \"variant_id\": \"<string>\"\n },\n \"event_id\": \"<string>\",\n \"recipient\": {\n \"athlete_event_entry_id\": \"<string>\",\n \"guardian_id\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sellable\": {\n \"id\": \"<string>\",\n \"quantity\": 50,\n \"digital_configuration_id\": \"<string>\",\n \"prepared_asset_assignment_ids\": [\n \"<string>\"\n ],\n \"variant_id\": \"<string>\"\n },\n \"event_id\": \"<string>\",\n \"recipient\": {\n \"athlete_event_entry_id\": \"<string>\",\n \"guardian_id\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.batchrelay.com/v1/studios/{studio_id}/offers/{offer_id}/margin-preview")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sellable\": {\n \"id\": \"<string>\",\n \"quantity\": 50,\n \"digital_configuration_id\": \"<string>\",\n \"prepared_asset_assignment_ids\": [\n \"<string>\"\n ],\n \"variant_id\": \"<string>\"\n },\n \"event_id\": \"<string>\",\n \"recipient\": {\n \"athlete_event_entry_id\": \"<string>\",\n \"guardian_id\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"cost_status": "verified",
"currency": "USD",
"generated_at": "2023-11-07T05:31:56Z",
"lines": [
{
"cost_status": "verified",
"normal_selling_cents": 1,
"quantity": 2,
"sellable_id": "<string>",
"contribution_cents": 123,
"contribution_percent": 123,
"discount_cents": 1,
"promo_selling_cents": 1,
"provider_cost_cents": 1
}
],
"normal_subtotal_cents": 1,
"offer_id": "<string>",
"revision": 123,
"contribution_cents": 123,
"contribution_percent": 123,
"discount_cents": 1,
"exclusions": [
"<string>"
],
"promo_subtotal_cents": 1
}{
"code": "<string>",
"docs_url": "<string>",
"error": "<string>",
"message": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"docs_url": "<string>",
"error": "<string>",
"message": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"docs_url": "<string>",
"error": "<string>",
"message": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"docs_url": "<string>",
"error": "<string>",
"message": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"docs_url": "<string>",
"error": "<string>",
"message": "<string>",
"request_id": "<string>"
}