Advanced Billing
Generate Advance Invoice
Generate an advance invoice covering one or more future billing periods.
POST
/
v1
/
subscriptions
/
{id}
/
advance
Generate an advance invoice
curl --request POST \
--url https://billing.example.com/v1/subscriptions/{id}/advance \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"periods": 2
}'import requests
url = "https://billing.example.com/v1/subscriptions/{id}/advance"
payload = { "periods": 2 }
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({periods: 2})
};
fetch('https://billing.example.com/v1/subscriptions/{id}/advance', 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}/advance",
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([
'periods' => 2
]),
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/subscriptions/{id}/advance"
payload := strings.NewReader("{\n \"periods\": 2\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://billing.example.com/v1/subscriptions/{id}/advance")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"periods\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/subscriptions/{id}/advance")
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 \"periods\": 2\n}"
response = http.request(request)
puts response.read_body{
"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>"
}
}Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The unique identifier of the subscription (e.g., sub_3jF6RtKmWp). |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
periods | int | Yes | The number of future billing periods to invoice in advance. Minimum value is 1. |
type: "advance" and is immediately finalized.
Example Request
curl -X POST https://api.recurso.io/v1/subscriptions/sub_3jF6RtKmWp/advance \
-H "Authorization: Bearer sk_live_26PHem9AhJZvU..." \
-H "Content-Type: application/json" \
-d '{
"periods": 3
}'
Response
{
"id": "inv_8xLpJnRtKw",
"object": "invoice",
"type": "advance",
"status": "open",
"currency": "usd",
"customer": {
"id": "cus_8vTnRbWqYx",
"name": "Acme Corp"
},
"subscription_id": "sub_3jF6RtKmWp",
"line_items": [
{
"id": "li_3nQ7RwYsKt",
"description": "Pro Plan — Jul 10 to Aug 10, 2026",
"amount": 4900
},
{
"id": "li_4pR8TxZtLu",
"description": "Pro Plan — Aug 10 to Sep 10, 2026",
"amount": 4900
},
{
"id": "li_5qS9UyAvMv",
"description": "Pro Plan — Sep 10 to Oct 10, 2026",
"amount": 4900
}
],
"subtotal": 14700,
"tax": 1323,
"total": 16023,
"amount_due": 16023,
"amount_paid": 0,
"due_date": "2026-07-10T00:00:00Z",
"created_at": "2026-06-23T13:00:00Z",
"updated_at": "2026-06-23T13:00:00Z"
}
⌘I
Generate an advance invoice
curl --request POST \
--url https://billing.example.com/v1/subscriptions/{id}/advance \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"periods": 2
}'import requests
url = "https://billing.example.com/v1/subscriptions/{id}/advance"
payload = { "periods": 2 }
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({periods: 2})
};
fetch('https://billing.example.com/v1/subscriptions/{id}/advance', 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}/advance",
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([
'periods' => 2
]),
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/subscriptions/{id}/advance"
payload := strings.NewReader("{\n \"periods\": 2\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://billing.example.com/v1/subscriptions/{id}/advance")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"periods\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/subscriptions/{id}/advance")
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 \"periods\": 2\n}"
response = http.request(request)
puts response.read_body{
"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>"
}
}