Skip to main content
POST
/
subscriptions
/
{subscriptionId}
/
usage-events
/
Create usage events for a subscription
curl --request POST \
  --url https://provider.api.nadles.com/v0/subscriptions/{subscriptionId}/usage-events/ \
  --header 'Content-Type: application/json' \
  --header 'nadles-provider-key: <api-key>' \
  --data '
{
  "label": "<string>",
  "value": 123,
  "request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "timestamp": "2023-11-07T05:31:56Z",
  "metadata": {}
}
'
import requests

url = "https://provider.api.nadles.com/v0/subscriptions/{subscriptionId}/usage-events/"

payload = {
"label": "<string>",
"value": 123,
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"timestamp": "2023-11-07T05:31:56Z",
"metadata": {}
}
headers = {
"nadles-provider-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'nadles-provider-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
label: '<string>',
value: 123,
request_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
timestamp: '2023-11-07T05:31:56Z',
metadata: {}
})
};

fetch('https://provider.api.nadles.com/v0/subscriptions/{subscriptionId}/usage-events/', 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://provider.api.nadles.com/v0/subscriptions/{subscriptionId}/usage-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([
'label' => '<string>',
'value' => 123,
'request_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'timestamp' => '2023-11-07T05:31:56Z',
'metadata' => [

]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"nadles-provider-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://provider.api.nadles.com/v0/subscriptions/{subscriptionId}/usage-events/"

payload := strings.NewReader("{\n \"label\": \"<string>\",\n \"value\": 123,\n \"request_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {}\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("nadles-provider-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://provider.api.nadles.com/v0/subscriptions/{subscriptionId}/usage-events/")
.header("nadles-provider-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"label\": \"<string>\",\n \"value\": 123,\n \"request_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {}\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://provider.api.nadles.com/v0/subscriptions/{subscriptionId}/usage-events/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["nadles-provider-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"label\": \"<string>\",\n \"value\": 123,\n \"request_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {}\n}"

response = http.request(request)
puts response.read_body

Authorizations

nadles-provider-key
string
header
required

API key provided in the admin portal

Path Parameters

subscriptionId
string
required

The ID of the subscription.

Body

application/json
label
string
required

Billable metric label

value
integer<int64>
required
request_id
string<uuid> | null
timestamp
string<date-time> | null
metadata
object | null

Response

OK