Skip to main content
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"
          }
        ]
      }
    }
  ]
}
'
{
  "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

x-admin-api-key
string
required

The API key to access the admin API

Body

application/json
name
string
required
Example:

"Premium Plan"

code
string
required

Unique code for the plan

Example:

"iqraa_starter_monthly"

interval
enum<string>
required

Billing interval

Available options:
yearly,
monthly
Example:

"monthly"

currency
string
required

Currency code

Example:

"USD"

amount
number
required

Plan amount

Required range: x >= 0
Example:

99.99

trialPeriod
number

Trial period in days

Required range: x >= 0
Example:

14

gracePeriod
number

Grace period in days after subscription expiry

Required range: x >= 0
Example:

7

charges
object[]

Add multiple billable metrics in plan

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

name
string
required
Example:

"Premium Plan"

code
string
required

Unique code for the plan

Example:

"iqraa_starter_monthly"

interval
enum<string>
required

Billing interval

Available options:
yearly,
monthly
Example:

"monthly"

currency
string
required

Currency code

Example:

"USD"

amount
number
required

Plan amount

Required range: x >= 0
Example:

99.99

trialPeriod
number

Trial period in days

Required range: x >= 0
Example:

14

gracePeriod
number

Grace period in days after subscription expiry

Required range: x >= 0
Example:

7

charges
object[]

Add multiple billable metrics in plan

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"
}
]
}
}
]