cURL
curl --request POST \
--url https://api.valyx.com/billing/usage \
--header 'Content-Type: application/json' \
--header 'X-Valyx-Signature: <x-valyx-signature>' \
--data '
{
"buyerId": "buyer_12345",
"eventTimeStamp": 1755079200000,
"tags": {
"region": "US-East",
"plan": "Enterprise",
"feature": "premium_support"
},
"metrics": [
{
"usage_driver_id": "usage_driver_001",
"quantity": 42.5,
"count": 1
}
],
"usageReferenceId": "usage_ref_98765"
}
'import requests
url = "https://api.valyx.com/billing/usage"
payload = {
"buyerId": "buyer_12345",
"eventTimeStamp": 1755079200000,
"tags": {
"region": "US-East",
"plan": "Enterprise",
"feature": "premium_support"
},
"metrics": [
{
"usage_driver_id": "usage_driver_001",
"quantity": 42.5,
"count": 1
}
],
"usageReferenceId": "usage_ref_98765"
}
headers = {
"X-Valyx-Signature": "<x-valyx-signature>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Valyx-Signature': '<x-valyx-signature>', 'Content-Type': 'application/json'},
body: JSON.stringify({
buyerId: 'buyer_12345',
eventTimeStamp: 1755079200000,
tags: {region: 'US-East', plan: 'Enterprise', feature: 'premium_support'},
metrics: [{usage_driver_id: 'usage_driver_001', quantity: 42.5, count: 1}],
usageReferenceId: 'usage_ref_98765'
})
};
fetch('https://api.valyx.com/billing/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {'X-Valyx-Signature': '<x-valyx-signature>', 'Content-Type': 'application/json'},
body: JSON.stringify({
buyerId: 'buyer_12345',
eventTimeStamp: 1755079200000,
tags: {region: 'US-East', plan: 'Enterprise', feature: 'premium_support'},
metrics: [{usage_driver_id: 'usage_driver_001', quantity: 42.5, count: 1}],
usageReferenceId: 'usage_ref_98765'
})
};
fetch('https://api.valyx.com/billing/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.valyx.com/billing/usage"
payload := strings.NewReader("{\n \"buyerId\": \"buyer_12345\",\n \"eventTimeStamp\": 1755079200000,\n \"tags\": {\n \"region\": \"US-East\",\n \"plan\": \"Enterprise\",\n \"feature\": \"premium_support\"\n },\n \"metrics\": [\n {\n \"usage_driver_id\": \"usage_driver_001\",\n \"quantity\": 42.5,\n \"count\": 1\n }\n ],\n \"usageReferenceId\": \"usage_ref_98765\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Valyx-Signature", "<x-valyx-signature>")
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.valyx.com/billing/usage")
.header("X-Valyx-Signature", "<x-valyx-signature>")
.header("Content-Type", "application/json")
.body("{\n \"buyerId\": \"buyer_12345\",\n \"eventTimeStamp\": 1755079200000,\n \"tags\": {\n \"region\": \"US-East\",\n \"plan\": \"Enterprise\",\n \"feature\": \"premium_support\"\n },\n \"metrics\": [\n {\n \"usage_driver_id\": \"usage_driver_001\",\n \"quantity\": 42.5,\n \"count\": 1\n }\n ],\n \"usageReferenceId\": \"usage_ref_98765\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.valyx.com/billing/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([
'buyerId' => 'buyer_12345',
'eventTimeStamp' => 1755079200000,
'tags' => [
'region' => 'US-East',
'plan' => 'Enterprise',
'feature' => 'premium_support'
],
'metrics' => [
[
'usage_driver_id' => 'usage_driver_001',
'quantity' => 42.5,
'count' => 1
]
],
'usageReferenceId' => 'usage_ref_98765'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Valyx-Signature: <x-valyx-signature>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.valyx.com/billing/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Valyx-Signature"] = '<x-valyx-signature>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"buyerId\": \"buyer_12345\",\n \"eventTimeStamp\": 1755079200000,\n \"tags\": {\n \"region\": \"US-East\",\n \"plan\": \"Enterprise\",\n \"feature\": \"premium_support\"\n },\n \"metrics\": [\n {\n \"usage_driver_id\": \"usage_driver_001\",\n \"quantity\": 42.5,\n \"count\": 1\n }\n ],\n \"usageReferenceId\": \"usage_ref_98765\"\n}"
response = http.request(request)
puts response.read_bodyimport Foundation
let parameters = [
"buyerId": "buyer_12345",
"eventTimeStamp": 1755079200000,
"tags": [
"region": "US-East",
"plan": "Enterprise",
"feature": "premium_support"
],
"metrics": [
[
"usage_driver_id": "usage_driver_001",
"quantity": 42.5,
"count": 1
]
],
"usageReferenceId": "usage_ref_98765"
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://api.valyx.com/billing/usage")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"X-Valyx-Signature": "<x-valyx-signature>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"buyerId\": \"buyer_12345\",\n \"eventTimeStamp\": 1755079200000,\n \"tags\": {\n \"region\": \"US-East\",\n \"plan\": \"Enterprise\",\n \"feature\": \"premium_support\"\n },\n \"metrics\": [\n {\n \"usage_driver_id\": \"usage_driver_001\",\n \"quantity\": 42.5,\n \"count\": 1\n }\n ],\n \"usageReferenceId\": \"usage_ref_98765\"\n}")
val request = Request.Builder()
.url("https://api.valyx.com/billing/usage")
.post(body)
.addHeader("X-Valyx-Signature", "<x-valyx-signature>")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()using RestSharp;
var options = new RestClientOptions("https://api.valyx.com/billing/usage");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("X-Valyx-Signature", "<x-valyx-signature>");
request.AddJsonBody("{\n \"buyerId\": \"buyer_12345\",\n \"eventTimeStamp\": 1755079200000,\n \"tags\": {\n \"region\": \"US-East\",\n \"plan\": \"Enterprise\",\n \"feature\": \"premium_support\"\n },\n \"metrics\": [\n {\n \"usage_driver_id\": \"usage_driver_001\",\n \"quantity\": 42.5,\n \"count\": 1\n }\n ],\n \"usageReferenceId\": \"usage_ref_98765\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
false{
"error": "<string>",
"message": "<string>",
"data": {
"usagesAdded": [
{
"usageDriverId": "<string>",
"usageDriverName": "<string>",
"contractId": "<string>",
"value": 123
}
],
"errors": [
"<string>"
]
}
}APIs
Add Usage
POST
/
billing
/
usage
cURL
curl --request POST \
--url https://api.valyx.com/billing/usage \
--header 'Content-Type: application/json' \
--header 'X-Valyx-Signature: <x-valyx-signature>' \
--data '
{
"buyerId": "buyer_12345",
"eventTimeStamp": 1755079200000,
"tags": {
"region": "US-East",
"plan": "Enterprise",
"feature": "premium_support"
},
"metrics": [
{
"usage_driver_id": "usage_driver_001",
"quantity": 42.5,
"count": 1
}
],
"usageReferenceId": "usage_ref_98765"
}
'import requests
url = "https://api.valyx.com/billing/usage"
payload = {
"buyerId": "buyer_12345",
"eventTimeStamp": 1755079200000,
"tags": {
"region": "US-East",
"plan": "Enterprise",
"feature": "premium_support"
},
"metrics": [
{
"usage_driver_id": "usage_driver_001",
"quantity": 42.5,
"count": 1
}
],
"usageReferenceId": "usage_ref_98765"
}
headers = {
"X-Valyx-Signature": "<x-valyx-signature>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Valyx-Signature': '<x-valyx-signature>', 'Content-Type': 'application/json'},
body: JSON.stringify({
buyerId: 'buyer_12345',
eventTimeStamp: 1755079200000,
tags: {region: 'US-East', plan: 'Enterprise', feature: 'premium_support'},
metrics: [{usage_driver_id: 'usage_driver_001', quantity: 42.5, count: 1}],
usageReferenceId: 'usage_ref_98765'
})
};
fetch('https://api.valyx.com/billing/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {'X-Valyx-Signature': '<x-valyx-signature>', 'Content-Type': 'application/json'},
body: JSON.stringify({
buyerId: 'buyer_12345',
eventTimeStamp: 1755079200000,
tags: {region: 'US-East', plan: 'Enterprise', feature: 'premium_support'},
metrics: [{usage_driver_id: 'usage_driver_001', quantity: 42.5, count: 1}],
usageReferenceId: 'usage_ref_98765'
})
};
fetch('https://api.valyx.com/billing/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.valyx.com/billing/usage"
payload := strings.NewReader("{\n \"buyerId\": \"buyer_12345\",\n \"eventTimeStamp\": 1755079200000,\n \"tags\": {\n \"region\": \"US-East\",\n \"plan\": \"Enterprise\",\n \"feature\": \"premium_support\"\n },\n \"metrics\": [\n {\n \"usage_driver_id\": \"usage_driver_001\",\n \"quantity\": 42.5,\n \"count\": 1\n }\n ],\n \"usageReferenceId\": \"usage_ref_98765\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Valyx-Signature", "<x-valyx-signature>")
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.valyx.com/billing/usage")
.header("X-Valyx-Signature", "<x-valyx-signature>")
.header("Content-Type", "application/json")
.body("{\n \"buyerId\": \"buyer_12345\",\n \"eventTimeStamp\": 1755079200000,\n \"tags\": {\n \"region\": \"US-East\",\n \"plan\": \"Enterprise\",\n \"feature\": \"premium_support\"\n },\n \"metrics\": [\n {\n \"usage_driver_id\": \"usage_driver_001\",\n \"quantity\": 42.5,\n \"count\": 1\n }\n ],\n \"usageReferenceId\": \"usage_ref_98765\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.valyx.com/billing/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([
'buyerId' => 'buyer_12345',
'eventTimeStamp' => 1755079200000,
'tags' => [
'region' => 'US-East',
'plan' => 'Enterprise',
'feature' => 'premium_support'
],
'metrics' => [
[
'usage_driver_id' => 'usage_driver_001',
'quantity' => 42.5,
'count' => 1
]
],
'usageReferenceId' => 'usage_ref_98765'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Valyx-Signature: <x-valyx-signature>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.valyx.com/billing/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Valyx-Signature"] = '<x-valyx-signature>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"buyerId\": \"buyer_12345\",\n \"eventTimeStamp\": 1755079200000,\n \"tags\": {\n \"region\": \"US-East\",\n \"plan\": \"Enterprise\",\n \"feature\": \"premium_support\"\n },\n \"metrics\": [\n {\n \"usage_driver_id\": \"usage_driver_001\",\n \"quantity\": 42.5,\n \"count\": 1\n }\n ],\n \"usageReferenceId\": \"usage_ref_98765\"\n}"
response = http.request(request)
puts response.read_bodyimport Foundation
let parameters = [
"buyerId": "buyer_12345",
"eventTimeStamp": 1755079200000,
"tags": [
"region": "US-East",
"plan": "Enterprise",
"feature": "premium_support"
],
"metrics": [
[
"usage_driver_id": "usage_driver_001",
"quantity": 42.5,
"count": 1
]
],
"usageReferenceId": "usage_ref_98765"
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://api.valyx.com/billing/usage")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"X-Valyx-Signature": "<x-valyx-signature>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"buyerId\": \"buyer_12345\",\n \"eventTimeStamp\": 1755079200000,\n \"tags\": {\n \"region\": \"US-East\",\n \"plan\": \"Enterprise\",\n \"feature\": \"premium_support\"\n },\n \"metrics\": [\n {\n \"usage_driver_id\": \"usage_driver_001\",\n \"quantity\": 42.5,\n \"count\": 1\n }\n ],\n \"usageReferenceId\": \"usage_ref_98765\"\n}")
val request = Request.Builder()
.url("https://api.valyx.com/billing/usage")
.post(body)
.addHeader("X-Valyx-Signature", "<x-valyx-signature>")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()using RestSharp;
var options = new RestClientOptions("https://api.valyx.com/billing/usage");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("X-Valyx-Signature", "<x-valyx-signature>");
request.AddJsonBody("{\n \"buyerId\": \"buyer_12345\",\n \"eventTimeStamp\": 1755079200000,\n \"tags\": {\n \"region\": \"US-East\",\n \"plan\": \"Enterprise\",\n \"feature\": \"premium_support\"\n },\n \"metrics\": [\n {\n \"usage_driver_id\": \"usage_driver_001\",\n \"quantity\": 42.5,\n \"count\": 1\n }\n ],\n \"usageReferenceId\": \"usage_ref_98765\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
false{
"error": "<string>",
"message": "<string>",
"data": {
"usagesAdded": [
{
"usageDriverId": "<string>",
"usageDriverName": "<string>",
"contractId": "<string>",
"value": 123
}
],
"errors": [
"<string>"
]
}
}Headers
Auth key to authenticate the request
Body
application/json
Unique identifier of the buyer associated with this usage event
Example:
"buyer_12345"
Unix timestamp in milliseconds representing when the usage occurred
Example:
1755079200000
Custom key-value tags associated with this usage
Show child attributes
Show child attributes
Example:
{
"region": "US-East",
"plan": "Enterprise",
"feature": "premium_support"
}
List of usage metrics for this event
Show child attributes
Show child attributes
A unique reference ID for tracking this usage event across systems
Example:
"usage_ref_98765"
Identifier of the contract under which the usage is recorded
Example:
"contract_67890"
Optional unique ID for this usage event, useful for idempotency
Example:
"event_abc123"
Optional metadata for storing extra key-value information about the usage event.
Example:
{
"company_id": "3932",
"recon_date": "2025-05-06 00:00:00",
"company_name": "Reliance Europa Limited",
"old_bag_status": "Returned"
}
⌘I