curl --request POST \
--url https://api.salesbricks.com/api/v2/usage/ \
--header 'Content-Type: application/json' \
--header 'X-SALESBRICKS-KEY: <api-key>' \
--data '
{
"transaction_id": "tx-12345-abc",
"subscription_id": "550e8400-e29b-41d4-a716-446655440000",
"brick_id": "660e8400-e29b-41d4-a716-446655440001",
"value": 150,
"properties": {
"region": "us-west-2",
"tier": "premium"
},
"time": "2024-01-15T10:30:00Z"
}
'import requests
url = "https://api.salesbricks.com/api/v2/usage/"
payload = {
"transaction_id": "tx-12345-abc",
"subscription_id": "550e8400-e29b-41d4-a716-446655440000",
"brick_id": "660e8400-e29b-41d4-a716-446655440001",
"value": 150,
"properties": {
"region": "us-west-2",
"tier": "premium"
},
"time": "2024-01-15T10:30:00Z"
}
headers = {
"X-SALESBRICKS-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-SALESBRICKS-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
transaction_id: 'tx-12345-abc',
subscription_id: '550e8400-e29b-41d4-a716-446655440000',
brick_id: '660e8400-e29b-41d4-a716-446655440001',
value: 150,
properties: {region: 'us-west-2', tier: 'premium'},
time: '2024-01-15T10:30:00Z'
})
};
fetch('https://api.salesbricks.com/api/v2/usage/', 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.salesbricks.com/api/v2/usage/",
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([
'transaction_id' => 'tx-12345-abc',
'subscription_id' => '550e8400-e29b-41d4-a716-446655440000',
'brick_id' => '660e8400-e29b-41d4-a716-446655440001',
'value' => 150,
'properties' => [
'region' => 'us-west-2',
'tier' => 'premium'
],
'time' => '2024-01-15T10:30:00Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-SALESBRICKS-KEY: <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.salesbricks.com/api/v2/usage/"
payload := strings.NewReader("{\n \"transaction_id\": \"tx-12345-abc\",\n \"subscription_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"brick_id\": \"660e8400-e29b-41d4-a716-446655440001\",\n \"value\": 150,\n \"properties\": {\n \"region\": \"us-west-2\",\n \"tier\": \"premium\"\n },\n \"time\": \"2024-01-15T10:30:00Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-SALESBRICKS-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.post("https://api.salesbricks.com/api/v2/usage/")
.header("X-SALESBRICKS-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"transaction_id\": \"tx-12345-abc\",\n \"subscription_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"brick_id\": \"660e8400-e29b-41d4-a716-446655440001\",\n \"value\": 150,\n \"properties\": {\n \"region\": \"us-west-2\",\n \"tier\": \"premium\"\n },\n \"time\": \"2024-01-15T10:30:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.salesbricks.com/api/v2/usage/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-SALESBRICKS-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"transaction_id\": \"tx-12345-abc\",\n \"subscription_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"brick_id\": \"660e8400-e29b-41d4-a716-446655440001\",\n \"value\": 150,\n \"properties\": {\n \"region\": \"us-west-2\",\n \"tier\": \"premium\"\n },\n \"time\": \"2024-01-15T10:30:00Z\"\n}"
response = http.request(request)
puts response.read_bodyCreate a usage entry
Submits a usage entry for a subscription’s metered brick. Each entry must have a unique transaction_id to prevent duplicates. The usage is reflected in the next billing cycle.
Which order receives the usage. A subscription is a chain of orders (the original, then any upgrade, recast or renewal). Each order runs from its start date to its end date inclusive, as calendar dates in the subscription’s time zone. The entry’s time is converted to that time zone, and its calendar date must fall within a closed order of the subscription that has not been terminated; the usage is attributed to that order. If more than one order covers the date, the latest agreement receives it. The brick_id must be sold on that order in the phase covering the date.
A time that falls on no order’s dates, or a brick_id that is not on the order for that date, returns 400. Backdated entries are accepted as long as the date falls within an order.
curl --request POST \
--url https://api.salesbricks.com/api/v2/usage/ \
--header 'Content-Type: application/json' \
--header 'X-SALESBRICKS-KEY: <api-key>' \
--data '
{
"transaction_id": "tx-12345-abc",
"subscription_id": "550e8400-e29b-41d4-a716-446655440000",
"brick_id": "660e8400-e29b-41d4-a716-446655440001",
"value": 150,
"properties": {
"region": "us-west-2",
"tier": "premium"
},
"time": "2024-01-15T10:30:00Z"
}
'import requests
url = "https://api.salesbricks.com/api/v2/usage/"
payload = {
"transaction_id": "tx-12345-abc",
"subscription_id": "550e8400-e29b-41d4-a716-446655440000",
"brick_id": "660e8400-e29b-41d4-a716-446655440001",
"value": 150,
"properties": {
"region": "us-west-2",
"tier": "premium"
},
"time": "2024-01-15T10:30:00Z"
}
headers = {
"X-SALESBRICKS-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-SALESBRICKS-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
transaction_id: 'tx-12345-abc',
subscription_id: '550e8400-e29b-41d4-a716-446655440000',
brick_id: '660e8400-e29b-41d4-a716-446655440001',
value: 150,
properties: {region: 'us-west-2', tier: 'premium'},
time: '2024-01-15T10:30:00Z'
})
};
fetch('https://api.salesbricks.com/api/v2/usage/', 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.salesbricks.com/api/v2/usage/",
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([
'transaction_id' => 'tx-12345-abc',
'subscription_id' => '550e8400-e29b-41d4-a716-446655440000',
'brick_id' => '660e8400-e29b-41d4-a716-446655440001',
'value' => 150,
'properties' => [
'region' => 'us-west-2',
'tier' => 'premium'
],
'time' => '2024-01-15T10:30:00Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-SALESBRICKS-KEY: <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.salesbricks.com/api/v2/usage/"
payload := strings.NewReader("{\n \"transaction_id\": \"tx-12345-abc\",\n \"subscription_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"brick_id\": \"660e8400-e29b-41d4-a716-446655440001\",\n \"value\": 150,\n \"properties\": {\n \"region\": \"us-west-2\",\n \"tier\": \"premium\"\n },\n \"time\": \"2024-01-15T10:30:00Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-SALESBRICKS-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.post("https://api.salesbricks.com/api/v2/usage/")
.header("X-SALESBRICKS-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"transaction_id\": \"tx-12345-abc\",\n \"subscription_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"brick_id\": \"660e8400-e29b-41d4-a716-446655440001\",\n \"value\": 150,\n \"properties\": {\n \"region\": \"us-west-2\",\n \"tier\": \"premium\"\n },\n \"time\": \"2024-01-15T10:30:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.salesbricks.com/api/v2/usage/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-SALESBRICKS-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"transaction_id\": \"tx-12345-abc\",\n \"subscription_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"brick_id\": \"660e8400-e29b-41d4-a716-446655440001\",\n \"value\": 150,\n \"properties\": {\n \"region\": \"us-west-2\",\n \"tier\": \"premium\"\n },\n \"time\": \"2024-01-15T10:30:00Z\"\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
API key for authentication
Body
Request serializer for creating a usage entry.
A unique identifier for this usage entry. Used to prevent duplicate entries and for later updates/deletes.
255The ID of the subscription this usage entry belongs to.
The ID of the metered brick this usage is for.
The usage value to record (e.g., number of API calls, GB used).
^-?\d{0,14}(?:\.\d{0,6})?$When the usage occurred, as an ISO 8601 date-time. Include the UTC offset, e.g. 2024-01-15T10:30:00Z or 2024-01-15T02:30:00-08:00; a value without one is read as UTC. The entry is stored in UTC. Its calendar date in the subscription's time zone decides which order of the subscription receives it (see the endpoint description).
Deprecated: Use 'value' instead.
^-?\d{0,14}(?:\.\d{0,6})?$Optional JSON object with additional properties for this usage entry.