subscriptions
Update a subscription
This endpoint allows you to update a subscription.
put/subscriptions/{external_id}
Query parameters
status'active' | 'pending'
Example:active
By default, this endpoint only return active subscriptions. If you want to update a subscription with a different status, you can specify it here.
Request body
Example request
{
"status": "active",
"subscription": {
"name": "Repository B",
"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",
"billable_metric_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"code": "api_requests_charge",
"invoice_display_name": "Setup",
"properties": {
"grouped_by": [
"agent_name"
],
"pricing_group_keys": [
"agent_name"
],
"graduated_ranges": [
{
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"graduated_percentage_ranges": [
{
"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": [
{
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"presentation_group_keys": [
{
"value": "region",
"options": {
"display_in_invoice": true
}
}
]
},
"filters": [
{
"invoice_display_name": "AWS",
"properties": {
"grouped_by": [
"agent_name"
],
"pricing_group_keys": [
"agent_name"
],
"graduated_ranges": [
{
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"graduated_percentage_ranges": [
{
"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": [
{
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
]
},
"values": {
"region": [
"us-east-1"
]
}
}
],
"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": [
{
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
],
"volume_ranges": [
{
"to_value": 10,
"flat_amount": "10",
"per_unit_amount": "0.5"
}
]
},
"tax_codes": [
"french_standard_vat"
]
}
],
"usage_thresholds": [
{
"threshold_display_name": "Threshold 1",
"amount_cents": 10000,
"recurring": true
}
],
"metadata": {
"external_id": "ext-123",
"synced_at": "2024-01-15"
}
},
"invoice_custom_section": {
"invoice_custom_section_codes": [
"eu_bank_details"
]
},
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
},
"billing_entity_code": "default",
"activation_rules": [
{
"type": "payment",
"timeout_hours": 48
}
]
}
}Response
Subscription updated
Example response
{
"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_entity_code": "default",
"billing_time": "anniversary",
"name": "Repository A",
"plan_code": "premium",
"plan_amount_cents": 10000,
"plan_amount_currency": "USD",
"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",
"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",
"applied_invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z",
"invoice_custom_section_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"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: Lago 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"
}
}
],
"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",
"expires_at": "2022-08-10T00:00:00Z",
"created_at": "2022-08-08T00:00:00Z",
"updated_at": "2022-08-08T00:00:00Z"
}
]
}
}