Create a new plan
curl --request POST \
--url https://dev-billing-api.iqraa.ai/api/v1/api/v1/plans \
--header 'Content-Type: application/json' \
--header 'x-admin-api-key: <x-admin-api-key>' \
--data '
{
"name": "Premium Plan",
"code": "iqraa_starter_monthly",
"interval": "monthly",
"currency": "USD",
"amount": 99.99,
"trialPeriod": 14,
"gracePeriod": 7,
"charges": [
{
"billable_metric_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"charge_model": "volume",
"invoiceable": true,
"pay_in_advance": false,
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": 100,
"flat_amount": "0",
"per_unit_amount": "0"
},
{
"from_value": 101,
"to_value": null,
"flat_amount": "0",
"per_unit_amount": "0.5"
}
]
}
}
]
}
'import requests
url = "https://dev-billing-api.iqraa.ai/api/v1/api/v1/plans"
payload = {
"name": "Premium Plan",
"code": "iqraa_starter_monthly",
"interval": "monthly",
"currency": "USD",
"amount": 99.99,
"trialPeriod": 14,
"gracePeriod": 7,
"charges": [
{
"billable_metric_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"charge_model": "volume",
"invoiceable": True,
"pay_in_advance": False,
"properties": { "volume_ranges": [
{
"from_value": 0,
"to_value": 100,
"flat_amount": "0",
"per_unit_amount": "0"
},
{
"from_value": 101,
"to_value": None,
"flat_amount": "0",
"per_unit_amount": "0.5"
}
] }
}
]
}
headers = {
"x-admin-api-key": "<x-admin-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-admin-api-key': '<x-admin-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Premium Plan',
code: 'iqraa_starter_monthly',
interval: 'monthly',
currency: 'USD',
amount: 99.99,
trialPeriod: 14,
gracePeriod: 7,
charges: [
{
billable_metric_id: '1a901a90-1a90-1a90-1a90-1a901a901a94',
charge_model: 'volume',
invoiceable: true,
pay_in_advance: false,
properties: {
volume_ranges: [
{from_value: 0, to_value: 100, flat_amount: '0', per_unit_amount: '0'},
{from_value: 101, to_value: null, flat_amount: '0', per_unit_amount: '0.5'}
]
}
}
]
})
};
fetch('https://dev-billing-api.iqraa.ai/api/v1/api/v1/plans', 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://dev-billing-api.iqraa.ai/api/v1/api/v1/plans",
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([
'name' => 'Premium Plan',
'code' => 'iqraa_starter_monthly',
'interval' => 'monthly',
'currency' => 'USD',
'amount' => 99.99,
'trialPeriod' => 14,
'gracePeriod' => 7,
'charges' => [
[
'billable_metric_id' => '1a901a90-1a90-1a90-1a90-1a901a901a94',
'charge_model' => 'volume',
'invoiceable' => true,
'pay_in_advance' => false,
'properties' => [
'volume_ranges' => [
[
'from_value' => 0,
'to_value' => 100,
'flat_amount' => '0',
'per_unit_amount' => '0'
],
[
'from_value' => 101,
'to_value' => null,
'flat_amount' => '0',
'per_unit_amount' => '0.5'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-admin-api-key: <x-admin-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://dev-billing-api.iqraa.ai/api/v1/api/v1/plans"
payload := strings.NewReader("{\n \"name\": \"Premium Plan\",\n \"code\": \"iqraa_starter_monthly\",\n \"interval\": \"monthly\",\n \"currency\": \"USD\",\n \"amount\": 99.99,\n \"trialPeriod\": 14,\n \"gracePeriod\": 7,\n \"charges\": [\n {\n \"billable_metric_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a94\",\n \"charge_model\": \"volume\",\n \"invoiceable\": true,\n \"pay_in_advance\": false,\n \"properties\": {\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 100,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0\"\n },\n {\n \"from_value\": 101,\n \"to_value\": null,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-admin-api-key", "<x-admin-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://dev-billing-api.iqraa.ai/api/v1/api/v1/plans")
.header("x-admin-api-key", "<x-admin-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Premium Plan\",\n \"code\": \"iqraa_starter_monthly\",\n \"interval\": \"monthly\",\n \"currency\": \"USD\",\n \"amount\": 99.99,\n \"trialPeriod\": 14,\n \"gracePeriod\": 7,\n \"charges\": [\n {\n \"billable_metric_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a94\",\n \"charge_model\": \"volume\",\n \"invoiceable\": true,\n \"pay_in_advance\": false,\n \"properties\": {\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 100,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0\"\n },\n {\n \"from_value\": 101,\n \"to_value\": null,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dev-billing-api.iqraa.ai/api/v1/api/v1/plans")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-admin-api-key"] = '<x-admin-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Premium Plan\",\n \"code\": \"iqraa_starter_monthly\",\n \"interval\": \"monthly\",\n \"currency\": \"USD\",\n \"amount\": 99.99,\n \"trialPeriod\": 14,\n \"gracePeriod\": 7,\n \"charges\": [\n {\n \"billable_metric_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a94\",\n \"charge_model\": \"volume\",\n \"invoiceable\": true,\n \"pay_in_advance\": false,\n \"properties\": {\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 100,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0\"\n },\n {\n \"from_value\": 101,\n \"to_value\": null,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"name": "Premium Plan",
"code": "iqraa_starter_monthly",
"interval": "monthly",
"currency": "USD",
"amount": 99.99,
"trialPeriod": 14,
"gracePeriod": 7,
"charges": [
{
"billable_metric_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"charge_model": "volume",
"invoiceable": true,
"pay_in_advance": false,
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": 100,
"flat_amount": "0",
"per_unit_amount": "0"
},
{
"from_value": 101,
"to_value": null,
"flat_amount": "0",
"per_unit_amount": "0.5"
}
]
}
}
]
}Plans
Create a new plan
Create a new plan with the provided details. Note: This endpoint is restricted for internal use only.
POST
/
api
/
v1
/
plans
Create a new plan
curl --request POST \
--url https://dev-billing-api.iqraa.ai/api/v1/api/v1/plans \
--header 'Content-Type: application/json' \
--header 'x-admin-api-key: <x-admin-api-key>' \
--data '
{
"name": "Premium Plan",
"code": "iqraa_starter_monthly",
"interval": "monthly",
"currency": "USD",
"amount": 99.99,
"trialPeriod": 14,
"gracePeriod": 7,
"charges": [
{
"billable_metric_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"charge_model": "volume",
"invoiceable": true,
"pay_in_advance": false,
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": 100,
"flat_amount": "0",
"per_unit_amount": "0"
},
{
"from_value": 101,
"to_value": null,
"flat_amount": "0",
"per_unit_amount": "0.5"
}
]
}
}
]
}
'import requests
url = "https://dev-billing-api.iqraa.ai/api/v1/api/v1/plans"
payload = {
"name": "Premium Plan",
"code": "iqraa_starter_monthly",
"interval": "monthly",
"currency": "USD",
"amount": 99.99,
"trialPeriod": 14,
"gracePeriod": 7,
"charges": [
{
"billable_metric_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"charge_model": "volume",
"invoiceable": True,
"pay_in_advance": False,
"properties": { "volume_ranges": [
{
"from_value": 0,
"to_value": 100,
"flat_amount": "0",
"per_unit_amount": "0"
},
{
"from_value": 101,
"to_value": None,
"flat_amount": "0",
"per_unit_amount": "0.5"
}
] }
}
]
}
headers = {
"x-admin-api-key": "<x-admin-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-admin-api-key': '<x-admin-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Premium Plan',
code: 'iqraa_starter_monthly',
interval: 'monthly',
currency: 'USD',
amount: 99.99,
trialPeriod: 14,
gracePeriod: 7,
charges: [
{
billable_metric_id: '1a901a90-1a90-1a90-1a90-1a901a901a94',
charge_model: 'volume',
invoiceable: true,
pay_in_advance: false,
properties: {
volume_ranges: [
{from_value: 0, to_value: 100, flat_amount: '0', per_unit_amount: '0'},
{from_value: 101, to_value: null, flat_amount: '0', per_unit_amount: '0.5'}
]
}
}
]
})
};
fetch('https://dev-billing-api.iqraa.ai/api/v1/api/v1/plans', 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://dev-billing-api.iqraa.ai/api/v1/api/v1/plans",
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([
'name' => 'Premium Plan',
'code' => 'iqraa_starter_monthly',
'interval' => 'monthly',
'currency' => 'USD',
'amount' => 99.99,
'trialPeriod' => 14,
'gracePeriod' => 7,
'charges' => [
[
'billable_metric_id' => '1a901a90-1a90-1a90-1a90-1a901a901a94',
'charge_model' => 'volume',
'invoiceable' => true,
'pay_in_advance' => false,
'properties' => [
'volume_ranges' => [
[
'from_value' => 0,
'to_value' => 100,
'flat_amount' => '0',
'per_unit_amount' => '0'
],
[
'from_value' => 101,
'to_value' => null,
'flat_amount' => '0',
'per_unit_amount' => '0.5'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-admin-api-key: <x-admin-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://dev-billing-api.iqraa.ai/api/v1/api/v1/plans"
payload := strings.NewReader("{\n \"name\": \"Premium Plan\",\n \"code\": \"iqraa_starter_monthly\",\n \"interval\": \"monthly\",\n \"currency\": \"USD\",\n \"amount\": 99.99,\n \"trialPeriod\": 14,\n \"gracePeriod\": 7,\n \"charges\": [\n {\n \"billable_metric_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a94\",\n \"charge_model\": \"volume\",\n \"invoiceable\": true,\n \"pay_in_advance\": false,\n \"properties\": {\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 100,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0\"\n },\n {\n \"from_value\": 101,\n \"to_value\": null,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-admin-api-key", "<x-admin-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://dev-billing-api.iqraa.ai/api/v1/api/v1/plans")
.header("x-admin-api-key", "<x-admin-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Premium Plan\",\n \"code\": \"iqraa_starter_monthly\",\n \"interval\": \"monthly\",\n \"currency\": \"USD\",\n \"amount\": 99.99,\n \"trialPeriod\": 14,\n \"gracePeriod\": 7,\n \"charges\": [\n {\n \"billable_metric_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a94\",\n \"charge_model\": \"volume\",\n \"invoiceable\": true,\n \"pay_in_advance\": false,\n \"properties\": {\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 100,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0\"\n },\n {\n \"from_value\": 101,\n \"to_value\": null,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dev-billing-api.iqraa.ai/api/v1/api/v1/plans")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-admin-api-key"] = '<x-admin-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Premium Plan\",\n \"code\": \"iqraa_starter_monthly\",\n \"interval\": \"monthly\",\n \"currency\": \"USD\",\n \"amount\": 99.99,\n \"trialPeriod\": 14,\n \"gracePeriod\": 7,\n \"charges\": [\n {\n \"billable_metric_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a94\",\n \"charge_model\": \"volume\",\n \"invoiceable\": true,\n \"pay_in_advance\": false,\n \"properties\": {\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 100,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0\"\n },\n {\n \"from_value\": 101,\n \"to_value\": null,\n \"flat_amount\": \"0\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"name": "Premium Plan",
"code": "iqraa_starter_monthly",
"interval": "monthly",
"currency": "USD",
"amount": 99.99,
"trialPeriod": 14,
"gracePeriod": 7,
"charges": [
{
"billable_metric_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"charge_model": "volume",
"invoiceable": true,
"pay_in_advance": false,
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": 100,
"flat_amount": "0",
"per_unit_amount": "0"
},
{
"from_value": 101,
"to_value": null,
"flat_amount": "0",
"per_unit_amount": "0.5"
}
]
}
}
]
}Headers
The API key to access the admin API
Body
application/json
Example:
"Premium Plan"
Unique code for the plan
Example:
"iqraa_starter_monthly"
Billing interval
Available options:
yearly, monthly Example:
"monthly"
Currency code
Example:
"USD"
Plan amount
Required range:
x >= 0Example:
99.99
Trial period in days
Required range:
x >= 0Example:
14
Grace period in days after subscription expiry
Required range:
x >= 0Example:
7
Add multiple billable metrics in plan
Show child attributes
Show child attributes
Example:
[
{
"billable_metric_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"charge_model": "volume",
"invoiceable": true,
"pay_in_advance": false,
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": 100,
"flat_amount": "0",
"per_unit_amount": "0"
},
{
"from_value": 101,
"to_value": null,
"flat_amount": "0",
"per_unit_amount": "0.5"
}
]
}
}
]
Response
The plan has been successfully created
Example:
"Premium Plan"
Unique code for the plan
Example:
"iqraa_starter_monthly"
Billing interval
Available options:
yearly, monthly Example:
"monthly"
Currency code
Example:
"USD"
Plan amount
Required range:
x >= 0Example:
99.99
Trial period in days
Required range:
x >= 0Example:
14
Grace period in days after subscription expiry
Required range:
x >= 0Example:
7
Add multiple billable metrics in plan
Show child attributes
Show child attributes
Example:
[
{
"billable_metric_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"charge_model": "volume",
"invoiceable": true,
"pay_in_advance": false,
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": 100,
"flat_amount": "0",
"per_unit_amount": "0"
},
{
"from_value": 101,
"to_value": null,
"flat_amount": "0",
"per_unit_amount": "0.5"
}
]
}
}
]
⌘I