Record usage event
curl --request POST \
--url https://demo.onlinebillingform.com/api/v2/meter-event \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": 123,
"order_id": 123,
"name": "<string>",
"qty": 2,
"payload": {}
}
'import requests
url = "https://demo.onlinebillingform.com/api/v2/meter-event"
payload = {
"customer_id": 123,
"order_id": 123,
"name": "<string>",
"qty": 2,
"payload": {}
}
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({customer_id: 123, order_id: 123, name: '<string>', qty: 2, payload: {}})
};
fetch('https://demo.onlinebillingform.com/api/v2/meter-event', 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://demo.onlinebillingform.com/api/v2/meter-event",
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([
'customer_id' => 123,
'order_id' => 123,
'name' => '<string>',
'qty' => 2,
'payload' => [
]
]),
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://demo.onlinebillingform.com/api/v2/meter-event"
payload := strings.NewReader("{\n \"customer_id\": 123,\n \"order_id\": 123,\n \"name\": \"<string>\",\n \"qty\": 2,\n \"payload\": {}\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://demo.onlinebillingform.com/api/v2/meter-event")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": 123,\n \"order_id\": 123,\n \"name\": \"<string>\",\n \"qty\": 2,\n \"payload\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://demo.onlinebillingform.com/api/v2/meter-event")
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 \"customer_id\": 123,\n \"order_id\": 123,\n \"name\": \"<string>\",\n \"qty\": 2,\n \"payload\": {}\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": 481,
"metric": "Bandwidth",
"qty": 25,
"unit_price": "0.050000",
"billable_qty": 5,
"free_qty": 20,
"amount": 0.25,
"usage": {
"used": 105,
"remaining_free": 0,
"remaining_free_percent": 0,
"overage_qty": 5,
"billable_qty": 5,
"current_unbilled_amount": "0.2500",
"threshold": {
"level": "warning",
"threshold": 10,
"message": "Free usage is below 10%."
}
},
"meter": {
"id": 7,
"name": "Bandwidth",
"unit_label": "GB",
"included_allowance": 100,
"unit_price": "0.050000",
"usage": {
"used": 105,
"remaining_free": 0,
"remaining_free_percent": 0,
"overage_qty": 5,
"billable_qty": 5,
"current_unbilled_amount": "0.2500",
"threshold": {
"level": "warning",
"threshold": 10,
"message": "Free usage is below 10%."
}
}
},
"data": {
"resource_id": "server-123",
"source": "provisioning-system"
}
}
}Usage
Record usage event
Records bill-in-arrears usage for a configured package usage metric on a customer order. The authenticated API key must own the order, and name must match a usage metric configured on the order’s package.
POST
/
meter-event
Record usage event
curl --request POST \
--url https://demo.onlinebillingform.com/api/v2/meter-event \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": 123,
"order_id": 123,
"name": "<string>",
"qty": 2,
"payload": {}
}
'import requests
url = "https://demo.onlinebillingform.com/api/v2/meter-event"
payload = {
"customer_id": 123,
"order_id": 123,
"name": "<string>",
"qty": 2,
"payload": {}
}
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({customer_id: 123, order_id: 123, name: '<string>', qty: 2, payload: {}})
};
fetch('https://demo.onlinebillingform.com/api/v2/meter-event', 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://demo.onlinebillingform.com/api/v2/meter-event",
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([
'customer_id' => 123,
'order_id' => 123,
'name' => '<string>',
'qty' => 2,
'payload' => [
]
]),
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://demo.onlinebillingform.com/api/v2/meter-event"
payload := strings.NewReader("{\n \"customer_id\": 123,\n \"order_id\": 123,\n \"name\": \"<string>\",\n \"qty\": 2,\n \"payload\": {}\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://demo.onlinebillingform.com/api/v2/meter-event")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": 123,\n \"order_id\": 123,\n \"name\": \"<string>\",\n \"qty\": 2,\n \"payload\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://demo.onlinebillingform.com/api/v2/meter-event")
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 \"customer_id\": 123,\n \"order_id\": 123,\n \"name\": \"<string>\",\n \"qty\": 2,\n \"payload\": {}\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": 481,
"metric": "Bandwidth",
"qty": 25,
"unit_price": "0.050000",
"billable_qty": 5,
"free_qty": 20,
"amount": 0.25,
"usage": {
"used": 105,
"remaining_free": 0,
"remaining_free_percent": 0,
"overage_qty": 5,
"billable_qty": 5,
"current_unbilled_amount": "0.2500",
"threshold": {
"level": "warning",
"threshold": 10,
"message": "Free usage is below 10%."
}
},
"meter": {
"id": 7,
"name": "Bandwidth",
"unit_label": "GB",
"included_allowance": 100,
"unit_price": "0.050000",
"usage": {
"used": 105,
"remaining_free": 0,
"remaining_free_percent": 0,
"overage_qty": 5,
"billable_qty": 5,
"current_unbilled_amount": "0.2500",
"threshold": {
"level": "warning",
"threshold": 10,
"message": "Free usage is below 10%."
}
}
},
"data": {
"resource_id": "server-123",
"source": "provisioning-system"
}
}
}Authorizations
Use Authorization: Bearer <live_api_key>.
Body
application/jsonapplication/x-www-form-urlencoded
Customer ID that owns the order.
Order ID to record usage against.
Usage metric name configured on the order package.
Usage quantity to add. Must be at least 1.
Required range:
x >= 1Optional metadata stored with the usage event. Non-object values are wrapped by the API under value.
⌘I