cURL
curl --request POST \
--url https://api.nozle.app/engine/api/v1/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"event": {
"code": "storage",
"transaction_id": "transaction_1234567890",
"external_subscription_id": "sub_1234567890",
"timestamp": "1651240791.123",
"precise_total_amount_cents": "1234.56",
"properties": {
"gb": 10
},
"external_customer_id": "cust_123"
}
}
'transaction_id = nozle.track(
"cust_123",
"api_calls",
{"tokens": 1200},
subscription_id="sub_123",
)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
event: {
code: 'storage',
transaction_id: 'transaction_1234567890',
external_subscription_id: 'sub_1234567890',
timestamp: '1651240791.123',
precise_total_amount_cents: '1234.56',
properties: {gb: 10},
external_customer_id: 'cust_123'
}
})
};
fetch('https://api.nozle.app/engine/api/v1/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));err := client.Track(ctx, nozle.TrackParams{
CustomerID: "cust_123",
SubscriptionID: "sub_123",
Event: "api_calls",
Metadata: map[string]any{"tokens": 1200},
})require 'uri'
require 'net/http'
url = URI("https://api.nozle.app/engine/api/v1/events")
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 \"event\": {\n \"code\": \"storage\",\n \"transaction_id\": \"transaction_1234567890\",\n \"external_subscription_id\": \"sub_1234567890\",\n \"timestamp\": \"1651240791.123\",\n \"precise_total_amount_cents\": \"1234.56\",\n \"properties\": {\n \"gb\": 10\n },\n \"external_customer_id\": \"cust_123\"\n }\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nozle.app/engine/api/v1/events",
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([
'event' => [
'code' => 'storage',
'transaction_id' => 'transaction_1234567890',
'external_subscription_id' => 'sub_1234567890',
'timestamp' => '1651240791.123',
'precise_total_amount_cents' => '1234.56',
'properties' => [
'gb' => 10
],
'external_customer_id' => 'cust_123'
]
]),
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;
}HttpResponse<String> response = Unirest.post("https://api.nozle.app/engine/api/v1/events")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"event\": {\n \"code\": \"storage\",\n \"transaction_id\": \"transaction_1234567890\",\n \"external_subscription_id\": \"sub_1234567890\",\n \"timestamp\": \"1651240791.123\",\n \"precise_total_amount_cents\": \"1234.56\",\n \"properties\": {\n \"gb\": 10\n },\n \"external_customer_id\": \"cust_123\"\n }\n}")
.asString();{
"event": {
"transaction_id": "transaction_1234567890",
"customer_id": null,
"code": "storage",
"timestamp": "2022-04-29T08:59:51.123Z",
"subscription_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_subscription_id": "sub_1234567890",
"nozle_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"precise_total_amount_cents": "1234.56",
"properties": {
"gb": 10
},
"created_at": "2022-04-29T08:59:51Z"
}
}Usage Events
Send usage events
This endpoint is used for transmitting usage measurement events to either a designated customer or a specific subscription.
POST
/
events
cURL
curl --request POST \
--url https://api.nozle.app/engine/api/v1/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"event": {
"code": "storage",
"transaction_id": "transaction_1234567890",
"external_subscription_id": "sub_1234567890",
"timestamp": "1651240791.123",
"precise_total_amount_cents": "1234.56",
"properties": {
"gb": 10
},
"external_customer_id": "cust_123"
}
}
'transaction_id = nozle.track(
"cust_123",
"api_calls",
{"tokens": 1200},
subscription_id="sub_123",
)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
event: {
code: 'storage',
transaction_id: 'transaction_1234567890',
external_subscription_id: 'sub_1234567890',
timestamp: '1651240791.123',
precise_total_amount_cents: '1234.56',
properties: {gb: 10},
external_customer_id: 'cust_123'
}
})
};
fetch('https://api.nozle.app/engine/api/v1/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));err := client.Track(ctx, nozle.TrackParams{
CustomerID: "cust_123",
SubscriptionID: "sub_123",
Event: "api_calls",
Metadata: map[string]any{"tokens": 1200},
})require 'uri'
require 'net/http'
url = URI("https://api.nozle.app/engine/api/v1/events")
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 \"event\": {\n \"code\": \"storage\",\n \"transaction_id\": \"transaction_1234567890\",\n \"external_subscription_id\": \"sub_1234567890\",\n \"timestamp\": \"1651240791.123\",\n \"precise_total_amount_cents\": \"1234.56\",\n \"properties\": {\n \"gb\": 10\n },\n \"external_customer_id\": \"cust_123\"\n }\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nozle.app/engine/api/v1/events",
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([
'event' => [
'code' => 'storage',
'transaction_id' => 'transaction_1234567890',
'external_subscription_id' => 'sub_1234567890',
'timestamp' => '1651240791.123',
'precise_total_amount_cents' => '1234.56',
'properties' => [
'gb' => 10
],
'external_customer_id' => 'cust_123'
]
]),
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;
}HttpResponse<String> response = Unirest.post("https://api.nozle.app/engine/api/v1/events")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"event\": {\n \"code\": \"storage\",\n \"transaction_id\": \"transaction_1234567890\",\n \"external_subscription_id\": \"sub_1234567890\",\n \"timestamp\": \"1651240791.123\",\n \"precise_total_amount_cents\": \"1234.56\",\n \"properties\": {\n \"gb\": 10\n },\n \"external_customer_id\": \"cust_123\"\n }\n}")
.asString();{
"event": {
"transaction_id": "transaction_1234567890",
"customer_id": null,
"code": "storage",
"timestamp": "2022-04-29T08:59:51.123Z",
"subscription_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_subscription_id": "sub_1234567890",
"nozle_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"precise_total_amount_cents": "1234.56",
"properties": {
"gb": 10
},
"created_at": "2022-04-29T08:59:51Z"
}
}