Assign a plan to a customer
curl --request POST \
--url https://core.nozle.app/api/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"subscription": {
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"plan_code": "premium",
"external_id": "my_sub_1234567890",
"billing_entity_code": "default",
"name": "Repository A",
"billing_time": "anniversary",
"ending_at": "2022-10-08T00:00:00Z",
"subscription_at": "2022-08-08T00:00:00Z",
"plan_overrides": {
"amount_cents": 10000,
"amount_currency": "USD",
"description": "Plan for early stage startups.",
"invoice_display_name": "Startup plan",
"name": "Startup",
"tax_codes": [
"french_standard_vat"
],
"trial_period": 5,
"minimum_commitment": {
"amount_cents": 100000,
"invoice_display_name": "Minimum Commitment (C1)",
"tax_codes": [
"french_standard_vat"
]
},
"charges": [
{
"id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"code": "api_requests_charge",
"invoice_display_name": "Setup",
"min_amount_cents": 0,
"properties": {
"grouped_by": [
"agent_name"
],
"pricing_group_keys": [
"agent_name"
],
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"graduated_percentage_ranges": [
{
"from_value": 0,
"to_value": 10,
"rate": "1",
"flat_amount": "10"
}
],
"amount": "30",
"free_units": 100,
"package_size": 1000,
"rate": "1",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500",
"per_transaction_max_amount": "3.75",
"per_transaction_min_amount": "1.75",
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"presentation_group_keys": [
{
"value": "region",
"options": {
"display_in_invoice": true
}
}
]
},
"filters": [
{
"properties": {
"grouped_by": [
"agent_name"
],
"pricing_group_keys": [
"agent_name"
],
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"graduated_percentage_ranges": [
{
"from_value": 0,
"to_value": 10,
"rate": "1",
"flat_amount": "10"
}
],
"amount": "30",
"free_units": 100,
"package_size": 1000,
"rate": "1",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500",
"per_transaction_max_amount": "3.75",
"per_transaction_min_amount": "1.75",
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
]
},
"values": {
"region": [
"us-east-1"
]
},
"invoice_display_name": "AWS"
}
],
"tax_codes": [
"french_standard_vat"
],
"applied_pricing_unit": {
"conversion_rate": "0.5"
}
}
],
"fixed_charges": [
{
"id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"invoice_display_name": "Setup fee",
"units": 1,
"apply_units_immediately": true,
"properties": {
"amount": "30",
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
]
},
"tax_codes": [
"french_standard_vat"
]
}
],
"usage_thresholds": [
{
"amount_cents": 10000,
"threshold_display_name": "Threshold 1",
"recurring": true
}
],
"metadata": {
"external_id": "ext-123",
"synced_at": "2024-01-15"
}
},
"invoice_custom_section": {
"skip_invoice_custom_sections": false,
"invoice_custom_section_codes": [
"eu_bank_details"
]
},
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
},
"consolidate_invoice": true,
"activation_rules": [
{
"type": "payment",
"timeout_hours": 48
}
]
}
}
'import requests
url = "https://core.nozle.app/api/v1/subscriptions"
payload = { "subscription": {
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"plan_code": "premium",
"external_id": "my_sub_1234567890",
"billing_entity_code": "default",
"name": "Repository A",
"billing_time": "anniversary",
"ending_at": "2022-10-08T00:00:00Z",
"subscription_at": "2022-08-08T00:00:00Z",
"plan_overrides": {
"amount_cents": 10000,
"amount_currency": "USD",
"description": "Plan for early stage startups.",
"invoice_display_name": "Startup plan",
"name": "Startup",
"tax_codes": ["french_standard_vat"],
"trial_period": 5,
"minimum_commitment": {
"amount_cents": 100000,
"invoice_display_name": "Minimum Commitment (C1)",
"tax_codes": ["french_standard_vat"]
},
"charges": [
{
"id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"code": "api_requests_charge",
"invoice_display_name": "Setup",
"min_amount_cents": 0,
"properties": {
"grouped_by": ["agent_name"],
"pricing_group_keys": ["agent_name"],
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"graduated_percentage_ranges": [
{
"from_value": 0,
"to_value": 10,
"rate": "1",
"flat_amount": "10"
}
],
"amount": "30",
"free_units": 100,
"package_size": 1000,
"rate": "1",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500",
"per_transaction_max_amount": "3.75",
"per_transaction_min_amount": "1.75",
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"presentation_group_keys": [
{
"value": "region",
"options": { "display_in_invoice": True }
}
]
},
"filters": [
{
"properties": {
"grouped_by": ["agent_name"],
"pricing_group_keys": ["agent_name"],
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"graduated_percentage_ranges": [
{
"from_value": 0,
"to_value": 10,
"rate": "1",
"flat_amount": "10"
}
],
"amount": "30",
"free_units": 100,
"package_size": 1000,
"rate": "1",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500",
"per_transaction_max_amount": "3.75",
"per_transaction_min_amount": "1.75",
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
]
},
"values": { "region": ["us-east-1"] },
"invoice_display_name": "AWS"
}
],
"tax_codes": ["french_standard_vat"],
"applied_pricing_unit": { "conversion_rate": "0.5" }
}
],
"fixed_charges": [
{
"id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"invoice_display_name": "Setup fee",
"units": 1,
"apply_units_immediately": True,
"properties": {
"amount": "30",
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
]
},
"tax_codes": ["french_standard_vat"]
}
],
"usage_thresholds": [
{
"amount_cents": 10000,
"threshold_display_name": "Threshold 1",
"recurring": True
}
],
"metadata": {
"external_id": "ext-123",
"synced_at": "2024-01-15"
}
},
"invoice_custom_section": {
"skip_invoice_custom_sections": False,
"invoice_custom_section_codes": ["eu_bank_details"]
},
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
},
"consolidate_invoice": True,
"activation_rules": [
{
"type": "payment",
"timeout_hours": 48
}
]
} }
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({
subscription: {
external_customer_id: '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba',
plan_code: 'premium',
external_id: 'my_sub_1234567890',
billing_entity_code: 'default',
name: 'Repository A',
billing_time: 'anniversary',
ending_at: '2022-10-08T00:00:00Z',
subscription_at: '2022-08-08T00:00:00Z',
plan_overrides: {
amount_cents: 10000,
amount_currency: 'USD',
description: 'Plan for early stage startups.',
invoice_display_name: 'Startup plan',
name: 'Startup',
tax_codes: ['french_standard_vat'],
trial_period: 5,
minimum_commitment: {
amount_cents: 100000,
invoice_display_name: 'Minimum Commitment (C1)',
tax_codes: ['french_standard_vat']
},
charges: [
{
id: '1a901a90-1a90-1a90-1a90-1a901a901a90',
feature_id: '1a901a90-1a90-1a90-1a90-1a901a901a90',
code: 'api_requests_charge',
invoice_display_name: 'Setup',
min_amount_cents: 0,
properties: {
grouped_by: ['agent_name'],
pricing_group_keys: ['agent_name'],
graduated_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}],
graduated_percentage_ranges: [{from_value: 0, to_value: 10, rate: '1', flat_amount: '10'}],
amount: '30',
free_units: 100,
package_size: 1000,
rate: '1',
fixed_amount: '0.5',
free_units_per_events: 5,
free_units_per_total_aggregation: '500',
per_transaction_max_amount: '3.75',
per_transaction_min_amount: '1.75',
volume_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}],
presentation_group_keys: [{value: 'region', options: {display_in_invoice: true}}]
},
filters: [
{
properties: {
grouped_by: ['agent_name'],
pricing_group_keys: ['agent_name'],
graduated_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}],
graduated_percentage_ranges: [{from_value: 0, to_value: 10, rate: '1', flat_amount: '10'}],
amount: '30',
free_units: 100,
package_size: 1000,
rate: '1',
fixed_amount: '0.5',
free_units_per_events: 5,
free_units_per_total_aggregation: '500',
per_transaction_max_amount: '3.75',
per_transaction_min_amount: '1.75',
volume_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}]
},
values: {region: ['us-east-1']},
invoice_display_name: 'AWS'
}
],
tax_codes: ['french_standard_vat'],
applied_pricing_unit: {conversion_rate: '0.5'}
}
],
fixed_charges: [
{
id: '1a901a90-1a90-1a90-1a90-1a901a901a90',
invoice_display_name: 'Setup fee',
units: 1,
apply_units_immediately: true,
properties: {
amount: '30',
graduated_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}],
volume_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}]
},
tax_codes: ['french_standard_vat']
}
],
usage_thresholds: [{amount_cents: 10000, threshold_display_name: 'Threshold 1', recurring: true}],
metadata: {external_id: 'ext-123', synced_at: '2024-01-15'}
},
invoice_custom_section: {
skip_invoice_custom_sections: false,
invoice_custom_section_codes: ['eu_bank_details']
},
payment_method: {
payment_method_type: 'provider',
payment_method_id: '1a901a90-1a90-1a90-1a90-1a901a901a90'
},
consolidate_invoice: true,
activation_rules: [{type: 'payment', timeout_hours: 48}]
}
})
};
fetch('https://core.nozle.app/api/v1/subscriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://core.nozle.app/api/v1/subscriptions"
payload := strings.NewReader("{\n \"subscription\": {\n \"external_customer_id\": \"5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba\",\n \"plan_code\": \"premium\",\n \"external_id\": \"my_sub_1234567890\",\n \"billing_entity_code\": \"default\",\n \"name\": \"Repository A\",\n \"billing_time\": \"anniversary\",\n \"ending_at\": \"2022-10-08T00:00:00Z\",\n \"subscription_at\": \"2022-08-08T00:00:00Z\",\n \"plan_overrides\": {\n \"amount_cents\": 10000,\n \"amount_currency\": \"USD\",\n \"description\": \"Plan for early stage startups.\",\n \"invoice_display_name\": \"Startup plan\",\n \"name\": \"Startup\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"trial_period\": 5,\n \"minimum_commitment\": {\n \"amount_cents\": 100000,\n \"invoice_display_name\": \"Minimum Commitment (C1)\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n },\n \"charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"feature_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"code\": \"api_requests_charge\",\n \"invoice_display_name\": \"Setup\",\n \"min_amount_cents\": 0,\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"presentation_group_keys\": [\n {\n \"value\": \"region\",\n \"options\": {\n \"display_in_invoice\": true\n }\n }\n ]\n },\n \"filters\": [\n {\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"values\": {\n \"region\": [\n \"us-east-1\"\n ]\n },\n \"invoice_display_name\": \"AWS\"\n }\n ],\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"applied_pricing_unit\": {\n \"conversion_rate\": \"0.5\"\n }\n }\n ],\n \"fixed_charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"invoice_display_name\": \"Setup fee\",\n \"units\": 1,\n \"apply_units_immediately\": true,\n \"properties\": {\n \"amount\": \"30\",\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n }\n ],\n \"usage_thresholds\": [\n {\n \"amount_cents\": 10000,\n \"threshold_display_name\": \"Threshold 1\",\n \"recurring\": true\n }\n ],\n \"metadata\": {\n \"external_id\": \"ext-123\",\n \"synced_at\": \"2024-01-15\"\n }\n },\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"eu_bank_details\"\n ]\n },\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n },\n \"consolidate_invoice\": true,\n \"activation_rules\": [\n {\n \"type\": \"payment\",\n \"timeout_hours\": 48\n }\n ]\n }\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))
}require 'uri'
require 'net/http'
url = URI("https://core.nozle.app/api/v1/subscriptions")
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 \"subscription\": {\n \"external_customer_id\": \"5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba\",\n \"plan_code\": \"premium\",\n \"external_id\": \"my_sub_1234567890\",\n \"billing_entity_code\": \"default\",\n \"name\": \"Repository A\",\n \"billing_time\": \"anniversary\",\n \"ending_at\": \"2022-10-08T00:00:00Z\",\n \"subscription_at\": \"2022-08-08T00:00:00Z\",\n \"plan_overrides\": {\n \"amount_cents\": 10000,\n \"amount_currency\": \"USD\",\n \"description\": \"Plan for early stage startups.\",\n \"invoice_display_name\": \"Startup plan\",\n \"name\": \"Startup\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"trial_period\": 5,\n \"minimum_commitment\": {\n \"amount_cents\": 100000,\n \"invoice_display_name\": \"Minimum Commitment (C1)\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n },\n \"charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"feature_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"code\": \"api_requests_charge\",\n \"invoice_display_name\": \"Setup\",\n \"min_amount_cents\": 0,\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"presentation_group_keys\": [\n {\n \"value\": \"region\",\n \"options\": {\n \"display_in_invoice\": true\n }\n }\n ]\n },\n \"filters\": [\n {\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"values\": {\n \"region\": [\n \"us-east-1\"\n ]\n },\n \"invoice_display_name\": \"AWS\"\n }\n ],\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"applied_pricing_unit\": {\n \"conversion_rate\": \"0.5\"\n }\n }\n ],\n \"fixed_charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"invoice_display_name\": \"Setup fee\",\n \"units\": 1,\n \"apply_units_immediately\": true,\n \"properties\": {\n \"amount\": \"30\",\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n }\n ],\n \"usage_thresholds\": [\n {\n \"amount_cents\": 10000,\n \"threshold_display_name\": \"Threshold 1\",\n \"recurring\": true\n }\n ],\n \"metadata\": {\n \"external_id\": \"ext-123\",\n \"synced_at\": \"2024-01-15\"\n }\n },\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"eu_bank_details\"\n ]\n },\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n },\n \"consolidate_invoice\": true,\n \"activation_rules\": [\n {\n \"type\": \"payment\",\n \"timeout_hours\": 48\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://core.nozle.app/api/v1/subscriptions",
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([
'subscription' => [
'external_customer_id' => '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba',
'plan_code' => 'premium',
'external_id' => 'my_sub_1234567890',
'billing_entity_code' => 'default',
'name' => 'Repository A',
'billing_time' => 'anniversary',
'ending_at' => '2022-10-08T00:00:00Z',
'subscription_at' => '2022-08-08T00:00:00Z',
'plan_overrides' => [
'amount_cents' => 10000,
'amount_currency' => 'USD',
'description' => 'Plan for early stage startups.',
'invoice_display_name' => 'Startup plan',
'name' => 'Startup',
'tax_codes' => [
'french_standard_vat'
],
'trial_period' => 5,
'minimum_commitment' => [
'amount_cents' => 100000,
'invoice_display_name' => 'Minimum Commitment (C1)',
'tax_codes' => [
'french_standard_vat'
]
],
'charges' => [
[
'id' => '1a901a90-1a90-1a90-1a90-1a901a901a90',
'feature_id' => '1a901a90-1a90-1a90-1a90-1a901a901a90',
'code' => 'api_requests_charge',
'invoice_display_name' => 'Setup',
'min_amount_cents' => 0,
'properties' => [
'grouped_by' => [
'agent_name'
],
'pricing_group_keys' => [
'agent_name'
],
'graduated_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
],
'graduated_percentage_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'rate' => '1',
'flat_amount' => '10'
]
],
'amount' => '30',
'free_units' => 100,
'package_size' => 1000,
'rate' => '1',
'fixed_amount' => '0.5',
'free_units_per_events' => 5,
'free_units_per_total_aggregation' => '500',
'per_transaction_max_amount' => '3.75',
'per_transaction_min_amount' => '1.75',
'volume_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
],
'presentation_group_keys' => [
[
'value' => 'region',
'options' => [
'display_in_invoice' => true
]
]
]
],
'filters' => [
[
'properties' => [
'grouped_by' => [
'agent_name'
],
'pricing_group_keys' => [
'agent_name'
],
'graduated_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
],
'graduated_percentage_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'rate' => '1',
'flat_amount' => '10'
]
],
'amount' => '30',
'free_units' => 100,
'package_size' => 1000,
'rate' => '1',
'fixed_amount' => '0.5',
'free_units_per_events' => 5,
'free_units_per_total_aggregation' => '500',
'per_transaction_max_amount' => '3.75',
'per_transaction_min_amount' => '1.75',
'volume_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
]
],
'values' => [
'region' => [
'us-east-1'
]
],
'invoice_display_name' => 'AWS'
]
],
'tax_codes' => [
'french_standard_vat'
],
'applied_pricing_unit' => [
'conversion_rate' => '0.5'
]
]
],
'fixed_charges' => [
[
'id' => '1a901a90-1a90-1a90-1a90-1a901a901a90',
'invoice_display_name' => 'Setup fee',
'units' => 1,
'apply_units_immediately' => true,
'properties' => [
'amount' => '30',
'graduated_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
],
'volume_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
]
],
'tax_codes' => [
'french_standard_vat'
]
]
],
'usage_thresholds' => [
[
'amount_cents' => 10000,
'threshold_display_name' => 'Threshold 1',
'recurring' => true
]
],
'metadata' => [
'external_id' => 'ext-123',
'synced_at' => '2024-01-15'
]
],
'invoice_custom_section' => [
'skip_invoice_custom_sections' => false,
'invoice_custom_section_codes' => [
'eu_bank_details'
]
],
'payment_method' => [
'payment_method_type' => 'provider',
'payment_method_id' => '1a901a90-1a90-1a90-1a90-1a901a901a90'
],
'consolidate_invoice' => true,
'activation_rules' => [
[
'type' => 'payment',
'timeout_hours' => 48
]
]
]
]),
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;
}HttpResponse<String> response = Unirest.post("https://core.nozle.app/api/v1/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"subscription\": {\n \"external_customer_id\": \"5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba\",\n \"plan_code\": \"premium\",\n \"external_id\": \"my_sub_1234567890\",\n \"billing_entity_code\": \"default\",\n \"name\": \"Repository A\",\n \"billing_time\": \"anniversary\",\n \"ending_at\": \"2022-10-08T00:00:00Z\",\n \"subscription_at\": \"2022-08-08T00:00:00Z\",\n \"plan_overrides\": {\n \"amount_cents\": 10000,\n \"amount_currency\": \"USD\",\n \"description\": \"Plan for early stage startups.\",\n \"invoice_display_name\": \"Startup plan\",\n \"name\": \"Startup\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"trial_period\": 5,\n \"minimum_commitment\": {\n \"amount_cents\": 100000,\n \"invoice_display_name\": \"Minimum Commitment (C1)\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n },\n \"charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"feature_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"code\": \"api_requests_charge\",\n \"invoice_display_name\": \"Setup\",\n \"min_amount_cents\": 0,\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"presentation_group_keys\": [\n {\n \"value\": \"region\",\n \"options\": {\n \"display_in_invoice\": true\n }\n }\n ]\n },\n \"filters\": [\n {\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"values\": {\n \"region\": [\n \"us-east-1\"\n ]\n },\n \"invoice_display_name\": \"AWS\"\n }\n ],\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"applied_pricing_unit\": {\n \"conversion_rate\": \"0.5\"\n }\n }\n ],\n \"fixed_charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"invoice_display_name\": \"Setup fee\",\n \"units\": 1,\n \"apply_units_immediately\": true,\n \"properties\": {\n \"amount\": \"30\",\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n }\n ],\n \"usage_thresholds\": [\n {\n \"amount_cents\": 10000,\n \"threshold_display_name\": \"Threshold 1\",\n \"recurring\": true\n }\n ],\n \"metadata\": {\n \"external_id\": \"ext-123\",\n \"synced_at\": \"2024-01-15\"\n }\n },\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"eu_bank_details\"\n ]\n },\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n },\n \"consolidate_invoice\": true,\n \"activation_rules\": [\n {\n \"type\": \"payment\",\n \"timeout_hours\": 48\n }\n ]\n }\n}")
.asString();{
"subscription": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"billing_time": "anniversary",
"name": "Repository A",
"plan_code": "premium",
"status": "active",
"created_at": "2022-08-08T00:00:00Z",
"canceled_at": "2022-09-14T16:35:31Z",
"started_at": "2022-08-08T00:00:00Z",
"ending_at": "2022-10-08T00:00:00Z",
"subscription_at": "2022-08-08T00:00:00Z",
"terminated_at": "2022-09-14T16:35:31Z",
"previous_plan_code": null,
"next_plan_code": null,
"downgrade_plan_date": "2022-04-30",
"trial_ended_at": "2022-08-08T00:00:00Z",
"current_billing_period_started_at": "2022-08-08T00:00:00Z",
"current_billing_period_ending_at": "2022-09-08T00:00:00Z",
"on_termination_credit_note": "credit",
"on_termination_invoice": "generate",
"billing_entity_code": "default",
"plan_amount_cents": 10000,
"plan_amount_currency": "USD",
"applied_invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z",
"invoice_custom_section": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "EU Bank Details",
"code": "eu_bank_details",
"description": "This section contains the bank details for EU customers.",
"details": "Bank Name: Nozle Bank, IBAN: FR7630004000031234567890143",
"display_name": "Bank Details:",
"applied_to_organization": true,
"organization_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z"
},
"invoice_custom_section_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
],
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
},
"consolidate_invoice": true,
"cancellation_reason": "payment_failed",
"activated_at": "2022-08-08T00:00:00Z",
"activation_rules": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"type": "payment",
"timeout_hours": 48,
"status": "pending",
"created_at": "2022-08-08T00:00:00Z",
"updated_at": "2022-08-08T00:00:00Z",
"expires_at": "2022-08-10T00:00:00Z"
}
],
"plan": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "Startup",
"created_at": "2023-06-27T19:43:42Z",
"code": "startup",
"interval": "monthly",
"amount_cents": 10000,
"amount_currency": "USD",
"invoice_display_name": "Startup plan",
"description": "",
"trial_period": 5,
"pay_in_advance": true,
"bill_charges_monthly": null,
"bill_fixed_charges_monthly": null,
"minimum_commitment": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"amount_cents": 100000,
"created_at": "2022-04-29T08:59:51Z",
"plan_code": "premium",
"invoice_display_name": "Minimum Commitment (C1)",
"interval": "monthly",
"updated_at": "2022-04-29T08:59:51Z",
"taxes": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "TVA",
"code": "french_standard_vat",
"rate": 20,
"applied_to_organization": true,
"created_at": "2023-07-06T14:35:58Z",
"description": "French standard VAT"
}
]
},
"charges": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a91",
"lago_feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a91",
"feature_code": "requests",
"created_at": "2023-06-27T19:43:42Z",
"charge_model": "package",
"invoiceable": true,
"invoice_display_name": "Setup",
"pay_in_advance": false,
"regroup_paid_fees": null,
"prorated": false,
"min_amount_cents": 3000,
"properties": {
"amount": "30",
"free_units": 100,
"package_size": 1000
},
"filters": []
},
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a92",
"lago_feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a92",
"feature_code": "cpu",
"created_at": "2023-06-27T19:43:42Z",
"charge_model": "graduated",
"invoiceable": true,
"invoice_display_name": "Setup",
"pay_in_advance": false,
"regroup_paid_fees": null,
"prorated": false,
"min_amount_cents": 0,
"properties": {
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
},
{
"from_value": 11,
"to_value": null,
"flat_amount": "0",
"per_unit_amount": "0.4"
}
]
},
"filters": []
},
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a93",
"lago_feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a93",
"feature_code": "seats",
"created_at": "2023-06-27T19:43:42Z",
"charge_model": "standard",
"invoiceable": true,
"invoice_display_name": "Setup",
"pay_in_advance": true,
"regroup_paid_fees": null,
"prorated": false,
"min_amount_cents": 0,
"properties": {},
"filters": [
{
"invoice_display_name": "Europe",
"properties": {
"amount": "10"
},
"values": {
"region": [
"Europe"
]
}
},
{
"invoice_display_name": "USA",
"properties": {
"amount": "5"
},
"values": {
"region": [
"USA"
]
}
},
{
"invoice_display_name": "Africa",
"properties": {
"amount": "8"
},
"values": {
"region": [
"Africa"
]
}
}
]
},
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"lago_feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"feature_code": "storage",
"created_at": "2023-06-27T19:43:42Z",
"charge_model": "volume",
"invoiceable": true,
"invoice_display_name": "Setup",
"pay_in_advance": false,
"regroup_paid_fees": null,
"prorated": false,
"min_amount_cents": 0,
"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"
}
]
},
"filters": []
},
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a95",
"lago_feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a95",
"feature_code": "payments",
"created_at": "2023-06-27T19:43:42Z",
"charge_model": "percentage",
"invoiceable": false,
"invoice_display_name": "Setup",
"pay_in_advance": true,
"regroup_paid_fees": "invoice",
"prorated": false,
"min_amount_cents": 0,
"properties": {
"rate": "1",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500"
},
"filters": []
}
],
"fixed_charges": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"lago_add_on_id": "2b802b80-2b80-2b80-2b80-2b802b802b80",
"code": "setup_fee",
"invoice_display_name": "Setup Fee",
"add_on_code": "setup",
"created_at": "2026-01-15T10:30:00Z",
"charge_model": "standard",
"pay_in_advance": true,
"prorated": false,
"properties": {
"amount": "500"
},
"units": 1,
"lago_parent_id": null,
"taxes": [
{
"lago_id": "3c703c70-3c70-3c70-3c70-3c703c703c70",
"name": "VAT",
"code": "vat_20",
"rate": 20,
"description": "Standard VAT rate",
"applied_to_organization": true,
"created_at": "2026-01-01T00:00:00Z"
}
]
},
{
"lago_id": "4d604d60-4d60-4d60-4d60-4d604d604d60",
"lago_add_on_id": "5e505e50-5e50-5e50-5e50-5e505e505e50",
"code": "support_tier",
"invoice_display_name": "Support Tier",
"add_on_code": "premium_support",
"created_at": "2026-01-15T10:30:00Z",
"charge_model": "graduated",
"pay_in_advance": false,
"prorated": true,
"properties": {
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"per_unit_amount": "5",
"flat_amount": "200"
},
{
"from_value": 11,
"to_value": null,
"per_unit_amount": "1",
"flat_amount": "300"
}
]
},
"units": 1,
"lago_parent_id": null,
"taxes": []
},
{
"lago_id": "6f406f40-6f40-6f40-6f40-6f406f406f40",
"lago_add_on_id": "7a307a30-7a30-7a30-7a30-7a307a307a30",
"code": "storage",
"invoice_display_name": "Storage Allocation",
"add_on_code": "cloud_storage",
"created_at": "2026-01-15T10:30:00Z",
"charge_model": "volume",
"pay_in_advance": false,
"prorated": false,
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": 100,
"per_unit_amount": "2",
"flat_amount": "1"
},
{
"from_value": 101,
"to_value": null,
"per_unit_amount": "1",
"flat_amount": "0"
}
]
},
"units": 50,
"lago_parent_id": null,
"taxes": []
}
],
"taxes": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "TVA",
"code": "french_standard_vat",
"rate": 20,
"applied_to_organization": true,
"created_at": "2023-07-06T14:35:58Z",
"description": "French standard VAT"
}
],
"usage_thresholds": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"threshold_display_name": "Threshold 1",
"amount_cents": 10000,
"recurring": true,
"created_at": "2023-06-27T19:43:42Z",
"updated_at": "2023-06-27T19:43:42Z"
}
],
"entitlements": [
{
"entitlement": {
"code": "seats",
"name": "Number of seats",
"description": "Number of users of the account",
"privileges": [
{
"code": "max",
"name": "Maximum",
"value_type": "integer",
"config": {},
"value": 10
},
{
"code": "max_admins",
"name": "Max Admins",
"value_type": "integer",
"config": {},
"value": 5
},
{
"code": "root",
"name": "Allow root user",
"value_type": "boolean",
"config": {},
"value": true
},
{
"code": "provider",
"name": "SSO Provider",
"value_type": "select",
"value": "google",
"config": {
"select_options": [
"google",
"okta"
]
}
}
]
}
}
],
"metadata": {
"external_id": "ext-123",
"synced_at": "2024-01-15",
"source": null
}
},
"applicable_usage_thresholds": [
{
"threshold_display_name": "Threshold 1",
"amount_cents": 10000,
"recurring": true
}
]
}
}{
"status": 400,
"error": "Bad request"
}{
"status": 401,
"error": "Unauthorized"
}{
"status": 404,
"error": "Not Found",
"code": "object_not_found"
}{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {}
}Subscriptions
Assign a plan to a customer
This endpoint assigns a plan to a customer, creating or modifying a subscription. Ideal for initial subscriptions or plan changes (upgrades/downgrades).
POST
/
subscriptions
Assign a plan to a customer
curl --request POST \
--url https://core.nozle.app/api/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"subscription": {
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"plan_code": "premium",
"external_id": "my_sub_1234567890",
"billing_entity_code": "default",
"name": "Repository A",
"billing_time": "anniversary",
"ending_at": "2022-10-08T00:00:00Z",
"subscription_at": "2022-08-08T00:00:00Z",
"plan_overrides": {
"amount_cents": 10000,
"amount_currency": "USD",
"description": "Plan for early stage startups.",
"invoice_display_name": "Startup plan",
"name": "Startup",
"tax_codes": [
"french_standard_vat"
],
"trial_period": 5,
"minimum_commitment": {
"amount_cents": 100000,
"invoice_display_name": "Minimum Commitment (C1)",
"tax_codes": [
"french_standard_vat"
]
},
"charges": [
{
"id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"code": "api_requests_charge",
"invoice_display_name": "Setup",
"min_amount_cents": 0,
"properties": {
"grouped_by": [
"agent_name"
],
"pricing_group_keys": [
"agent_name"
],
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"graduated_percentage_ranges": [
{
"from_value": 0,
"to_value": 10,
"rate": "1",
"flat_amount": "10"
}
],
"amount": "30",
"free_units": 100,
"package_size": 1000,
"rate": "1",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500",
"per_transaction_max_amount": "3.75",
"per_transaction_min_amount": "1.75",
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"presentation_group_keys": [
{
"value": "region",
"options": {
"display_in_invoice": true
}
}
]
},
"filters": [
{
"properties": {
"grouped_by": [
"agent_name"
],
"pricing_group_keys": [
"agent_name"
],
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"graduated_percentage_ranges": [
{
"from_value": 0,
"to_value": 10,
"rate": "1",
"flat_amount": "10"
}
],
"amount": "30",
"free_units": 100,
"package_size": 1000,
"rate": "1",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500",
"per_transaction_max_amount": "3.75",
"per_transaction_min_amount": "1.75",
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
]
},
"values": {
"region": [
"us-east-1"
]
},
"invoice_display_name": "AWS"
}
],
"tax_codes": [
"french_standard_vat"
],
"applied_pricing_unit": {
"conversion_rate": "0.5"
}
}
],
"fixed_charges": [
{
"id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"invoice_display_name": "Setup fee",
"units": 1,
"apply_units_immediately": true,
"properties": {
"amount": "30",
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
]
},
"tax_codes": [
"french_standard_vat"
]
}
],
"usage_thresholds": [
{
"amount_cents": 10000,
"threshold_display_name": "Threshold 1",
"recurring": true
}
],
"metadata": {
"external_id": "ext-123",
"synced_at": "2024-01-15"
}
},
"invoice_custom_section": {
"skip_invoice_custom_sections": false,
"invoice_custom_section_codes": [
"eu_bank_details"
]
},
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
},
"consolidate_invoice": true,
"activation_rules": [
{
"type": "payment",
"timeout_hours": 48
}
]
}
}
'import requests
url = "https://core.nozle.app/api/v1/subscriptions"
payload = { "subscription": {
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"plan_code": "premium",
"external_id": "my_sub_1234567890",
"billing_entity_code": "default",
"name": "Repository A",
"billing_time": "anniversary",
"ending_at": "2022-10-08T00:00:00Z",
"subscription_at": "2022-08-08T00:00:00Z",
"plan_overrides": {
"amount_cents": 10000,
"amount_currency": "USD",
"description": "Plan for early stage startups.",
"invoice_display_name": "Startup plan",
"name": "Startup",
"tax_codes": ["french_standard_vat"],
"trial_period": 5,
"minimum_commitment": {
"amount_cents": 100000,
"invoice_display_name": "Minimum Commitment (C1)",
"tax_codes": ["french_standard_vat"]
},
"charges": [
{
"id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"code": "api_requests_charge",
"invoice_display_name": "Setup",
"min_amount_cents": 0,
"properties": {
"grouped_by": ["agent_name"],
"pricing_group_keys": ["agent_name"],
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"graduated_percentage_ranges": [
{
"from_value": 0,
"to_value": 10,
"rate": "1",
"flat_amount": "10"
}
],
"amount": "30",
"free_units": 100,
"package_size": 1000,
"rate": "1",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500",
"per_transaction_max_amount": "3.75",
"per_transaction_min_amount": "1.75",
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"presentation_group_keys": [
{
"value": "region",
"options": { "display_in_invoice": True }
}
]
},
"filters": [
{
"properties": {
"grouped_by": ["agent_name"],
"pricing_group_keys": ["agent_name"],
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"graduated_percentage_ranges": [
{
"from_value": 0,
"to_value": 10,
"rate": "1",
"flat_amount": "10"
}
],
"amount": "30",
"free_units": 100,
"package_size": 1000,
"rate": "1",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500",
"per_transaction_max_amount": "3.75",
"per_transaction_min_amount": "1.75",
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
]
},
"values": { "region": ["us-east-1"] },
"invoice_display_name": "AWS"
}
],
"tax_codes": ["french_standard_vat"],
"applied_pricing_unit": { "conversion_rate": "0.5" }
}
],
"fixed_charges": [
{
"id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"invoice_display_name": "Setup fee",
"units": 1,
"apply_units_immediately": True,
"properties": {
"amount": "30",
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"volume_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
]
},
"tax_codes": ["french_standard_vat"]
}
],
"usage_thresholds": [
{
"amount_cents": 10000,
"threshold_display_name": "Threshold 1",
"recurring": True
}
],
"metadata": {
"external_id": "ext-123",
"synced_at": "2024-01-15"
}
},
"invoice_custom_section": {
"skip_invoice_custom_sections": False,
"invoice_custom_section_codes": ["eu_bank_details"]
},
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
},
"consolidate_invoice": True,
"activation_rules": [
{
"type": "payment",
"timeout_hours": 48
}
]
} }
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({
subscription: {
external_customer_id: '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba',
plan_code: 'premium',
external_id: 'my_sub_1234567890',
billing_entity_code: 'default',
name: 'Repository A',
billing_time: 'anniversary',
ending_at: '2022-10-08T00:00:00Z',
subscription_at: '2022-08-08T00:00:00Z',
plan_overrides: {
amount_cents: 10000,
amount_currency: 'USD',
description: 'Plan for early stage startups.',
invoice_display_name: 'Startup plan',
name: 'Startup',
tax_codes: ['french_standard_vat'],
trial_period: 5,
minimum_commitment: {
amount_cents: 100000,
invoice_display_name: 'Minimum Commitment (C1)',
tax_codes: ['french_standard_vat']
},
charges: [
{
id: '1a901a90-1a90-1a90-1a90-1a901a901a90',
feature_id: '1a901a90-1a90-1a90-1a90-1a901a901a90',
code: 'api_requests_charge',
invoice_display_name: 'Setup',
min_amount_cents: 0,
properties: {
grouped_by: ['agent_name'],
pricing_group_keys: ['agent_name'],
graduated_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}],
graduated_percentage_ranges: [{from_value: 0, to_value: 10, rate: '1', flat_amount: '10'}],
amount: '30',
free_units: 100,
package_size: 1000,
rate: '1',
fixed_amount: '0.5',
free_units_per_events: 5,
free_units_per_total_aggregation: '500',
per_transaction_max_amount: '3.75',
per_transaction_min_amount: '1.75',
volume_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}],
presentation_group_keys: [{value: 'region', options: {display_in_invoice: true}}]
},
filters: [
{
properties: {
grouped_by: ['agent_name'],
pricing_group_keys: ['agent_name'],
graduated_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}],
graduated_percentage_ranges: [{from_value: 0, to_value: 10, rate: '1', flat_amount: '10'}],
amount: '30',
free_units: 100,
package_size: 1000,
rate: '1',
fixed_amount: '0.5',
free_units_per_events: 5,
free_units_per_total_aggregation: '500',
per_transaction_max_amount: '3.75',
per_transaction_min_amount: '1.75',
volume_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}]
},
values: {region: ['us-east-1']},
invoice_display_name: 'AWS'
}
],
tax_codes: ['french_standard_vat'],
applied_pricing_unit: {conversion_rate: '0.5'}
}
],
fixed_charges: [
{
id: '1a901a90-1a90-1a90-1a90-1a901a901a90',
invoice_display_name: 'Setup fee',
units: 1,
apply_units_immediately: true,
properties: {
amount: '30',
graduated_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}],
volume_ranges: [{from_value: 0, to_value: 10, flat_amount: '10', per_unit_amount: '0.5'}]
},
tax_codes: ['french_standard_vat']
}
],
usage_thresholds: [{amount_cents: 10000, threshold_display_name: 'Threshold 1', recurring: true}],
metadata: {external_id: 'ext-123', synced_at: '2024-01-15'}
},
invoice_custom_section: {
skip_invoice_custom_sections: false,
invoice_custom_section_codes: ['eu_bank_details']
},
payment_method: {
payment_method_type: 'provider',
payment_method_id: '1a901a90-1a90-1a90-1a90-1a901a901a90'
},
consolidate_invoice: true,
activation_rules: [{type: 'payment', timeout_hours: 48}]
}
})
};
fetch('https://core.nozle.app/api/v1/subscriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://core.nozle.app/api/v1/subscriptions"
payload := strings.NewReader("{\n \"subscription\": {\n \"external_customer_id\": \"5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba\",\n \"plan_code\": \"premium\",\n \"external_id\": \"my_sub_1234567890\",\n \"billing_entity_code\": \"default\",\n \"name\": \"Repository A\",\n \"billing_time\": \"anniversary\",\n \"ending_at\": \"2022-10-08T00:00:00Z\",\n \"subscription_at\": \"2022-08-08T00:00:00Z\",\n \"plan_overrides\": {\n \"amount_cents\": 10000,\n \"amount_currency\": \"USD\",\n \"description\": \"Plan for early stage startups.\",\n \"invoice_display_name\": \"Startup plan\",\n \"name\": \"Startup\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"trial_period\": 5,\n \"minimum_commitment\": {\n \"amount_cents\": 100000,\n \"invoice_display_name\": \"Minimum Commitment (C1)\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n },\n \"charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"feature_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"code\": \"api_requests_charge\",\n \"invoice_display_name\": \"Setup\",\n \"min_amount_cents\": 0,\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"presentation_group_keys\": [\n {\n \"value\": \"region\",\n \"options\": {\n \"display_in_invoice\": true\n }\n }\n ]\n },\n \"filters\": [\n {\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"values\": {\n \"region\": [\n \"us-east-1\"\n ]\n },\n \"invoice_display_name\": \"AWS\"\n }\n ],\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"applied_pricing_unit\": {\n \"conversion_rate\": \"0.5\"\n }\n }\n ],\n \"fixed_charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"invoice_display_name\": \"Setup fee\",\n \"units\": 1,\n \"apply_units_immediately\": true,\n \"properties\": {\n \"amount\": \"30\",\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n }\n ],\n \"usage_thresholds\": [\n {\n \"amount_cents\": 10000,\n \"threshold_display_name\": \"Threshold 1\",\n \"recurring\": true\n }\n ],\n \"metadata\": {\n \"external_id\": \"ext-123\",\n \"synced_at\": \"2024-01-15\"\n }\n },\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"eu_bank_details\"\n ]\n },\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n },\n \"consolidate_invoice\": true,\n \"activation_rules\": [\n {\n \"type\": \"payment\",\n \"timeout_hours\": 48\n }\n ]\n }\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))
}require 'uri'
require 'net/http'
url = URI("https://core.nozle.app/api/v1/subscriptions")
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 \"subscription\": {\n \"external_customer_id\": \"5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba\",\n \"plan_code\": \"premium\",\n \"external_id\": \"my_sub_1234567890\",\n \"billing_entity_code\": \"default\",\n \"name\": \"Repository A\",\n \"billing_time\": \"anniversary\",\n \"ending_at\": \"2022-10-08T00:00:00Z\",\n \"subscription_at\": \"2022-08-08T00:00:00Z\",\n \"plan_overrides\": {\n \"amount_cents\": 10000,\n \"amount_currency\": \"USD\",\n \"description\": \"Plan for early stage startups.\",\n \"invoice_display_name\": \"Startup plan\",\n \"name\": \"Startup\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"trial_period\": 5,\n \"minimum_commitment\": {\n \"amount_cents\": 100000,\n \"invoice_display_name\": \"Minimum Commitment (C1)\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n },\n \"charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"feature_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"code\": \"api_requests_charge\",\n \"invoice_display_name\": \"Setup\",\n \"min_amount_cents\": 0,\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"presentation_group_keys\": [\n {\n \"value\": \"region\",\n \"options\": {\n \"display_in_invoice\": true\n }\n }\n ]\n },\n \"filters\": [\n {\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"values\": {\n \"region\": [\n \"us-east-1\"\n ]\n },\n \"invoice_display_name\": \"AWS\"\n }\n ],\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"applied_pricing_unit\": {\n \"conversion_rate\": \"0.5\"\n }\n }\n ],\n \"fixed_charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"invoice_display_name\": \"Setup fee\",\n \"units\": 1,\n \"apply_units_immediately\": true,\n \"properties\": {\n \"amount\": \"30\",\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n }\n ],\n \"usage_thresholds\": [\n {\n \"amount_cents\": 10000,\n \"threshold_display_name\": \"Threshold 1\",\n \"recurring\": true\n }\n ],\n \"metadata\": {\n \"external_id\": \"ext-123\",\n \"synced_at\": \"2024-01-15\"\n }\n },\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"eu_bank_details\"\n ]\n },\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n },\n \"consolidate_invoice\": true,\n \"activation_rules\": [\n {\n \"type\": \"payment\",\n \"timeout_hours\": 48\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://core.nozle.app/api/v1/subscriptions",
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([
'subscription' => [
'external_customer_id' => '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba',
'plan_code' => 'premium',
'external_id' => 'my_sub_1234567890',
'billing_entity_code' => 'default',
'name' => 'Repository A',
'billing_time' => 'anniversary',
'ending_at' => '2022-10-08T00:00:00Z',
'subscription_at' => '2022-08-08T00:00:00Z',
'plan_overrides' => [
'amount_cents' => 10000,
'amount_currency' => 'USD',
'description' => 'Plan for early stage startups.',
'invoice_display_name' => 'Startup plan',
'name' => 'Startup',
'tax_codes' => [
'french_standard_vat'
],
'trial_period' => 5,
'minimum_commitment' => [
'amount_cents' => 100000,
'invoice_display_name' => 'Minimum Commitment (C1)',
'tax_codes' => [
'french_standard_vat'
]
],
'charges' => [
[
'id' => '1a901a90-1a90-1a90-1a90-1a901a901a90',
'feature_id' => '1a901a90-1a90-1a90-1a90-1a901a901a90',
'code' => 'api_requests_charge',
'invoice_display_name' => 'Setup',
'min_amount_cents' => 0,
'properties' => [
'grouped_by' => [
'agent_name'
],
'pricing_group_keys' => [
'agent_name'
],
'graduated_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
],
'graduated_percentage_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'rate' => '1',
'flat_amount' => '10'
]
],
'amount' => '30',
'free_units' => 100,
'package_size' => 1000,
'rate' => '1',
'fixed_amount' => '0.5',
'free_units_per_events' => 5,
'free_units_per_total_aggregation' => '500',
'per_transaction_max_amount' => '3.75',
'per_transaction_min_amount' => '1.75',
'volume_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
],
'presentation_group_keys' => [
[
'value' => 'region',
'options' => [
'display_in_invoice' => true
]
]
]
],
'filters' => [
[
'properties' => [
'grouped_by' => [
'agent_name'
],
'pricing_group_keys' => [
'agent_name'
],
'graduated_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
],
'graduated_percentage_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'rate' => '1',
'flat_amount' => '10'
]
],
'amount' => '30',
'free_units' => 100,
'package_size' => 1000,
'rate' => '1',
'fixed_amount' => '0.5',
'free_units_per_events' => 5,
'free_units_per_total_aggregation' => '500',
'per_transaction_max_amount' => '3.75',
'per_transaction_min_amount' => '1.75',
'volume_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
]
],
'values' => [
'region' => [
'us-east-1'
]
],
'invoice_display_name' => 'AWS'
]
],
'tax_codes' => [
'french_standard_vat'
],
'applied_pricing_unit' => [
'conversion_rate' => '0.5'
]
]
],
'fixed_charges' => [
[
'id' => '1a901a90-1a90-1a90-1a90-1a901a901a90',
'invoice_display_name' => 'Setup fee',
'units' => 1,
'apply_units_immediately' => true,
'properties' => [
'amount' => '30',
'graduated_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
],
'volume_ranges' => [
[
'from_value' => 0,
'to_value' => 10,
'flat_amount' => '10',
'per_unit_amount' => '0.5'
]
]
],
'tax_codes' => [
'french_standard_vat'
]
]
],
'usage_thresholds' => [
[
'amount_cents' => 10000,
'threshold_display_name' => 'Threshold 1',
'recurring' => true
]
],
'metadata' => [
'external_id' => 'ext-123',
'synced_at' => '2024-01-15'
]
],
'invoice_custom_section' => [
'skip_invoice_custom_sections' => false,
'invoice_custom_section_codes' => [
'eu_bank_details'
]
],
'payment_method' => [
'payment_method_type' => 'provider',
'payment_method_id' => '1a901a90-1a90-1a90-1a90-1a901a901a90'
],
'consolidate_invoice' => true,
'activation_rules' => [
[
'type' => 'payment',
'timeout_hours' => 48
]
]
]
]),
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;
}HttpResponse<String> response = Unirest.post("https://core.nozle.app/api/v1/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"subscription\": {\n \"external_customer_id\": \"5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba\",\n \"plan_code\": \"premium\",\n \"external_id\": \"my_sub_1234567890\",\n \"billing_entity_code\": \"default\",\n \"name\": \"Repository A\",\n \"billing_time\": \"anniversary\",\n \"ending_at\": \"2022-10-08T00:00:00Z\",\n \"subscription_at\": \"2022-08-08T00:00:00Z\",\n \"plan_overrides\": {\n \"amount_cents\": 10000,\n \"amount_currency\": \"USD\",\n \"description\": \"Plan for early stage startups.\",\n \"invoice_display_name\": \"Startup plan\",\n \"name\": \"Startup\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"trial_period\": 5,\n \"minimum_commitment\": {\n \"amount_cents\": 100000,\n \"invoice_display_name\": \"Minimum Commitment (C1)\",\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n },\n \"charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"feature_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"code\": \"api_requests_charge\",\n \"invoice_display_name\": \"Setup\",\n \"min_amount_cents\": 0,\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"presentation_group_keys\": [\n {\n \"value\": \"region\",\n \"options\": {\n \"display_in_invoice\": true\n }\n }\n ]\n },\n \"filters\": [\n {\n \"properties\": {\n \"grouped_by\": [\n \"agent_name\"\n ],\n \"pricing_group_keys\": [\n \"agent_name\"\n ],\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"graduated_percentage_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"rate\": \"1\",\n \"flat_amount\": \"10\"\n }\n ],\n \"amount\": \"30\",\n \"free_units\": 100,\n \"package_size\": 1000,\n \"rate\": \"1\",\n \"fixed_amount\": \"0.5\",\n \"free_units_per_events\": 5,\n \"free_units_per_total_aggregation\": \"500\",\n \"per_transaction_max_amount\": \"3.75\",\n \"per_transaction_min_amount\": \"1.75\",\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"values\": {\n \"region\": [\n \"us-east-1\"\n ]\n },\n \"invoice_display_name\": \"AWS\"\n }\n ],\n \"tax_codes\": [\n \"french_standard_vat\"\n ],\n \"applied_pricing_unit\": {\n \"conversion_rate\": \"0.5\"\n }\n }\n ],\n \"fixed_charges\": [\n {\n \"id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"invoice_display_name\": \"Setup fee\",\n \"units\": 1,\n \"apply_units_immediately\": true,\n \"properties\": {\n \"amount\": \"30\",\n \"graduated_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ],\n \"volume_ranges\": [\n {\n \"from_value\": 0,\n \"to_value\": 10,\n \"flat_amount\": \"10\",\n \"per_unit_amount\": \"0.5\"\n }\n ]\n },\n \"tax_codes\": [\n \"french_standard_vat\"\n ]\n }\n ],\n \"usage_thresholds\": [\n {\n \"amount_cents\": 10000,\n \"threshold_display_name\": \"Threshold 1\",\n \"recurring\": true\n }\n ],\n \"metadata\": {\n \"external_id\": \"ext-123\",\n \"synced_at\": \"2024-01-15\"\n }\n },\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"eu_bank_details\"\n ]\n },\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n },\n \"consolidate_invoice\": true,\n \"activation_rules\": [\n {\n \"type\": \"payment\",\n \"timeout_hours\": 48\n }\n ]\n }\n}")
.asString();{
"subscription": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"billing_time": "anniversary",
"name": "Repository A",
"plan_code": "premium",
"status": "active",
"created_at": "2022-08-08T00:00:00Z",
"canceled_at": "2022-09-14T16:35:31Z",
"started_at": "2022-08-08T00:00:00Z",
"ending_at": "2022-10-08T00:00:00Z",
"subscription_at": "2022-08-08T00:00:00Z",
"terminated_at": "2022-09-14T16:35:31Z",
"previous_plan_code": null,
"next_plan_code": null,
"downgrade_plan_date": "2022-04-30",
"trial_ended_at": "2022-08-08T00:00:00Z",
"current_billing_period_started_at": "2022-08-08T00:00:00Z",
"current_billing_period_ending_at": "2022-09-08T00:00:00Z",
"on_termination_credit_note": "credit",
"on_termination_invoice": "generate",
"billing_entity_code": "default",
"plan_amount_cents": 10000,
"plan_amount_currency": "USD",
"applied_invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z",
"invoice_custom_section": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "EU Bank Details",
"code": "eu_bank_details",
"description": "This section contains the bank details for EU customers.",
"details": "Bank Name: Nozle Bank, IBAN: FR7630004000031234567890143",
"display_name": "Bank Details:",
"applied_to_organization": true,
"organization_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z"
},
"invoice_custom_section_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
],
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
},
"consolidate_invoice": true,
"cancellation_reason": "payment_failed",
"activated_at": "2022-08-08T00:00:00Z",
"activation_rules": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"type": "payment",
"timeout_hours": 48,
"status": "pending",
"created_at": "2022-08-08T00:00:00Z",
"updated_at": "2022-08-08T00:00:00Z",
"expires_at": "2022-08-10T00:00:00Z"
}
],
"plan": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "Startup",
"created_at": "2023-06-27T19:43:42Z",
"code": "startup",
"interval": "monthly",
"amount_cents": 10000,
"amount_currency": "USD",
"invoice_display_name": "Startup plan",
"description": "",
"trial_period": 5,
"pay_in_advance": true,
"bill_charges_monthly": null,
"bill_fixed_charges_monthly": null,
"minimum_commitment": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"amount_cents": 100000,
"created_at": "2022-04-29T08:59:51Z",
"plan_code": "premium",
"invoice_display_name": "Minimum Commitment (C1)",
"interval": "monthly",
"updated_at": "2022-04-29T08:59:51Z",
"taxes": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "TVA",
"code": "french_standard_vat",
"rate": 20,
"applied_to_organization": true,
"created_at": "2023-07-06T14:35:58Z",
"description": "French standard VAT"
}
]
},
"charges": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a91",
"lago_feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a91",
"feature_code": "requests",
"created_at": "2023-06-27T19:43:42Z",
"charge_model": "package",
"invoiceable": true,
"invoice_display_name": "Setup",
"pay_in_advance": false,
"regroup_paid_fees": null,
"prorated": false,
"min_amount_cents": 3000,
"properties": {
"amount": "30",
"free_units": 100,
"package_size": 1000
},
"filters": []
},
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a92",
"lago_feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a92",
"feature_code": "cpu",
"created_at": "2023-06-27T19:43:42Z",
"charge_model": "graduated",
"invoiceable": true,
"invoice_display_name": "Setup",
"pay_in_advance": false,
"regroup_paid_fees": null,
"prorated": false,
"min_amount_cents": 0,
"properties": {
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
},
{
"from_value": 11,
"to_value": null,
"flat_amount": "0",
"per_unit_amount": "0.4"
}
]
},
"filters": []
},
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a93",
"lago_feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a93",
"feature_code": "seats",
"created_at": "2023-06-27T19:43:42Z",
"charge_model": "standard",
"invoiceable": true,
"invoice_display_name": "Setup",
"pay_in_advance": true,
"regroup_paid_fees": null,
"prorated": false,
"min_amount_cents": 0,
"properties": {},
"filters": [
{
"invoice_display_name": "Europe",
"properties": {
"amount": "10"
},
"values": {
"region": [
"Europe"
]
}
},
{
"invoice_display_name": "USA",
"properties": {
"amount": "5"
},
"values": {
"region": [
"USA"
]
}
},
{
"invoice_display_name": "Africa",
"properties": {
"amount": "8"
},
"values": {
"region": [
"Africa"
]
}
}
]
},
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"lago_feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a94",
"feature_code": "storage",
"created_at": "2023-06-27T19:43:42Z",
"charge_model": "volume",
"invoiceable": true,
"invoice_display_name": "Setup",
"pay_in_advance": false,
"regroup_paid_fees": null,
"prorated": false,
"min_amount_cents": 0,
"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"
}
]
},
"filters": []
},
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a95",
"lago_feature_id": "1a901a90-1a90-1a90-1a90-1a901a901a95",
"feature_code": "payments",
"created_at": "2023-06-27T19:43:42Z",
"charge_model": "percentage",
"invoiceable": false,
"invoice_display_name": "Setup",
"pay_in_advance": true,
"regroup_paid_fees": "invoice",
"prorated": false,
"min_amount_cents": 0,
"properties": {
"rate": "1",
"fixed_amount": "0.5",
"free_units_per_events": 5,
"free_units_per_total_aggregation": "500"
},
"filters": []
}
],
"fixed_charges": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"lago_add_on_id": "2b802b80-2b80-2b80-2b80-2b802b802b80",
"code": "setup_fee",
"invoice_display_name": "Setup Fee",
"add_on_code": "setup",
"created_at": "2026-01-15T10:30:00Z",
"charge_model": "standard",
"pay_in_advance": true,
"prorated": false,
"properties": {
"amount": "500"
},
"units": 1,
"lago_parent_id": null,
"taxes": [
{
"lago_id": "3c703c70-3c70-3c70-3c70-3c703c703c70",
"name": "VAT",
"code": "vat_20",
"rate": 20,
"description": "Standard VAT rate",
"applied_to_organization": true,
"created_at": "2026-01-01T00:00:00Z"
}
]
},
{
"lago_id": "4d604d60-4d60-4d60-4d60-4d604d604d60",
"lago_add_on_id": "5e505e50-5e50-5e50-5e50-5e505e505e50",
"code": "support_tier",
"invoice_display_name": "Support Tier",
"add_on_code": "premium_support",
"created_at": "2026-01-15T10:30:00Z",
"charge_model": "graduated",
"pay_in_advance": false,
"prorated": true,
"properties": {
"graduated_ranges": [
{
"from_value": 0,
"to_value": 10,
"per_unit_amount": "5",
"flat_amount": "200"
},
{
"from_value": 11,
"to_value": null,
"per_unit_amount": "1",
"flat_amount": "300"
}
]
},
"units": 1,
"lago_parent_id": null,
"taxes": []
},
{
"lago_id": "6f406f40-6f40-6f40-6f40-6f406f406f40",
"lago_add_on_id": "7a307a30-7a30-7a30-7a30-7a307a307a30",
"code": "storage",
"invoice_display_name": "Storage Allocation",
"add_on_code": "cloud_storage",
"created_at": "2026-01-15T10:30:00Z",
"charge_model": "volume",
"pay_in_advance": false,
"prorated": false,
"properties": {
"volume_ranges": [
{
"from_value": 0,
"to_value": 100,
"per_unit_amount": "2",
"flat_amount": "1"
},
{
"from_value": 101,
"to_value": null,
"per_unit_amount": "1",
"flat_amount": "0"
}
]
},
"units": 50,
"lago_parent_id": null,
"taxes": []
}
],
"taxes": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "TVA",
"code": "french_standard_vat",
"rate": 20,
"applied_to_organization": true,
"created_at": "2023-07-06T14:35:58Z",
"description": "French standard VAT"
}
],
"usage_thresholds": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"threshold_display_name": "Threshold 1",
"amount_cents": 10000,
"recurring": true,
"created_at": "2023-06-27T19:43:42Z",
"updated_at": "2023-06-27T19:43:42Z"
}
],
"entitlements": [
{
"entitlement": {
"code": "seats",
"name": "Number of seats",
"description": "Number of users of the account",
"privileges": [
{
"code": "max",
"name": "Maximum",
"value_type": "integer",
"config": {},
"value": 10
},
{
"code": "max_admins",
"name": "Max Admins",
"value_type": "integer",
"config": {},
"value": 5
},
{
"code": "root",
"name": "Allow root user",
"value_type": "boolean",
"config": {},
"value": true
},
{
"code": "provider",
"name": "SSO Provider",
"value_type": "select",
"value": "google",
"config": {
"select_options": [
"google",
"okta"
]
}
}
]
}
}
],
"metadata": {
"external_id": "ext-123",
"synced_at": "2024-01-15",
"source": null
}
},
"applicable_usage_thresholds": [
{
"threshold_display_name": "Threshold 1",
"amount_cents": 10000,
"recurring": true
}
]
}
}{
"status": 400,
"error": "Bad request"
}{
"status": 401,
"error": "Unauthorized"
}{
"status": 404,
"error": "Not Found",
"code": "object_not_found"
}{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Subscription payload
Show child attributes
Show child attributes
Optionally, you can create a pre-authorization on the customer's card before creating a subscription. This process places a temporary hold (capture) for a specified amount on the customer's account, but does not actually withdraw the funds.
Important notes:
- The final amount due for the subscription is not known at the time of creation; it is determined only after the invoice is finalized.
- The payment intent generated for pre-authorization cannot be reused, as the final invoice amount may exceed the authorized amount.
- The payment intent is canceled immediately after creation, but this cancellation occurs asynchronously.
- For these reasons, it is recommended to use a small amount (such as $1) for pre-authorization. While this does not guarantee sufficient funds for the final payment, it helps reduce the likelihood of payment errors.
Show child attributes
Show child attributes
Response
Subscription created
Show child attributes
Show child attributes