Advanced Billing
Set Plan Charges
Replace the usage charges attached to a plan — one charge per billable metric, any of the seven charge models.
PUT
/
v1
/
plans
/
{id}
/
charges
Replace a plan's usage charge set
curl --request PUT \
--url https://billing.example.com/v1/plans/{id}/charges \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amounts": {},
"filter_key": "<string>",
"filters": [
{
"value": "<string>",
"amounts": {}
}
],
"pay_in_advance": true,
"hsn_code": "<string>"
}
]
'import requests
url = "https://billing.example.com/v1/plans/{id}/charges"
payload = [
{
"metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amounts": {},
"filter_key": "<string>",
"filters": [
{
"value": "<string>",
"amounts": {}
}
],
"pay_in_advance": True,
"hsn_code": "<string>"
}
]
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
metric_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
amounts: {},
filter_key: '<string>',
filters: [{value: '<string>', amounts: {}}],
pay_in_advance: true,
hsn_code: '<string>'
}
])
};
fetch('https://billing.example.com/v1/plans/{id}/charges', 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://billing.example.com/v1/plans/{id}/charges",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
[
'metric_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'amounts' => [
],
'filter_key' => '<string>',
'filters' => [
[
'value' => '<string>',
'amounts' => [
]
]
],
'pay_in_advance' => true,
'hsn_code' => '<string>'
]
]),
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://billing.example.com/v1/plans/{id}/charges"
payload := strings.NewReader("[\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amounts\": {},\n \"filter_key\": \"<string>\",\n \"filters\": [\n {\n \"value\": \"<string>\",\n \"amounts\": {}\n }\n ],\n \"pay_in_advance\": true,\n \"hsn_code\": \"<string>\"\n }\n]")
req, _ := http.NewRequest("PUT", 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.put("https://billing.example.com/v1/plans/{id}/charges")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("[\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amounts\": {},\n \"filter_key\": \"<string>\",\n \"filters\": [\n {\n \"value\": \"<string>\",\n \"amounts\": {}\n }\n ],\n \"pay_in_advance\": true,\n \"hsn_code\": \"<string>\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/plans/{id}/charges")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amounts\": {},\n \"filter_key\": \"<string>\",\n \"filters\": [\n {\n \"value\": \"<string>\",\n \"amounts\": {}\n }\n ],\n \"pay_in_advance\": true,\n \"hsn_code\": \"<string>\"\n }\n]"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"charge_model": "per_unit",
"amounts": {},
"filter_key": "<string>",
"filters": [
{
"value": "<string>",
"amounts": {}
}
],
"pay_in_advance": true,
"hsn_code": "<string>",
"metric": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"code": "<string>",
"aggregation_type": "count",
"field_name": "<string>",
"expression": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}
]
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Path Parameters
Body
application/json
Available options:
per_unit, graduated, volume, package, percentage, graduated_percentage, dynamic Show child attributes
Show child attributes
(A4) event property for dimensional pricing.
Show child attributes
Show child attributes
Non-cumulative models only (per_unit/percentage/dynamic).
Response
The stored charge set
Show child attributes
Show child attributes
⌘I
Replace a plan's usage charge set
curl --request PUT \
--url https://billing.example.com/v1/plans/{id}/charges \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amounts": {},
"filter_key": "<string>",
"filters": [
{
"value": "<string>",
"amounts": {}
}
],
"pay_in_advance": true,
"hsn_code": "<string>"
}
]
'import requests
url = "https://billing.example.com/v1/plans/{id}/charges"
payload = [
{
"metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amounts": {},
"filter_key": "<string>",
"filters": [
{
"value": "<string>",
"amounts": {}
}
],
"pay_in_advance": True,
"hsn_code": "<string>"
}
]
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
metric_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
amounts: {},
filter_key: '<string>',
filters: [{value: '<string>', amounts: {}}],
pay_in_advance: true,
hsn_code: '<string>'
}
])
};
fetch('https://billing.example.com/v1/plans/{id}/charges', 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://billing.example.com/v1/plans/{id}/charges",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
[
'metric_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'amounts' => [
],
'filter_key' => '<string>',
'filters' => [
[
'value' => '<string>',
'amounts' => [
]
]
],
'pay_in_advance' => true,
'hsn_code' => '<string>'
]
]),
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://billing.example.com/v1/plans/{id}/charges"
payload := strings.NewReader("[\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amounts\": {},\n \"filter_key\": \"<string>\",\n \"filters\": [\n {\n \"value\": \"<string>\",\n \"amounts\": {}\n }\n ],\n \"pay_in_advance\": true,\n \"hsn_code\": \"<string>\"\n }\n]")
req, _ := http.NewRequest("PUT", 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.put("https://billing.example.com/v1/plans/{id}/charges")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("[\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amounts\": {},\n \"filter_key\": \"<string>\",\n \"filters\": [\n {\n \"value\": \"<string>\",\n \"amounts\": {}\n }\n ],\n \"pay_in_advance\": true,\n \"hsn_code\": \"<string>\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/plans/{id}/charges")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amounts\": {},\n \"filter_key\": \"<string>\",\n \"filters\": [\n {\n \"value\": \"<string>\",\n \"amounts\": {}\n }\n ],\n \"pay_in_advance\": true,\n \"hsn_code\": \"<string>\"\n }\n]"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"charge_model": "per_unit",
"amounts": {},
"filter_key": "<string>",
"filters": [
{
"value": "<string>",
"amounts": {}
}
],
"pay_in_advance": true,
"hsn_code": "<string>",
"metric": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"code": "<string>",
"aggregation_type": "count",
"field_name": "<string>",
"expression": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}
]
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}