Create a new usage entry
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": "12345",
"subscription_id": "00000000-0000-0000-0000-000000000000",
"brick_id": "00000000-0000-0000-0000-000000000000",
"value": 1,
"properties": {
"source": "api",
"notes": "This is a test entry",
"region": "US"
},
"time": "2024-09-16T10:15:30Z"
}
'import requests
url = "https://api.salesbricks.com/api/v2/usage"
payload = {
"transaction_id": "12345",
"subscription_id": "00000000-0000-0000-0000-000000000000",
"brick_id": "00000000-0000-0000-0000-000000000000",
"value": 1,
"properties": {
"source": "api",
"notes": "This is a test entry",
"region": "US"
},
"time": "2024-09-16T10:15:30Z"
}
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: '12345',
subscription_id: '00000000-0000-0000-0000-000000000000',
brick_id: '00000000-0000-0000-0000-000000000000',
value: 1,
properties: {source: 'api', notes: 'This is a test entry', region: 'US'},
time: '2024-09-16T10:15:30Z'
})
};
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' => '12345',
'subscription_id' => '00000000-0000-0000-0000-000000000000',
'brick_id' => '00000000-0000-0000-0000-000000000000',
'value' => 1,
'properties' => [
'source' => 'api',
'notes' => 'This is a test entry',
'region' => 'US'
],
'time' => '2024-09-16T10:15:30Z'
]),
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\": \"12345\",\n \"subscription_id\": \"00000000-0000-0000-0000-000000000000\",\n \"brick_id\": \"00000000-0000-0000-0000-000000000000\",\n \"value\": 1,\n \"properties\": {\n \"source\": \"api\",\n \"notes\": \"This is a test entry\",\n \"region\": \"US\"\n },\n \"time\": \"2024-09-16T10:15:30Z\"\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\": \"12345\",\n \"subscription_id\": \"00000000-0000-0000-0000-000000000000\",\n \"brick_id\": \"00000000-0000-0000-0000-000000000000\",\n \"value\": 1,\n \"properties\": {\n \"source\": \"api\",\n \"notes\": \"This is a test entry\",\n \"region\": \"US\"\n },\n \"time\": \"2024-09-16T10:15:30Z\"\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\": \"12345\",\n \"subscription_id\": \"00000000-0000-0000-0000-000000000000\",\n \"brick_id\": \"00000000-0000-0000-0000-000000000000\",\n \"value\": 1,\n \"properties\": {\n \"source\": \"api\",\n \"notes\": \"This is a test entry\",\n \"region\": \"US\"\n },\n \"time\": \"2024-09-16T10:15:30Z\"\n}"
response = http.request(request)
puts response.read_body{
"message": "Usage entry submitted successfully."
}Usage
Submit a usage entry
Use this API to increment a final value counter for a customer.
POST
/
usage
Create a new usage entry
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": "12345",
"subscription_id": "00000000-0000-0000-0000-000000000000",
"brick_id": "00000000-0000-0000-0000-000000000000",
"value": 1,
"properties": {
"source": "api",
"notes": "This is a test entry",
"region": "US"
},
"time": "2024-09-16T10:15:30Z"
}
'import requests
url = "https://api.salesbricks.com/api/v2/usage"
payload = {
"transaction_id": "12345",
"subscription_id": "00000000-0000-0000-0000-000000000000",
"brick_id": "00000000-0000-0000-0000-000000000000",
"value": 1,
"properties": {
"source": "api",
"notes": "This is a test entry",
"region": "US"
},
"time": "2024-09-16T10:15:30Z"
}
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: '12345',
subscription_id: '00000000-0000-0000-0000-000000000000',
brick_id: '00000000-0000-0000-0000-000000000000',
value: 1,
properties: {source: 'api', notes: 'This is a test entry', region: 'US'},
time: '2024-09-16T10:15:30Z'
})
};
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' => '12345',
'subscription_id' => '00000000-0000-0000-0000-000000000000',
'brick_id' => '00000000-0000-0000-0000-000000000000',
'value' => 1,
'properties' => [
'source' => 'api',
'notes' => 'This is a test entry',
'region' => 'US'
],
'time' => '2024-09-16T10:15:30Z'
]),
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\": \"12345\",\n \"subscription_id\": \"00000000-0000-0000-0000-000000000000\",\n \"brick_id\": \"00000000-0000-0000-0000-000000000000\",\n \"value\": 1,\n \"properties\": {\n \"source\": \"api\",\n \"notes\": \"This is a test entry\",\n \"region\": \"US\"\n },\n \"time\": \"2024-09-16T10:15:30Z\"\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\": \"12345\",\n \"subscription_id\": \"00000000-0000-0000-0000-000000000000\",\n \"brick_id\": \"00000000-0000-0000-0000-000000000000\",\n \"value\": 1,\n \"properties\": {\n \"source\": \"api\",\n \"notes\": \"This is a test entry\",\n \"region\": \"US\"\n },\n \"time\": \"2024-09-16T10:15:30Z\"\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\": \"12345\",\n \"subscription_id\": \"00000000-0000-0000-0000-000000000000\",\n \"brick_id\": \"00000000-0000-0000-0000-000000000000\",\n \"value\": 1,\n \"properties\": {\n \"source\": \"api\",\n \"notes\": \"This is a test entry\",\n \"region\": \"US\"\n },\n \"time\": \"2024-09-16T10:15:30Z\"\n}"
response = http.request(request)
puts response.read_body{
"message": "Usage entry submitted successfully."
}To use this endpoint, ensure that you are using the
v2/usage API endpoint:https://api.salesbricks.com/api/v2/usageAuthorizations
Use your Salesbricks API key to authenticate requests.
Body
application/json
The unique identifier for this usage entry transaction.
Example:
"12345"
The UUID of the Salesbricks subscription associated with the customer.
Example:
"00000000-0000-0000-0000-000000000000"
The UUID of the associated Usage Brick.
Example:
"00000000-0000-0000-0000-000000000000"
The value to set for the Brick.
Example:
1
Additional properties for the usage entry.
Example:
{
"source": "api",
"notes": "This is a test entry",
"region": "US"
}
The timestamp indicating when the operation occurs in ISO 8601 format.
Example:
"2024-09-16T10:15:30Z"
Response
Usage entry created successfully.
Example:
"Usage entry submitted successfully."
⌘I