Advanced Billing
Bill Usage Now
Bill a subscription’s accrued usage immediately instead of waiting for the period close.
POST
/
v1
/
subscriptions
/
{id}
/
bill-usage
Generate an interim progressive-usage invoice
curl --request POST \
--url https://billing.example.com/v1/subscriptions/{id}/bill-usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://billing.example.com/v1/subscriptions/{id}/bill-usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://billing.example.com/v1/subscriptions/{id}/bill-usage', 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/subscriptions/{id}/bill-usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/subscriptions/{id}/bill-usage"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/subscriptions/{id}/bill-usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/subscriptions/{id}/bill-usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": null
}{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"subscription_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoice_number": "<string>",
"billing_reason": "<string>",
"amount_due": 123,
"amount_paid": 123,
"currency": "<string>",
"subtotal": 123,
"tax_amount": 123,
"total": 123,
"tax_regime": "gst",
"igst_amount": 123,
"cgst_amount": 123,
"sgst_amount": 123,
"hsn_code": "<string>",
"irn": "<string>",
"ack_no": "<string>",
"signed_qr_code": "<string>",
"e_invoice_status": "<string>",
"ack_date": "<string>",
"e_invoice_retry_count": 123,
"e_invoice_next_retry_at": "2023-11-07T05:31:56Z",
"e_invoice_error_message": "<string>",
"tds_amount": 123,
"status": "draft",
"created_at": "2023-11-07T05:31:56Z",
"due_date": "2023-11-07T05:31:56Z",
"paid_at": "2023-11-07T05:31:56Z",
"payment_terms": "<string>",
"exchange_rate": 123,
"base_currency_total": 123,
"base_currency": "<string>",
"next_retry_at": "2023-11-07T05:31:56Z",
"retry_count": 123,
"payment_wall_active": true,
"line_items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"hsn_code": "<string>",
"quantity": 123,
"unit_amount": 123,
"amount": 123,
"tax_rate": 123,
"cgst_amount": 123,
"sgst_amount": 123,
"igst_amount": 123,
"taxable_amount": 123,
"created_at": "2023-11-07T05:31:56Z"
}
]
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}Errors
| Status | Code | When | Fix |
|---|---|---|---|
| 400 | validation_failed | id is not a valid UUID. | Pass the subscription’s UUID. |
| 401 | unauthorized | API key missing or invalid (invalid_api_key), or a live/test mode mismatch (key_mode_mismatch). | Send Authorization: Bearer <api_key> with a key for the right mode. |
| 500 | internal_error | The subscription could not be loaded, or interim invoice generation failed. | Verify the subscription ID and retry; check that the subscription’s plan has usage charges. |
200 with "data": null is not an error — it means nothing is due (the subscription is not on progressive billing, or accrued usage is below the threshold).
See Errors for the error envelope and the full code taxonomy.⌘I
Generate an interim progressive-usage invoice
curl --request POST \
--url https://billing.example.com/v1/subscriptions/{id}/bill-usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://billing.example.com/v1/subscriptions/{id}/bill-usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://billing.example.com/v1/subscriptions/{id}/bill-usage', 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/subscriptions/{id}/bill-usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/subscriptions/{id}/bill-usage"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/subscriptions/{id}/bill-usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/subscriptions/{id}/bill-usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": null
}{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"subscription_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoice_number": "<string>",
"billing_reason": "<string>",
"amount_due": 123,
"amount_paid": 123,
"currency": "<string>",
"subtotal": 123,
"tax_amount": 123,
"total": 123,
"tax_regime": "gst",
"igst_amount": 123,
"cgst_amount": 123,
"sgst_amount": 123,
"hsn_code": "<string>",
"irn": "<string>",
"ack_no": "<string>",
"signed_qr_code": "<string>",
"e_invoice_status": "<string>",
"ack_date": "<string>",
"e_invoice_retry_count": 123,
"e_invoice_next_retry_at": "2023-11-07T05:31:56Z",
"e_invoice_error_message": "<string>",
"tds_amount": 123,
"status": "draft",
"created_at": "2023-11-07T05:31:56Z",
"due_date": "2023-11-07T05:31:56Z",
"paid_at": "2023-11-07T05:31:56Z",
"payment_terms": "<string>",
"exchange_rate": 123,
"base_currency_total": 123,
"base_currency": "<string>",
"next_retry_at": "2023-11-07T05:31:56Z",
"retry_count": 123,
"payment_wall_active": true,
"line_items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"hsn_code": "<string>",
"quantity": 123,
"unit_amount": 123,
"amount": 123,
"tax_rate": 123,
"cgst_amount": 123,
"sgst_amount": 123,
"igst_amount": 123,
"taxable_amount": 123,
"created_at": "2023-11-07T05:31:56Z"
}
]
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}