LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/plans" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"plan": {
"name": "Startup",
"code": "startup",
"interval": "monthly",
"description": null,
"amount_cents": 1000,
"amount_currency": "USD",
"invoice_display_name": "",
"trial_period": 10,
"pay_in_advance": true,
"bill_charges_monthly": null,
"tax_codes": ["french_standard_vat"],
"minimum_commitment": {
"amount_cents": 100000,
"invoice_display_name": "Minimum Commitment (C1)",
"taxes": []
},
"charges": [
{
"billable_metric_id": "__BILLABLE_METRIC_ID__",
"billable_metric_code": "api_request",
"charge_model": "graduated",
"invoiceable": true,
"pay_in_advance": false,
"prorated": false,
"min_amount_cents": 0,
"invoice_display_name": "New name on invoice 1",
"properties": {
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10000,
"per_unit_amount": "0.02",
"flat_amount": "50"
},
{
"from_value": 10001,
"to_value": null,
"per_unit_amount": "0.01",
"flat_amount": "100"
}
]
},
"tax_codes": []
},
{
"billable_metric_id": "__BILLABLE_METRIC_ID__",
"billable_metric_code": "requests",
"charge_model": "package",
"invoiceable": true,
"pay_in_advance": false,
"prorated": false,
"min_amount_cents": 0,
"invoice_display_name": "",
"properties": {
"amount": "30",
"free_units": 1000,
"package_size": 10000
},
"tax_codes": []
},
{
"billable_metric_id": "__BILLABLE_METRIC_ID__",
"billable_metric_code": "payments",
"charge_model": "percentage",
"invoiceable": true,
"pay_in_advance": false,
"prorated": false,
"min_amount_cents": 0,
"invoice_display_name": "New name on invoice 2",
"properties": {
"rate": "0.15",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500",
"per_transaction_min_amount": "1.75",
"per_transaction_max_amount": "2"
},
"tax_codes": []
},
{
"billable_metric_id": "__BILLABLE_METRIC_ID__",
"billable_metric_code": "seat",
"charge_model": "standard",
"invoiceable": true,
"pay_in_advance": false,
"prorated": false,
"min_amount_cents": 0,
"invoice_display_name": "",
"properties": {
"amount": "10"
},
"tax_codes": []
},
{
"billable_metric_id": "__BILLABLE_METRIC_ID__",
"billable_metric_code": "sms_sent",
"charge_model": "volume",
"invoiceable": true,
"pay_in_advance": false,
"prorated": false,
"min_amount_cents": 0,
"invoice_display_name": "",
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": 1000,
"per_unit_amount": "0.75",
"flat_amount": "0"
},
{
"from_value": 1001,
"to_value": null,
"per_unit_amount": "0.50",
"flat_amount": "0"
}
]
},
"tax_codes": []
},
{
"billable_metric_id": "__BILLABLE_METRIC_ID__",
"billable_metric_code": "api_request_groups",
"charge_model": "graduated",
"invoiceable": true,
"pay_in_advance": false,
"prorated": false,
"min_amount_cents": 0,
"invoice_display_name": "",
"properties": {
"graduated_ranges": [
{
"from_value": 0,
"to_value": null,
"per_unit_amount": "0",
"flat_amount": "0"
}
]
},
"filters": [
{
"values": {
"cloud": ["aws"],
"region": ["us-east-1"]
},
"properties": {
"graduated_ranges": [
{
"from_value": 0,
"to_value": 20000,
"per_unit_amount": "0.02",
"flat_amount": "50"
},
{
"from_value": 20001,
"to_value": null,
"per_unit_amount": "0.01",
"flat_amount": "100"
}
]
},
invoice_display_name: "Filter"
}
],
"tax_codes": []
},
{
"billable_metric_id": "__BILLABLE_METRIC_ID__",
"billable_metric_code": "request_groups",
"charge_model": "package",
"invoiceable": true,
"pay_in_advance": false,
"prorated": false,
"min_amount_cents": 0,
"properties": {
"amount": "0",
"free_units": 0,
"package_size": 1
},
"filters": [
{
"values": {
"cloud": ["aws"],
"region": ["us-east-1"]
},
"properties": {
"amount": "30",
"free_units": 1000,
"package_size": 10000
},
invoice_display_name: "Filter"
}
],
"tax_codes": []
},
{
"billable_metric_id": "__BILLABLE_METRIC_ID__",
"billable_metric_code": "payment_groups",
"charge_model": "percentage",
"invoiceable": true,
"pay_in_advance": false,
"prorated": false,
"min_amount_cents": 0,
"properties": {
"rate": "0"
},
"filters": [
{
"values": {
"cloud": ["aws"],
"region": ["us-east-1"]
},
"properties": {
"rate": "0.15",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500",
"per_transaction_min_amount": "1.75",
"per_transaction_max_amount": "2"
}
}
],
"tax_codes": []
},
{
"billable_metric_id": "__BILLABLE_METRIC_ID__",
"billable_metric_code": "seats_groups",
"charge_model": "standard",
"invoiceable": true,
"pay_in_advance": false,
"prorated": false,
"min_amount_cents": 0,
"properties": {
"amount": "0"
},
"filters": [
{
"values": {
"cloud": ["aws"],
"region": ["us-east-1"]
},
"properties": {
"amount": "15"
}
}
],
"tax_codes": []
},
{
"billable_metric_id": "__BILLABLE_METRIC_ID__",
"billable_metric_code": "sms_sent_groups",
"charge_model": "volume",
"invoiceable": true,
"pay_in_advance": false,
"prorated": false,
"min_amount_cents": 0,
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": null,
"per_unit_amount": "0",
"flat_amount": "0"
}
]
},
"filters": [
{
"values": {
"cloud": ["aws"],
"region": ["us-east-1"]
},
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": 2000,
"per_unit_amount": "0.75",
"flat_amount": "0"
},
{
"from_value": 2001,
"to_value": null,
"per_unit_amount": "0.50",
"flat_amount": "0"
}
]
}
}
],
"tax_codes": []
}
]
}
}
'
from lago_python_client.client import Client
from lago_python_client.exceptions import LagoApiError
from lago_python_client.models import Plan, Charges, Charge
client = Client(api_key='__YOUR_API_KEY__')
standard_charge = Charge(
billable_metric_id='id',
charge_model='standard',
pay_in_advance=false,
min_amount_cents=0,
prorated= true,
invoice_display_name= "New display name",
tax_codes= ['french_standard_vat'],
properties={
'amount': '0.11'
},
filters=[
{
values={
"cloud": ["aws"],
"region": ["us-east-1"]
},
properties={
'amount': '0.22'
}
}
]
)
graduated_charge = Charge(
billable_metric_id='id,
charge_model='graduated',
pay_in_advance=false,
min_amount_cents=0,
prorated=false,
invoice_display_name= "",
properties=[
{
'from_value': 0,
'to_value': 10,
'flat_amount': '0',
'per_unit_amount': '0.00010'
},
{
'from_value': 11,
'to_value': None,
'flat_amount': "0",
'per_unit_amount': '0.0005'
}
]
)
package_charge = Charge(
billable_metric_id='id,
charge_model='package',
pay_in_advance=false,
min_amount_cents=0,
prorated=false,
invoice_display_name= "",
properties={
'amount': '100',
'free_units': 10000,
'package_size': 1000
}
)
percentage_charge = Charge(
billable_metric_id='id,
charge_model='percentage',
pay_in_advance=false,
min_amount_cents=0,
prorated=false,
invoice_display_name= "",
properties={
'rate': '0.5',
'fixed_amount': '1',
'free_units_per_events': 3,
'free_units_per_total_aggregation': None,
'per_transaction_min_amount': '1.75',
'per_transaction_max_amount': '2'
}
)
volume_charge = Charge(
billable_metric_id='id,
charge_model='volume',
pay_in_advance=false,
min_amount_cents=0,
prorated=true,
invoice_display_name= "",
properties={
'volume_ranges': [
{
'from_value': 0,
'to_value': 10,
'flat_amount': '0',
'per_unit_amount': '0.00010'
},
{
'from_value': 11,
'to_value': None,
'flat_amount': '0',
'per_unit_amount': '0.0005'
}
]
}
)
graduated_percentage_charge = Charge(
billable_metric_id='id,
charge_model='graduated_percentage',
prorated=true,
invoice_display_name= "",
properties={
'graduated_percentage_ranges': [
{
"rate": "1",
"from_value": 0,
"to_value": 1000,
"flat_amount": "200"
},
{
"rate": "2",
"from_value": 1001,
"to_value": 10000,
"flat_amount": "300"
},
{
"rate": "3",
"from_value": 10001,
"to_value": null,
"flat_amount": "400"
}
]
}
)
charges = Charges(__root__=[
standard_charge,
graduated_charge,
package_charge,
percentage_charge,
volume_charge,
graduated_percentage_charge
])
plan = Plan(
name='Startup',
code='startup',
amount_cents=10000,
amount_currency='USD',
description='This is a startup plan.',
interval='monthly',
pay_in_advance=True,
tax_codes= ['french_standard_vat'],
invoice_display_name= "",
charges=charges
)
try:
client.plans.create(plan)
except LagoApiError as e:
repair_broken_state(e) # do something on error or raise your own exception
require 'lago-ruby-client'
client = Lago::Api::Client.new({api_key: '__YOUR_API_KEY__'})
plan = {
name: 'Startup',
code: 'startup',
interval: 'monthly',
description: 'This is a startup plan.',
amount_cents: 10000,
amount_currency: 'USD',
pay_in_advance: false,
invoice_display_name: '',
tax_codes: ['french_standard_vat'],
charges: [
{
billable_metric_id: 'id',
charge_model: 'standard',
pay_in_advance: false,
min_amount_cents: 0,
prorated: true,
invoice_display_name: 'New invoice display name',
tax_codes: ['french_standard_vat'],
filters: [
{
values: {
cloud: 'aws',
region: 'us-east-1'
},
properties: {
amount: '0.10'
}
}
]
},
{
billable_metric_id: 'id',
charge_model: 'graduated',
pay_in_advance: false,
min_amount_cents: 0,
prorated: false,
invoice_display_name: '',
properties: [
{
to_value: 10,
from_value: 0,
flat_amount: '0',
per_unit_amount: '0.00010'
},
{
to_value: nil,
from_value: 11,
flat_amount: '0',
per_unit_amount: '0.0005'
}
]
},
{
billable_metric_id: 'id',
charge_model: 'package',
pay_in_advance: false,
min_amount_cents: 0,
prorated: false,
invoice_display_name: '',
properties: {
amount: '100',
free_units: 10000,
package_size: 1000
}
},
{
billable_metric_id: 'id',
charge_model: 'percentage',
pay_in_advance: false,
min_amount_cents: 0,
prorated: false,
invoice_display_name: '',
properties: {
rate: '0.5',
fixed_amount: '1',
free_units_per_events: 3,
free_units_per_total_aggregation: nil,
per_transaction_min_amount: '1.75',
per_transaction_max_amount: '2'
}
},
{
billable_metric_id: 'id',
charge_model: 'volume',
pay_in_advance: false,
min_amount_cents: 0,
prorated: true,
invoice_display_name: '',
properties: {
volume_ranges: [
{
to_value: 10,
from_value: 0,
flat_amount: '0',
per_unit_amount: '0.00010'
},
{
to_value: nil,
from_value: 11,
flat_amount: '0',
per_unit_amount: '0.0005'
}
]
}
},
{
billable_metric_id: 'id',
charge_model: 'graduated_percentage',
prorated: false,
invoice_display_name: '',
properties: {
graduated_percentage_ranges: [
{
"rate": "1",
"from_value": 0,
"to_value": 1000,
"flat_amount": "200"
},
{
"rate": "2",
"from_value": 1001,
"to_value": 10000,
"flat_amount": "300"
},
{
"rate": "3",
"from_value": 10001,
"to_value": null,
"flat_amount": "400"
}
]
}
}
]
}
client.plans.create(plan)
import { ChargeObject, PlanInput } from "lago-javascript-client";
const standardChargeObject = {
lago_id: null,
billable_metric_code: null,
created_at: null,
lago_billable_metric_id: "id",
charge_model: "standard" as ChargeObject["chargeModel"],
pay_in_advance: false,
min_amount_cents: 0,
prorated: true,
invoice_display_name: "New invoice display name",
tax_codes: ["french_standard_vat"],
filters: [
{
values: {
cloud: ["aws"],
region: ["us-east-1"]
},
properties: {
amount: "0.10",
},
},
],
};
const graduatedChargeObject = {
lago_id: null,
billable_metric_code: null,
created_at: null,
lago_billable_metric_id: "id",
charge_model: "graduated" as ChargeObject["chargeModel"],
pay_in_advance: false,
min_amount_cents: 0,
prorated: false,
invoice_display_name: "",
properties: [
{
to_value: 10,
from_value: 0,
flat_amount: "0",
per_unit_amount: "0.00010",
},
{
to_value: null,
from_value: 11,
flat_amount: "0",
per_unit_amount: "0.0005",
},
],
};
const packageChargeObject = {
lago_id: null,
billable_metric_code: null,
created_at: null,
lago_billable_metric_id: "id",
charge_model: "package" as ChargeObject["chargeModel"],
pay_in_advance: false,
min_amount_cents: 0,
prorated: false,
invoice_display_name: "",
properties: {
amount: "100",
free_units: 10000,
package_size: 1000,
},
};
const percentageChargeObject = {
lago_id: null,
billable_metric_code: null,
created_at: null,
lago_billable_metric_id: "id",
charge_model: "percentage" as ChargeObject["chargeModel"],
pay_in_advance: false,
min_amount_cents: 0,
prorated: false,
invoice_display_name: "",
properties: {
rate: "0.5",
fixed_amount: "1",
free_units_per_events: 3,
free_units_per_total_aggregation: null,
per_transaction_min_amount: "1.75",
per_transaction_max_amount: "2"
},
};
const volumeChargeObject = {
lago_id: null,
billable_metric_code: null,
created_at: null,
lago_billable_metric_id: "id",
charge_model: "volume" as ChargeObject["chargeModel"],
pay_in_advance: false,
min_amount_cents: 0,
prorated: true,
invoice_display_name: "",
properties: {
volume_ranges: [
{
to_value: 10,
from_value: 0,
flat_amount: "0",
per_unit_amount: "0.00010",
},
{
to_value: null,
from_value: 11,
flat_amount: "0",
per_unit_amount: "0.0005",
},
],
},
};
const graduatePercentageChargeObject = {
lago_id: null,
billable_metric_code: null,
created_at: null,
lago_billable_metric_id: "id",
charge_model: "graduated_percentage" as ChargeObject["chargeModel"],
pay_in_advance: false,
min_amount_cents: 0,
prorated: true,
invoice_display_name: "",
properties: {
volume_ranges: [
{
from_value: 0,
to_value: 10,
rate: "1",
flat_amount: "100"
},
{
from_value: 11,
to_value: null,
rate: "2",
flat_amount: "0"
},
],
},
};
const charges = [
standardChargeObject,
packageChargeObject,
graduatedChargeObject,
percentageChargeObject,
volumeChargeObject,
graduatePercentageChargeObject
];
const plan_object: PlanInput = {
plan: {
name: "Startup",
code: "startup",
interval: "monthly",
amount_cents: 10000,
amount_currency: "USD",
pay_in_advance: true,
trial_period: 2,
description: "This is a startup plan.",
invoice_display_name: "",
bill_charges_monthly: false,
tax_codes: ["french_standard_vat"],
charges: charges,
},
};
await client.plans.createPlan(planObject);
import "fmt"
import "github.com/getlago/lago-go-client"
func main() {
lagoClient := lago.New().
SetApiKey("__YOUR_API_KEY__")
planInput := &lago.PlanInput{
Name: "Startup",
Code: "startup",
Interval: lago.PlanMonthly,
PayInAdvance: true,
AmountCents: 10000,
InvoiceDisplayName: "",
AmountCurrency: lago.USD,
}
plan, err := lagoClient.Plan().Create(planInput)
if err != nil {
// Error is *lago.Error
panic(err)
}
// plan is *lago.Plan
fmt.Println(plan)
}
using System.Collections.Generic;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
namespace Example
{
public class CreatePlanExample
{
public static void Main()
{
Configuration.Default.BasePath = "https://api.getlago.com/api/v1";
// Configure HTTP bearer authorization: bearerAuth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new PlansApi(Configuration.Default);
var planInput = new PlanInput(); // PlanInput | Plan payload
try
{
// Create a new plan
Plan result = apiInstance.CreatePlan(planInput);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling PlansApi.CreatePlan: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer authorization: bearerAuth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\Client\Api\PlansApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$plan_input = new \OpenAPI\Client\Model\PlanInput(); // \OpenAPI\Client\Model\PlanInput | Plan payload
try {
$result = $apiInstance->createPlan($plan_input);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling PlansApi->createPlan: ', $e->getMessage(), PHP_EOL;
}