> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getlago.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a subscription

> This endpoint assigns a plan to a customer, creating or modifying a subscription. Ideal for initial subscriptions or plan changes (upgrades/downgrades).

<RequestExample>
  ```bash cURL theme={"dark"}
  LAGO_URL="https://api.getlago.com"
  API_KEY="__YOUR_API_KEY__"

  curl --location --request POST "$LAGO_URL/api/v1/subscriptions" \
    --header "Authorization: Bearer $API_KEY" \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "subscription": {
      "external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
      "plan_code": "premium",
      "name": "Repository A",
      "external_id": "my_sub_1234567890",
      "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,
        "charges": [
          {
            "id": "cha_12345",
            "billable_metric_id": "bm_12345",
            "invoice_display_name": "Setup",
            "min_amount_cents": 0,
            "tax_codes": [
              "standard_vat"
            ],
            "properties": {
              "graduated_ranges": [
                {
                  "from_value": 0,
                  "to_value": 10,
                  "flat_amount": "10",
                  "per_unit_amount": "0.5"
                }
              ]
            }
          },
          {
            "id": "cha_67890",
            "billable_metric_id": "bm_67890",
            "invoice_display_name": "FX Transfer",
            "min_amount_cents": 0,
            "properties": {
              "graduated_percentage_ranges": [
                {
                  "from_value": 0,
                  "to_value": 10,
                  "rate": "1",
                  "flat_amount": "10"
                }
              ]
            }
          },
          {
            "id": "cha_111213",
            "billable_metric_id": "bm_111213",
            "invoice_display_name": "API calls",
            "min_amount_cents": 0,
            "properties": {
              "amount": "30",
              "free_units": 100,
              "package_size": 1000
            }
          },
          {
            "id": "cha_141516",
            "billable_metric_id": "bm_141516",
            "invoice_display_name": "Interchange",
            "min_amount_cents": 0,
            "properties": {
              "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"
            }
          },
          {
            "id": "cha_171819",
            "billable_metric_id": "bm_171819",
            "invoice_display_name": "Seats",
            "min_amount_cents": 0,
            "properties": {
              "volume_ranges": [
                {
                  "from_value": 0,
                  "to_value": 10,
                  "flat_amount": "10",
                  "per_unit_amount": "0.5"
                }
              ]
            }
          },
          {
            "id": "cha_202122",
            "billable_metric_id": "bm_202122",
            "invoice_display_name": "Interchange",
            "min_amount_cents": 0,
            "filters": [
              {
                "values": {
                  "cloud": ["aws"],
                  "region": ["us-east-1"]
                },
                "properties": {
                  "graduated_ranges": [
                    {
                      "from_value": 0,
                      "to_value": 10,
                      "flat_amount": "10",
                      "per_unit_amount": "0.5"
                    }
                  ]
                }
              }
            ]
          }
        ]
      }
    }
  }'
  ```

  ```python Python theme={"dark"}
  from lago_python_client.client import Client
  from lago_python_client.exceptions import LagoApiError
  from lago_python_client.models import Subscription

  client = Client(api_key='__YOUR_API_KEY__')

  subscription = Subscription(
    external_customer_id="5eb02857-a71e-4ea2-bcf9-57d8885990ba",
    plan_code="startup_plan",
    external_id="sub_id_123456789",
    name="Repository A",
    subscription_at="2022-08-08T00:00:00Z",
    ending_at= "2023-08-08T00:00:00Z",
    billing_time="anniversary"
  )

  try:
      client.subscriptions.create(subscription)
  except LagoApiError as e:
      repair_broken_state(e)  # do something on error or raise your own exception
  ```

  ```ruby Ruby theme={"dark"}
  require 'lago-ruby-client'

  client = Lago::Api::Client.new(api_key: '__YOUR_API_KEY__')

  client.subscriptions.create(
    external_customer_id: "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
    plan_code: "startup_plan",
    external_id: "sub_id_123456789",
    name: "Repository A",
    subscription_at: "2022-08-08T00:00:00Z",
    ending_at: "2023-08-08T00:00:00Z",
    billing_time: "anniversary"
  )
  ```

  ```js Javascript theme={"dark"}
  import { Client, SubscriptionObject } from "lago-javascript-client";

  const subscriptionObject = {
    external_customer_id: "5eb02857-a71e-4ea2-bcf9-57d8885990ba",
    plan_code: "statup_plan",
    external_id: "sub_id_123456789",
    name: "Repository A",
    subscription_at: "2022-08-08T00:00:00Z",
    ending_at: "2023-08-08T00:00:00Z",
    billing_time: "anniversary" as SubscriptionObject["billingTime"],
  };

  await client.subscriptions.createSubscription({
    subscription: subscriptionObject,
  });
  ```

  ```go Go theme={"dark"}
  import "fmt"
  import "github.com/getlago/lago-go-client"

  func main() {
  lagoClient := lago.New().
      SetApiKey("__YOUR_API_KEY__")

  subscriptionAt := time.Date(2022, 8, 8, 0, 0, 0, 0, time.UTC)
  endingAt := time.Date(2023, 8, 8, 0, 0, 0, 0, time.UTC)
  subscriptionInput := &lago.SubscriptionInput{
      ExternalCustomerID: "5eb02857-a71e-4ea2-bcf9-57d8885990ba",
      PlanCode:           "startup_plan",
      SubscriptionAt:     &subscriptionAt,
      EndingAt:           &endingAt,
      BillingTime:        lago.Anniversary,
  }

  subscription, err := lagoClient.Subscription().Create(subscriptionInput)
  if err != nil {
      // Error is *lago.Error
      panic(err)
  }

  // subscription is *lago.Subscription
  fmt.Println(subscription)
  }
  ```
</RequestExample>


## OpenAPI

````yaml POST /subscriptions
openapi: 3.1.0
info:
  title: Lago API documentation
  description: >-
    Lago API allows your application to push customer information and metrics
    (events) from your application to the billing application.
  version: 1.46.0
  license:
    name: AGPLv3
    url: https://github.com/getlago/lago-openapi/blob/main/LICENSE
  contact:
    email: tech@getlago.com
servers:
  - url: https://api.getlago.com/api/v1
    description: US Lago cluster
  - url: https://api.eu.getlago.com/api/v1
    description: EU Lago cluster
security:
  - bearerAuth: []
tags:
  - name: activity_logs
    description: Everything about Activity logs
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/audit-logs/activity-logs-object
  - name: analytics
    description: Everything about Analytics
  - name: api_logs
    description: Everything about API logs
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/audit-logs/api-logs-object
  - name: billable_metrics
    description: Everything about Billable metric collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/billable-metrics/object
  - name: features
    description: Everything about Feature collection
    externalDocs:
      description: Find out more
      url: >-
        https://getlago.com/docs/api-reference/entitlements/features/feature-object
  - name: entitlements
    description: Everything about Entitlement collection
    externalDocs:
      description: Find out more
      url: >-
        https://getlago.com/docs/api-reference/entitlements/plan-entitlements/plan-entitlement-object
  - name: billing_entities
    description: Everything about Billing Entities
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/billing-entities/object
  - name: customers
    description: Everything about Customer collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/customers/object
  - name: plans
    description: Everything about Plan collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/plans/object
  - name: subscriptions
    description: Everything about Subscription collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/subscriptions/subscription-object
  - name: events
    description: Everything about Event collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/events/event-object
  - name: organizations
    description: Everything about Organization collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/organizations/organization-object
  - name: taxes
    description: Everything about Tax collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/taxes/tax-object
  - name: coupons
    description: Everything about Coupon collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/coupons/coupon-object
  - name: add_ons
    description: Everything about Add-on collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/add-ons/add-on-object
  - name: fees
    description: Everything about Fees
    externalDocs:
      description: Find out more
      url: >-
        https://getlago.com/docs/api-reference/invoices/invoice-object#fee-object
  - name: invoices
    description: Everything about Invoice collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/invoices/invoice-object
  - name: wallets
    description: Everything about Wallet collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/wallets/wallet-object
  - name: credit_notes
    description: Everything about Credit notes collection
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/credit-notes/credit-note-object
  - name: webhooks
    description: Everything about Webhooks
    externalDocs:
      description: Find out more
      url: >-
        https://getlago.com/docs/api-reference/webhooks/format---signature#1-retrieve-the-public-key
  - name: webhook_endpoints
    description: Everything about Webhook Endpoints
    externalDocs:
      description: Find out more
      url: >-
        https://getlago.com/docs/api-reference/webhook-endpoints/webhook-endpoint-object
  - name: payment_receipts
    description: Everything about Payment receipts
    externalDocs:
      description: Find out more
      url: >-
        https://getlago.com/docs/api-reference/payment-receipts/payment-receipt-object
  - name: payment_requests
    description: Everything about PaymentRequests
    externalDocs:
      description: Find out more
      url: >-
        https://getlago.com/docs/api-reference/payment-requests/payment-request-object
  - name: payments
    description: Everything about Payments
    externalDocs:
      description: Find out more
      url: https://getlago.com/docs/api-reference/payments/payment-object
  - name: payment_methods
    description: Everything about Payment Methods
    externalDocs:
      description: Find out more
      url: >-
        https://getlago.com/docs/api-reference/payment-methods/payment-method-object
externalDocs:
  description: Lago Github
  url: https://github.com/getlago
paths:
  /subscriptions:
    post:
      tags:
        - subscriptions
      summary: Assign a plan to a customer
      description: >-
        This endpoint assigns a plan to a customer, creating or modifying a
        subscription. Ideal for initial subscriptions or plan changes
        (upgrades/downgrades).
      operationId: createSubscription
      requestBody:
        description: Subscription payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubscriptionCreateInput'
        required: true
      responses:
        '200':
          description: Subscription created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionExtended'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
components:
  schemas:
    SubscriptionCreateInput:
      type: object
      required:
        - subscription
      properties:
        authorization:
          type: object
          description: >
            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.
          required:
            - amount_cents
            - amount_currency
          properties:
            amount_cents:
              type: integer
              example: 1000
              description: The amount of the authorization in cents.
            amount_currency:
              type: string
              example: USD
              description: The currency of the authorization.
        subscription:
          type: object
          required:
            - external_customer_id
            - plan_code
            - external_id
          properties:
            billing_entity_code:
              type: string
              example: default
              description: >-
                The code of the billing entity to be used for the subscription.
                If not provided, the default billing entity will be used.
            external_customer_id:
              type: string
              description: >-
                The customer external unique identifier (provided by your own
                application)
              example: 5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba
            plan_code:
              type: string
              example: premium
              description: >-
                The unique code representing the plan to be attached to the
                customer. This code must correspond to the `code` property of
                one of the active plans.
            name:
              type: string
              example: Repository A
              description: >-
                The display name of the subscription on an invoice. This field
                allows for customization of the subscription's name for billing
                purposes, especially useful when a single customer has multiple
                subscriptions using the same plan.
            external_id:
              type: string
              example: my_sub_1234567890
              description: >-
                The unique external identifier for the subscription. This
                identifier serves as an idempotency key, ensuring that each
                subscription is unique.
            billing_time:
              type: string
              description: >-
                The billing time for the subscription, which can be set as
                either `anniversary` or `calendar`. If not explicitly provided,
                it will default to `calendar`. The billing time determines the
                timing of recurring billing cycles for the subscription. By
                specifying `anniversary`, the billing cycle will be based on the
                specific date the subscription started (billed fully), while
                `calendar` sets the billing cycle at the first day of the
                week/month/year (billed with proration).
              example: anniversary
              enum:
                - calendar
                - anniversary
            ending_at:
              type: string
              format: date-time
              example: '2022-10-08T00:00:00Z'
              description: >-
                The effective end date of the subscription. If this field is set
                to null, the subscription will automatically renew. This date
                should be provided in ISO 8601 datetime format, and use
                Coordinated Universal Time (UTC).
            subscription_at:
              type: string
              format: date-time
              example: '2022-08-08T00:00:00Z'
              description: >-
                The start date for the subscription, allowing for the creation
                of subscriptions that can begin in the past or future. Please
                note that it cannot be used to update the start date of a
                pending subscription or schedule an upgrade/downgrade. The
                start_date should be provided in ISO 8601 datetime format and
                expressed in Coordinated Universal Time (UTC).
            plan_overrides:
              $ref: '#/components/schemas/PlanOverridesObject'
            invoice_custom_section:
              $ref: '#/components/schemas/InvoiceCustomSectionInput'
            payment_method:
              $ref: '#/components/schemas/PaymentMethodReference'
              description: >-
                Optional payment method to use for processing subscription
                payments.
    SubscriptionExtended:
      type: object
      required:
        - subscription
      properties:
        subscription:
          $ref: '#/components/schemas/SubscriptionObjectExtended'
    PlanOverridesObject:
      type: object
      description: Based plan overrides.
      properties:
        amount_cents:
          type: integer
          description: >-
            The base cost of the plan, excluding any applicable taxes, that is
            billed on a recurring basis. This value is defined at 0 if your plan
            is a pay-as-you-go plan.
          example: 10000
        amount_currency:
          $ref: '#/components/schemas/Currency'
          description: >-
            The currency of the plan. It indicates the monetary unit in which
            the plan's cost, including taxes and usage-based charges, is
            expressed.
          example: USD
        description:
          type: string
          description: The description on the plan.
          example: Plan for early stage startups.
        invoice_display_name:
          type: string
          description: >-
            Specifies the name that will be displayed on an invoice. If no value
            is set for this field, the name of the plan will be used as the
            default display name.
          example: Startup plan
        name:
          type: string
          description: The name of the plan.
          example: Startup
        tax_codes:
          $ref: '#/components/schemas/TaxCodes'
        trial_period:
          type: number
          description: >-
            The duration in days during which the base cost of the plan is
            offered for free.
          example: 5
        minimum_commitment:
          $ref: '#/components/schemas/MinimumCommitmentInput'
        charges:
          type: array
          description: Additional usage-based charges for this plan.
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
                description: Unique identifier of the charge created by Lago.
                example: 1a901a90-1a90-1a90-1a90-1a901a901a90
              billable_metric_id:
                type: string
                format: uuid
                example: 1a901a90-1a90-1a90-1a90-1a901a901a90
                description: Unique identifier of the billable metric created by Lago.
              code:
                type: string
                description: Unique code identifying the charge within the plan.
                example: api_requests_charge
              charge_model:
                $ref: '#/components/schemas/ChargeModelEnum'
              invoice_display_name:
                type: string
                description: >-
                  Specifies the name that will be displayed on an invoice. If no
                  value is set for this field, the name of the actual charge
                  will be used as the default display name.
                example: Setup
              min_amount_cents:
                type: integer
                description: >-
                  The minimum spending amount required for the charge, measured
                  in cents and excluding any applicable taxes. It indicates the
                  minimum amount that needs to be charged for each billing
                  period.
                example: 0
              properties:
                $ref: '#/components/schemas/ChargeProperties'
                description: List of all thresholds utilized for calculating the charge.
              filters:
                type: array
                description: >-
                  List of filters used to apply differentiated pricing based on
                  additional event properties.
                items:
                  $ref: '#/components/schemas/ChargeFilterInput'
              tax_codes:
                $ref: '#/components/schemas/TaxCodes'
              applied_pricing_unit:
                type: object
                description: >-
                  Updates the pricing unit conversion rate for this charge. Only
                  applies if the charge has applied pricing unit.
                properties:
                  conversion_rate:
                    type: string
                    description: >-
                      The conversion rate from pricing units to the plan's
                      currency.

                      This rate determines how many currency units (in the
                      plan's base currency) equal one pricing unit.

                      For example, if the plan uses USD and the conversion rate
                      is 0.5, then 1 pricing unit = $0.50 USD.
                    example: '0.5'
        fixed_charges:
          type: array
          description: Additional fixed charges for this plan.
          items:
            type: object
            required:
              - id
            properties:
              id:
                type: string
                format: uuid
                description: Unique identifier of the fixed charge created by Lago.
                example: 1a901a90-1a90-1a90-1a90-1a901a901a90
              invoice_display_name:
                type: string
                description: >-
                  Specifies the name that will be displayed on an invoice. If no
                  value is set for this field, the name of the actual charge
                  will be used as the default display name.
                example: Setup fee
              units:
                type: number
                description: >-
                  The number of units for the fixed charge. Defaults to 0 if not
                  provided.
                example: 1
                default: 0
              apply_units_immediately:
                type: boolean
                description: >-
                  Determines if the units should be applied immediately upon
                  assignment or deferred to the next billing cycle.
                example: true
              properties:
                $ref: '#/components/schemas/FixedChargeProperties'
                description: >-
                  List of all thresholds utilized for calculating the fixed
                  charge.
              tax_codes:
                $ref: '#/components/schemas/TaxCodes'
                description: List of taxes applied to the fixed charge.
        usage_thresholds:
          type: array
          description: List of usage thresholds applied to the subscription.
          items:
            $ref: '#/components/schemas/UsageThresholdInput'
        metadata:
          $ref: '#/components/schemas/MetadataInput'
    InvoiceCustomSectionInput:
      type: object
      description: >-
        Configuration for invoice custom sections to apply to invoices generated
        by this resource.
      properties:
        skip_invoice_custom_sections:
          type: boolean
          example: false
          description: >-
            Set to `true` to exclude all invoice custom sections from PDF
            generation for invoices related to this resource. When `true`,
            `invoice_custom_section_codes` is ignored.
        invoice_custom_section_codes:
          type: array
          items:
            type: string
          description: >-
            List of unique codes identifying the invoice custom sections to
            apply. These override the default invoice custom sections configured
            at the customer or billing entity level.
          example:
            - eu_bank_details
    PaymentMethodReference:
      type: object
      description: Reference to a specific payment method for processing the payment.
      properties:
        payment_method_type:
          type: string
          enum:
            - provider
            - manual
          description: The type of payment method to use.
          example: provider
        payment_method_id:
          type: string
          format: uuid
          description: >-
            The unique identifier of the payment method (required when using a
            specific provider payment method).
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
    SubscriptionObjectExtended:
      allOf:
        - $ref: '#/components/schemas/SubscriptionObject'
        - type: object
          properties:
            plan:
              $ref: '#/components/schemas/PlanObject'
            applicable_usage_thresholds:
              type: array
              items:
                $ref: '#/components/schemas/ApplicableUsageThreshold'
              description: List of usage thresholds applicable to this subscription.
    ApiErrorBadRequest:
      type: object
      required:
        - status
        - error
      properties:
        status:
          type: integer
          format: int32
          example: 400
        error:
          type: string
          example: Bad request
    ApiErrorUnauthorized:
      type: object
      required:
        - status
        - error
      properties:
        status:
          type: integer
          format: int32
          example: 401
        error:
          type: string
          example: Unauthorized
    ApiErrorNotFound:
      type: object
      required:
        - status
        - error
        - code
      properties:
        status:
          type: integer
          format: int32
          example: 404
        error:
          type: string
          example: Not Found
        code:
          type: string
          example: object_not_found
    ApiErrorUnprocessableEntity:
      type: object
      required:
        - status
        - error
        - code
        - error_details
      properties:
        status:
          type: integer
          format: int32
          example: 422
        error:
          type: string
          example: Unprocessable entity
        code:
          type: string
          example: validation_errors
        error_details:
          type: object
    Currency:
      type: string
      example: USD
      enum:
        - AED
        - AFN
        - ALL
        - AMD
        - ANG
        - AOA
        - ARS
        - AUD
        - AWG
        - AZN
        - BAM
        - BBD
        - BDT
        - BGN
        - BIF
        - BMD
        - BND
        - BOB
        - BRL
        - BSD
        - BWP
        - BYN
        - BZD
        - CAD
        - CDF
        - CHF
        - CLF
        - CLP
        - CNY
        - COP
        - CRC
        - CVE
        - CZK
        - DJF
        - DKK
        - DOP
        - DZD
        - EGP
        - ETB
        - EUR
        - FJD
        - FKP
        - GBP
        - GEL
        - GHS
        - GIP
        - GMD
        - GNF
        - GTQ
        - GYD
        - HKD
        - HNL
        - HRK
        - HTG
        - HUF
        - IDR
        - ILS
        - INR
        - ISK
        - JMD
        - JPY
        - KES
        - KGS
        - KHR
        - KMF
        - KRW
        - KYD
        - KZT
        - LAK
        - LBP
        - LKR
        - LRD
        - LSL
        - MAD
        - MDL
        - MGA
        - MKD
        - MMK
        - MNT
        - MOP
        - MRO
        - MUR
        - MVR
        - MWK
        - MXN
        - MYR
        - MZN
        - NAD
        - NGN
        - NIO
        - NOK
        - NPR
        - NZD
        - PAB
        - PEN
        - PGK
        - PHP
        - PKR
        - PLN
        - PYG
        - QAR
        - RON
        - RSD
        - RUB
        - RWF
        - SAR
        - SBD
        - SCR
        - SEK
        - SGD
        - SHP
        - SLL
        - SOS
        - SRD
        - STD
        - SZL
        - THB
        - TJS
        - TOP
        - TRY
        - TTD
        - TWD
        - TZS
        - UAH
        - UGX
        - USD
        - UYU
        - UZS
        - VND
        - VUV
        - WST
        - XAF
        - XCD
        - XOF
        - XPF
        - YER
        - ZAR
        - ZMW
    TaxCodes:
      type: array
      items:
        type: string
      description: List of unique code used to identify the taxes.
      example:
        - french_standard_vat
    MinimumCommitmentInput:
      type:
        - object
        - 'null'
      description: Minimum commitment for this plan.
      required:
        - amount_cents
      properties:
        amount_cents:
          type: integer
          description: The amount of the minimum commitment in cents.
          example: 100000
        invoice_display_name:
          type: string
          description: >-
            Specifies the name that will be displayed on an invoice. If no value
            is set for this field, the default name will be used as the display
            name.
          example: Minimum Commitment (C1)
        tax_codes:
          $ref: '#/components/schemas/TaxCodes'
    ChargeModelEnum:
      type: string
      description: >
        Specifies the pricing model used for the calculation of the final fee.
        It can be any of the following values:
          - [`dynamic`](https://docs.getlago.com/guide/plans/charges/charge-models/dynamic)
          - [`graduated_percentage`](https://docs.getlago.com/guide/plans/charges/charge-models/graduated-percentage)
          - [`graduated`](https://docs.getlago.com/guide/plans/charges/charge-models/graduated)
          - [`package`](https://docs.getlago.com/guide/plans/charges/charge-models/package)
          - [`percentage`](https://docs.getlago.com/guide/plans/charges/charge-models/percentage)
          - [`standard`](https://docs.getlago.com/guide/plans/charges/charge-models/standard)
          - [`volume`](https://docs.getlago.com/guide/plans/charges/charge-models/volume)
      enum:
        - dynamic
        - graduated
        - graduated_percentage
        - package
        - percentage
        - standard
        - volume
    ChargeProperties:
      type: object
      properties:
        grouped_by:
          type: array
          description: >-
            The list of event properties that are used to group the events on
            the invoice for a `standard` charge model.

            **DEPRECATED** Replaced by `pricing_group_keys`.
          items:
            type: string
          example:
            - agent_name
          deprecated: true
        pricing_group_keys:
          type: array
          description: >-
            The list of event properties that are used to group the events on
            the invoice.
          items:
            type: string
          example:
            - agent_name
        graduated_ranges:
          type: array
          description: >-
            Graduated ranges, sorted from bottom to top tiers, used for a
            `graduated` charge model.
          items:
            type: object
            required:
              - from_value
              - to_value
              - flat_amount
              - per_unit_amount
            properties:
              from_value:
                type: integer
                description: >-
                  Specifies the lower value of a tier for a `graduated` charge
                  model. It must be either 0 or the previous range's `to_value +
                  1` to maintain the proper sequence of values.
                example: 0
              to_value:
                type:
                  - integer
                  - 'null'
                description: >-
                  Specifies the highest value of a tier for a `graduated` charge
                  model.

                  - This value must be higher than the from_value of the same
                  tier.

                  - This value must be null for the last tier.
                example: 10
              flat_amount:
                type: string
                pattern: ^[0-9]+.?[0-9]*$
                description: >-
                  The flat amount for a whole tier, excluding tax, for a
                  `graduated` charge model. It is expressed as a decimal value.
                example: '10'
              per_unit_amount:
                type: string
                pattern: ^[0-9]+.?[0-9]*$
                description: >-
                  The unit price, excluding tax, for a specific tier of a
                  `graduated` charge model. It is expressed as a decimal value.
                example: '0.5'
        graduated_percentage_ranges:
          type: array
          description: >-
            Graduated percentage ranges, sorted from bottom to top tiers, used
            for a `graduated_percentage` charge model.
          items:
            type: object
            required:
              - from_value
              - to_value
              - rate
              - flat_amount
            properties:
              from_value:
                type: integer
                description: >-
                  Specifies the lower value of a tier for a
                  `graduated_percentage` charge model. It must be either 0 or
                  the previous range's `to_value + 1` to maintain the proper
                  sequence of values.
                example: 0
              to_value:
                type:
                  - integer
                  - 'null'
                description: >-
                  Specifies the highest value of a tier for a
                  `graduated_percentage` charge model.

                  - This value must be higher than the from_value of the same
                  tier.

                  - This value must be null for the last tier.
                example: 10
              rate:
                type: string
                format: ^[0-9]+.?[0-9]*$
                description: >-
                  The percentage rate that is applied to the amount of each
                  transaction in the tier for a `graduated_percentage` charge
                  model. It is expressed as a decimal value.
                example: '1'
              flat_amount:
                type: string
                format: ^[0-9]+.?[0-9]*$
                description: >-
                  The flat amount for a whole tier, excluding tax, for a
                  `graduated_percentage` charge model. It is expressed as a
                  decimal value.
                example: '10'
        amount:
          type: string
          pattern: ^[0-9]+.?[0-9]*$
          description: >-
            - The unit price, excluding tax, for a `standard` charge model. It
            is expressed as a decimal value.

            - The amount, excluding tax, for a complete set of units in a
            `package` charge model. It is expressed as a decimal value.
          example: '30'
        free_units:
          type: integer
          description: >-
            The quantity of units that are provided free of charge for each
            billing period in a `package` charge model. This field specifies the
            number of units that customers can use without incurring any
            additional cost during each billing cycle.
          example: 100
        package_size:
          type: integer
          description: >-
            The quantity of units included in each pack or set for a `package`
            charge model. It indicates the number of units that are bundled
            together as a single package or set within the pricing structure.
          example: 1000
        rate:
          type: string
          pattern: ^[0-9]+.?[0-9]*$
          description: >-
            The percentage rate that is applied to the amount of each
            transaction for a `percentage` charge model. It is expressed as a
            decimal value.
          example: '1'
        fixed_amount:
          type: string
          pattern: ^[0-9]+.?[0-9]*$
          description: >-
            The fixed fee that is applied to each transaction for a `percentage`
            charge model. It is expressed as a decimal value.
          example: '0.5'
        free_units_per_events:
          type:
            - integer
            - 'null'
          description: >-
            The count of transactions that are not impacted by the `percentage`
            rate and fixed fee in a percentage charge model. This field
            indicates the number of transactions that are exempt from the
            calculation of charges based on the specified percentage rate and
            fixed fee.
          example: 5
        free_units_per_total_aggregation:
          type:
            - string
            - 'null'
          pattern: ^[0-9]+.?[0-9]*$
          description: >-
            The transaction amount that is not impacted by the `percentage` rate
            and fixed fee in a percentage charge model. This field indicates the
            portion of the transaction amount that is exempt from the
            calculation of charges based on the specified percentage rate and
            fixed fee.
          example: '500'
        per_transaction_max_amount:
          type:
            - string
            - 'null'
          format: ^[0-9]+.?[0-9]*$
          description: >-
            Specifies the maximum allowable spending for a single transaction.
            Working as a transaction cap.
          example: '3.75'
        per_transaction_min_amount:
          type:
            - string
            - 'null'
          format: ^[0-9]+.?[0-9]*$
          description: >-
            Specifies the minimum allowable spending for a single transaction.
            Working as a transaction floor.
          example: '1.75'
        volume_ranges:
          type: array
          description: >-
            Volume ranges, sorted from bottom to top tiers, used for a `volume`
            charge model.
          items:
            type: object
            required:
              - from_value
              - to_value
              - flat_amount
              - per_unit_amount
            properties:
              from_value:
                type: integer
                description: >-
                  Specifies the lower value of a tier for a `volume` charge
                  model. It must be either 0 or the previous range's `to_value +
                  1` to maintain the proper sequence of values.
                example: 0
              to_value:
                type:
                  - integer
                  - 'null'
                description: >-
                  Specifies the highest value of a tier for a `volume` charge
                  model.

                  - This value must be higher than the `from_value` of the same
                  tier.

                  - This value must be `null` for the last tier.
                example: 10
              flat_amount:
                type: string
                pattern: ^[0-9]+.?[0-9]*$
                description: >-
                  The flat amount for a whole tier, excluding tax, for a
                  `volume` charge model. It is expressed as a decimal value.
                example: '10'
              per_unit_amount:
                type: string
                pattern: ^[0-9]+.?[0-9]*$
                description: >-
                  The unit price, excluding tax, for a specific tier of a
                  `volume` charge model. It is expressed as a decimal value.
                example: '0.5'
    ChargeFilterInput:
      type: object
      description: >-
        Values used to apply differentiated pricing based on additional event
        properties.
      required:
        - properties
        - values
      properties:
        invoice_display_name:
          type:
            - string
            - 'null'
          description: >-
            Specifies the name that will be displayed on an invoice. If no value
            is set for this field, the values of the filter will be used as the
            default display name.
          example: AWS
        properties:
          $ref: '#/components/schemas/ChargeProperties'
          description: List of all thresholds utilized for calculating the charge.
        values:
          type: object
          description: >-
            List of possible filter values. The key and values must match one of
            the billable metric filters.
          additionalProperties:
            type: array
            items:
              type: string
          example:
            region:
              - us-east-1
    FixedChargeProperties:
      type: object
      properties:
        amount:
          type: string
          pattern: ^[0-9]+.?[0-9]*$
          description: >-
            - The unit price, excluding tax, for a `standard` charge model. It
            is expressed as a decimal value.

            - The amount, excluding tax, for a complete set of units in a
            `package` charge model. It is expressed as a decimal value.
          example: '30'
        graduated_ranges:
          type: array
          description: >-
            Graduated ranges, sorted from bottom to top tiers, used for a
            `graduated` charge model.
          items:
            type: object
            required:
              - from_value
              - to_value
              - flat_amount
              - per_unit_amount
            properties:
              from_value:
                type: integer
                description: >-
                  Specifies the lower value of a tier for a `graduated` charge
                  model. It must be either 0 or the previous range's `to_value +
                  1` to maintain the proper sequence of values.
                example: 0
              to_value:
                type:
                  - integer
                  - 'null'
                description: >-
                  Specifies the highest value of a tier for a `graduated` charge
                  model.

                  - This value must be higher than the from_value of the same
                  tier.

                  - This value must be null for the last tier.
                example: 10
              flat_amount:
                type: string
                pattern: ^[0-9]+.?[0-9]*$
                description: >-
                  The flat amount for a whole tier, excluding tax, for a
                  `graduated` charge model. It is expressed as a decimal value.
                example: '10'
              per_unit_amount:
                type: string
                pattern: ^[0-9]+.?[0-9]*$
                description: >-
                  The unit price, excluding tax, for a specific tier of a
                  `graduated` charge model. It is expressed as a decimal value.
                example: '0.5'
        volume_ranges:
          type: array
          description: >-
            Volume ranges, sorted from bottom to top tiers, used for a `volume`
            charge model.
          items:
            type: object
            required:
              - from_value
              - to_value
              - flat_amount
              - per_unit_amount
            properties:
              from_value:
                type: integer
                description: >-
                  Specifies the lower value of a tier for a `volume` charge
                  model. It must be either 0 or the previous range's `to_value +
                  1` to maintain the proper sequence of values.
                example: 0
              to_value:
                type:
                  - integer
                  - 'null'
                description: >-
                  Specifies the highest value of a tier for a `volume` charge
                  model.

                  - This value must be higher than the `from_value` of the same
                  tier.

                  - This value must be `null` for the last tier.
                example: 10
              flat_amount:
                type: string
                pattern: ^[0-9]+.?[0-9]*$
                description: >-
                  The flat amount for a whole tier, excluding tax, for a
                  `volume` charge model. It is expressed as a decimal value.
                example: '10'
              per_unit_amount:
                type: string
                pattern: ^[0-9]+.?[0-9]*$
                description: >-
                  The unit price, excluding tax, for a specific tier of a
                  `volume` charge model. It is expressed as a decimal value.
                example: '0.5'
    UsageThresholdInput:
      type: object
      required:
        - amount_cents
      properties:
        threshold_display_name:
          type:
            - string
            - 'null'
          description: The display name of the usage threshold.
          example: Threshold 1
        amount_cents:
          type: integer
          description: The amount to reach to trigger a `progressive_billing` invoice.
          example: 10000
        recurring:
          type: boolean
          description: >-
            This field when set to `true` indicates that a `progressive_billing`
            invoice will be created every time the lifetime usage increases by
            the specified amount.
          example: true
          default: false
    MetadataInput:
      type: object
      description: >-
        Metadata to set as key-value pairs. Keys are strings (max 100
        characters), values can be strings (max 255 characters) or null.
      additionalProperties:
        type:
          - string
          - 'null'
      example:
        external_id: ext-123
        synced_at: '2024-01-15'
    SubscriptionObject:
      type: object
      required:
        - billing_time
        - canceled_at
        - created_at
        - current_billing_period_ending_at
        - current_billing_period_started_at
        - downgrade_plan_date
        - ending_at
        - external_customer_id
        - external_id
        - lago_customer_id
        - lago_id
        - name
        - next_plan_code
        - on_termination_credit_note
        - on_termination_invoice
        - plan_code
        - previous_plan_code
        - started_at
        - status
        - subscription_at
        - terminated_at
        - trial_ended_at
      properties:
        lago_id:
          type: string
          format: uuid
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          description: >-
            Unique identifier assigned to the subscription within the Lago
            application. This ID is exclusively created by Lago and serves as a
            unique identifier for the subscription's record within the Lago
            system
        external_id:
          type: string
          example: 5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba
          description: >-
            The subscription external unique identifier (provided by your own
            application).
        lago_customer_id:
          type: string
          format: uuid
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          description: >-
            Unique identifier assigned to the customer within the Lago
            application. This ID is exclusively created by Lago and serves as a
            unique identifier for the customer's record within the Lago system
        external_customer_id:
          type: string
          example: 5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba
          description: >-
            The customer external unique identifier (provided by your own
            application).
        billing_time:
          type: string
          description: >-
            The billing time for the subscription, which can be set as either
            `anniversary` or `calendar`. If not explicitly provided, it will
            default to `calendar`. The billing time determines the timing of
            recurring billing cycles for the subscription. By specifying
            `anniversary`, the billing cycle will be based on the specific date
            the subscription started (billed fully), while `calendar` sets the
            billing cycle at the first day of the week/month/year (billed with
            proration).
          example: anniversary
          enum:
            - calendar
            - anniversary
        name:
          type:
            - string
            - 'null'
          example: Repository A
          description: >-
            The display name of the subscription on an invoice. This field
            allows for customization of the subscription's name for billing
            purposes, especially useful when a single customer has multiple
            subscriptions using the same plan.
        plan_code:
          type: string
          example: premium
          description: >-
            The unique code representing the plan to be attached to the
            customer. This code must correspond to the `code` property of one of
            the active plans.
        plan_amount_cents:
          type: integer
          description: >-
            The base cost of the related plan, excluding any applicable taxes,
            that is billed on a recurring basis.
          example: 10000
        plan_amount_currency:
          $ref: '#/components/schemas/Currency'
          description: >-
            The currency of the related plan. It indicates the monetary unit in
            which the plan's cost, including taxes and usage-based charges, is
            expressed.
          example: USD
        status:
          type: string
          description: >-
            The status of the subscription, which can have the following values:

            - `active`: the subscription is currently active and applied to the
            customer.

            - `canceled`: the subscription has been stopped before its
            activation. This can occur when two consecutive downgrades have been
            applied to a customer or when a subscription with a pending status
            is terminated.

            - `pending`: a previous subscription has been downgraded, and the
            current one is awaiting automatic activation at the end of the
            billing period.

            - `terminated`: the subscription is no longer active.
          example: active
          enum:
            - active
            - canceled
            - pending
            - terminated
        created_at:
          type: string
          format: date-time
          example: '2022-08-08T00:00:00Z'
          description: >-
            The creation date of the subscription, represented in ISO 8601
            datetime format and expressed in Coordinated Universal Time (UTC).
            This date provides a timestamp indicating when the subscription was
            initially created.
        canceled_at:
          type:
            - string
            - 'null'
          format: date-time
          example: '2022-09-14T16:35:31Z'
          description: >-
            The cancellation date of the subscription. This field is not null
            when the subscription is `canceled`. This date should be provided in
            ISO 8601 datetime format and expressed in Coordinated Universal Time
            (UTC).
        started_at:
          type:
            - string
            - 'null'
          format: date-time
          example: '2022-08-08T00:00:00Z'
          description: >-
            The effective start date of the subscription. This field can be null
            if the subscription is `pending` or `canceled`. This date should be
            provided in ISO 8601 datetime format and expressed in Coordinated
            Universal Time (UTC).
        ending_at:
          type:
            - string
            - 'null'
          format: date-time
          example: '2022-10-08T00:00:00Z'
          description: >-
            The effective end date of the subscription. If this field is set to
            null, the subscription will automatically renew. This date should be
            provided in ISO 8601 datetime format, and use Coordinated Universal
            Time (UTC).
        subscription_at:
          type: string
          format: date-time
          example: '2022-08-08T00:00:00Z'
          description: >-
            The anniversary date and time of the initial subscription. This date
            serves as the basis for billing subscriptions with `anniversary`
            billing time. The `anniversary_date` should be provided in ISO 8601
            datetime format and expressed in Coordinated Universal Time (UTC).
        terminated_at:
          type:
            - string
            - 'null'
          format: date-time
          example: '2022-09-14T16:35:31Z'
          description: >-
            The termination date of the subscription. This field is not null
            when the subscription is `terminated`. This date should be provided
            in ISO 8601 datetime format and expressed in Coordinated Universal
            Time (UTC)
        previous_plan_code:
          type:
            - string
            - 'null'
          example: null
          description: >-
            The code identifying the previous plan associated with this
            subscription.
        next_plan_code:
          type:
            - string
            - 'null'
          example: null
          description: The code identifying the next plan in the case of a downgrade.
        downgrade_plan_date:
          type:
            - string
            - 'null'
          format: date
          example: '2022-04-30'
          description: >-
            The date when the plan will be downgraded, represented in ISO 8601
            date format.
        trial_ended_at:
          type:
            - string
            - 'null'
          format: date-time
          example: '2022-08-08T00:00:00Z'
          description: >-
            The date when the free trial is ended, represented in ISO 8601 date
            format.
        current_billing_period_started_at:
          type:
            - string
            - 'null'
          format: date-time
          example: '2022-08-08T00:00:00Z'
          description: >-
            The date and time when the current billing period started,
            represented in ISO 8601 date format.
        current_billing_period_ending_at:
          type:
            - string
            - 'null'
          format: date-time
          example: '2022-09-08T00:00:00Z'
          description: >-
            The date and time when the current billing period ends, represented
            in ISO 8601 date format.
        on_termination_credit_note:
          type:
            - string
            - 'null'
          description: >
            When a pay-in-advance subscription is terminated before the end of
            its billing period, we generate a credit note for the unused
            subscription time by default.

            This field allows you to control the behavior of the credit note
            generation:


            - `credit`: A credit note is generated for the unused subscription
            time. The unused amount is credited back to the customer.

            - `refund`: A credit note is generated for the unused subscription
            time. If the invoice is paid or partially paid, the unused paid
            amount is refunded; any unpaid unused amount is credited back to the
            customer.

            - `offset`: A credit note is generated for the unused subscription
            time. If the invoice is paid or partially paid, the unused paid
            amount is refunded; any unpaid unused amount is applied to the
            invoice reducing its amount due.

            - `skip`: No credit note is generated for the unused subscription
            time.


            _Note: This field is only applicable to pay-in-advance plans and
            will be `null` for pay-in-arrears plans._
          example: credit
          enum:
            - credit
            - refund
            - offset
            - skip
        on_termination_invoice:
          type:
            - string
          example: generate
          enum:
            - generate
            - skip
          default: generate
          description: >
            When a subscription is terminated before the end of its billing
            period, we generate an invoice for the unbilled usage.

            This field allows you to control the behavior of the invoice
            generation:


            - `generate`: An invoice is generated for the unbilled usage.

            - `skip`: No invoice is generated for the unbilled usage.
        applied_invoice_custom_sections:
          description: >-
            The invoice custom sections applied to invoices generated by this
            subscription.
          type: array
          items:
            $ref: '#/components/schemas/AppliedInvoiceCustomSectionObject'
        payment_method:
          $ref: '#/components/schemas/PaymentMethodReference'
          description: >-
            The payment method assigned to this subscription for processing
            payments.
    PlanObject:
      type: object
      required:
        - lago_id
        - name
        - created_at
        - code
        - interval
        - amount_cents
        - amount_currency
      properties:
        lago_id:
          type: string
          format: uuid
          description: Unique identifier of the plan created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        name:
          type: string
          description: The name of the plan.
          example: Startup
        invoice_display_name:
          type: string
          description: >-
            Specifies the name that will be displayed on an invoice. If no value
            is set for this field, the name of the plan will be used as the
            default display name.
          example: Startup plan
        created_at:
          type: string
          format: date-time
          description: >-
            The date and time when the plan was created. It is expressed in UTC
            format according to the ISO 8601 datetime standard. This field
            provides the timestamp for the exact moment when the plan was
            initially created.
          example: '2023-06-27T19:43:42Z'
        code:
          type: string
          description: >-
            The code of the plan. It serves as a unique identifier associated
            with a particular plan. The code is typically used for internal or
            system-level identification purposes, like assigning a subscription,
            for instance.
          example: startup
        interval:
          type: string
          description: >-
            The interval used for recurring billing. It represents the frequency
            at which subscription billing occurs. The interval can be one of the
            following values: `yearly`, `semiannual`, `quarterly`, `monthly` or
            `weekly`.
          enum:
            - weekly
            - monthly
            - quarterly
            - semiannual
            - yearly
          example: monthly
        description:
          type: string
          description: The description on the plan.
          example: ''
        amount_cents:
          type: integer
          description: >-
            The base cost of the plan, excluding any applicable taxes, that is
            billed on a recurring basis. This value is defined at 0 if your plan
            is a pay-as-you-go plan.
          example: 10000
        amount_currency:
          $ref: '#/components/schemas/Currency'
          description: >-
            The currency of the plan. It indicates the monetary unit in which
            the plan's cost, including taxes and usage-based charges, is
            expressed.
          example: USD
        trial_period:
          type: number
          description: >-
            The duration in days during which the base cost of the plan is
            offered for free.
          example: 5
        pay_in_advance:
          type: boolean
          description: >-
            This field determines the billing timing for the plan. When set to
            `true`, the base cost of the plan is due at the beginning of each
            billing period. Conversely, when set to `false`, the base cost of
            the plan is due at the end of each billing period.
          example: true
        bill_charges_monthly:
          type:
            - boolean
            - 'null'
          description: >-
            This field, when set to `true`, enables to invoice usage-based
            charges on monthly basis, even if the cadence of the plan is yearly
            or semiannual. This allows customers to pay charges overage on a
            monthly basis. This can be set to true only if the plan's interval
            is `yearly` or `semiannual`.
          example: null
        bill_fixed_charges_monthly:
          type:
            - boolean
            - 'null'
          description: >-
            This field, when set to `true`, enables to invoice fixed charges on
            monthly basis, even if the cadence of the plan is yearly or
            semiannual. This allows customers to pay fixed charges on a monthly
            basis. This can be set to true only if the plan's interval is
            `yearly` or `semiannual`.
          example: null
        minimum_commitment:
          $ref: '#/components/schemas/MinimumCommitmentObject'
        charges:
          type: array
          items:
            $ref: '#/components/schemas/ChargeObject'
          description: Additional usage-based charges for this plan.
          example:
            - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a91
              lago_billable_metric_id: 1a901a90-1a90-1a90-1a90-1a901a901a91
              billable_metric_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_billable_metric_id: 1a901a90-1a90-1a90-1a90-1a901a901a92
              billable_metric_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_billable_metric_id: 1a901a90-1a90-1a90-1a90-1a901a901a93
              billable_metric_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_billable_metric_id: 1a901a90-1a90-1a90-1a90-1a901a901a94
              billable_metric_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_billable_metric_id: 1a901a90-1a90-1a90-1a90-1a901a901a95
              billable_metric_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:
          type: array
          description: List of fixed charges for this plan.
          items:
            $ref: '#/components/schemas/FixedChargeObject'
          example:
            - 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:
          type: array
          description: All taxes applied to the plan.
          items:
            $ref: '#/components/schemas/TaxObject'
        usage_thresholds:
          type: array
          description: List of usage thresholds applied to the plan.
          items:
            $ref: '#/components/schemas/UsageThresholdObject'
        entitlements:
          type: array
          description: >-
            List of all feature entitlements and their privileges available for
            this plan.
          items:
            $ref: '#/components/schemas/PlanEntitlement'
        metadata:
          $ref: '#/components/schemas/MetadataObject'
    ApplicableUsageThreshold:
      type: object
      required:
        - threshold_display_name
        - amount_cents
        - recurring
      properties:
        threshold_display_name:
          type:
            - string
            - 'null'
          description: The display name of the usage threshold.
          example: Threshold 1
        amount_cents:
          type: integer
          description: The amount to reach to trigger a `progressive_billing` invoice.
          example: 10000
        recurring:
          type: boolean
          description: >-
            This field when set to `true` indicates that a `progressive_billing`
            invoice will be created every time the lifetime usage increases by
            the specified amount.
          example: true
    AppliedInvoiceCustomSectionObject:
      type: object
      required:
        - lago_id
        - created_at
        - invoice_custom_section
      properties:
        lago_id:
          type: string
          format: uuid
          description: >-
            Unique identifier of the applied invoice custom section in the Lago
            application.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        created_at:
          type: string
          format: date-time
          description: >-
            The date of the applied invoice custom section creation, represented
            in ISO 8601 datetime format and expressed in Coordinated Universal
            Time (UTC).
          example: '2023-07-06T14:35:58Z'
        invoice_custom_section_id:
          deprecated: true
          type: string
          format: uuid
          description: Unique identifier of the invoice custom section that was applied.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        invoice_custom_section:
          $ref: '#/components/schemas/InvoiceCustomSectionObject'
    MinimumCommitmentObject:
      type:
        - object
        - 'null'
      required:
        - lago_id
        - amount_cents
        - created_at
      properties:
        lago_id:
          type: string
          format: uuid
          description: Unique identifier of the minimum commitment, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        plan_code:
          type: string
          example: premium
          description: >-
            The unique code representing the plan to be attached to the
            customer.
        amount_cents:
          type: integer
          description: The amount of the minimum commitment in cents.
          example: 100000
        invoice_display_name:
          type: string
          description: >-
            Specifies the name that will be displayed on an invoice. If no value
            is set for this field, the default name will be used as the display
            name.
          example: Minimum Commitment (C1)
        interval:
          type: string
          description: >-
            The interval used for recurring billing. It represents the frequency
            at which subscription billing occurs. The interval can be one of the
            following values: `yearly`, `semiannual`, `quarterly`, `monthly` or
            `weekly`.
          enum:
            - weekly
            - monthly
            - quarterly
            - semiannual
            - yearly
          example: monthly
        created_at:
          type: string
          format: date-time
          description: >-
            The date and time when the minimum commitment was created. It is
            expressed in UTC format according to the ISO 8601 datetime standard.
            This field provides the timestamp for the exact moment when the
            minimum commitment was initially created.
          example: '2022-04-29T08:59:51Z'
        updated_at:
          type: string
          format: date-time
          description: >-
            The date and time when the minimum commitment was updated. It is
            expressed in UTC format according to the ISO 8601 datetime standard.
            This field provides the timestamp for the exact moment when the
            minimum commitment was initially created.
          example: '2022-04-29T08:59:51Z'
        taxes:
          type: array
          description: All taxes applied to the minimum commitment.
          items:
            $ref: '#/components/schemas/TaxObject'
    ChargeObject:
      type: object
      required:
        - lago_id
        - lago_billable_metric_id
        - billable_metric_code
        - created_at
        - charge_model
        - invoiceable
        - regroup_paid_fees
        - pay_in_advance
        - prorated
        - min_amount_cents
        - properties
        - filters
      properties:
        lago_id:
          type: string
          format: uuid
          description: Unique identifier of charge, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_billable_metric_id:
          type: string
          format: uuid
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          description: Unique identifier of the billable metric created by Lago.
        code:
          type:
            - string
            - 'null'
          description: Unique code identifying the charge within the plan.
          example: api_requests_charge
        billable_metric_code:
          type: string
          description: Unique code identifying a billable metric.
          example: requests
        invoice_display_name:
          type:
            - string
            - 'null'
          description: >-
            Specifies the name that will be displayed on an invoice. If no value
            is set for this field, the name of the actual charge will be used as
            the default display name.
          example: Setup
        created_at:
          type: string
          format: date-time
          description: >-
            The date and time when the charge was created. It is expressed in
            UTC format according to the ISO 8601 datetime standard.
          example: '2022-09-14T16:35:31Z'
        charge_model:
          $ref: '#/components/schemas/ChargeModelEnum'
        pay_in_advance:
          type: boolean
          description: >-
            This field determines the billing timing for this specific
            usage-based charge. When set to `true`, the charge is due and
            invoiced immediately. Conversely, when set to `false`, the charge is
            due and invoiced at the end of each billing period.
          example: true
        invoiceable:
          type: boolean
          description: >-
            This field specifies whether the charge should be included in a
            proper invoice. If set to `false`, no invoice will be issued for
            this charge. You can only set it to `false` when `pay_in_advance` is
            `true`.
          example: true
        regroup_paid_fees:
          type:
            - string
            - 'null'
          enum:
            - null
            - invoice
          description: >-
            This setting can only be configured if `pay_in_advance` is `true`
            and `invoiceable` is `false`.

            This field determines whether and when the charge fee should be
            included in

            the invoice. If `null`, no invoice will be issued for this charge
            fee.

            If `invoice`, an invoice will be generated at the end of the period,

            consolidating all charge fees with a succeeded payment status.
          example: invoice
        prorated:
          type: boolean
          example: false
          description: >-
            Specifies whether a charge is prorated based on the remaining number
            of days in the billing period or billed fully.


            - If set to `true`, the charge is prorated based on the remaining
            days in the current billing period.

            - If set to `false`, the charge is billed in full.

            - If not defined in the request, default value is `false`.
        min_amount_cents:
          type: integer
          description: >-
            The minimum spending amount required for the charge, measured in
            cents and excluding any applicable taxes. It indicates the minimum
            amount that needs to be charged for each billing period.
          example: 1200
        properties:
          $ref: '#/components/schemas/ChargeProperties'
          description: List of all thresholds utilized for calculating the charge.
        filters:
          type: array
          description: >-
            List of filters used to apply differentiated pricing based on
            additional event properties.
          items:
            $ref: '#/components/schemas/ChargeFilterObject'
        taxes:
          type: array
          description: All taxes applied to the charge.
          items:
            $ref: '#/components/schemas/TaxObject'
        applied_pricing_unit:
          type:
            - object
            - 'null'
          required:
            - code
            - conversion_rate
          description: The pricing unit applied to the charge.
          properties:
            code:
              type: string
              description: The code of the pricing unit.
              example: unit_code
            conversion_rate:
              type: string
              description: The conversion rate from pricing units to the plan's currency.
              example: '0.5'
        accepts_target_wallet:
          type:
            - boolean
            - 'null'
          description: >-
            Specifies whether the charge accepts a target wallet for prepaid
            credits deduction.
          example: false
        lago_parent_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Unique identifier of the parent charge (if this is an override).
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
    FixedChargeObject:
      type: object
      required:
        - lago_id
        - lago_add_on_id
        - code
        - invoice_display_name
        - add_on_code
        - created_at
        - charge_model
        - pay_in_advance
        - prorated
        - properties
        - units
      properties:
        lago_id:
          type: string
          format: uuid
          description: Unique identifier of the fixed charge, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_add_on_id:
          type: string
          format: uuid
          description: Unique identifier of the add-on associated with this fixed charge.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        invoice_display_name:
          type: string
          description: >-
            Specifies the name that will be displayed on an invoice. If no value
            is set for this field, the name of the actual charge will be used as
            the default display name.
          example: Setup fee
        add_on_code:
          type: string
          description: Unique code used to identify the add-on.
          example: setup_fee
        created_at:
          type: string
          format: date-time
          description: >-
            The date and time when the fixed charge was created. It is expressed
            in UTC format according to the ISO 8601 datetime standard.
          example: '2023-06-27T19:43:42Z'
        code:
          type: string
          description: Unique code for the fixed charge.
          example: setup_fee
        charge_model:
          type: string
          enum:
            - standard
            - graduated
            - volume
          description: >-
            The charge model for the fixed charge. Only `standard`, `graduated`,
            and `volume` models are supported for fixed charges.
          example: standard
        pay_in_advance:
          type: boolean
          description: >-
            This field determines the billing timing for this fixed charge. When
            set to `true`, the charge is due and invoiced immediately.
            Conversely, when set to false, the charge is due and invoiced at the
            end of each billing period.
          example: false
        prorated:
          type: boolean
          description: >
            Specifies whether a fixed charge is prorated based on the remaining
            number of days in the billing period or billed fully.


            - If set to `true`, the charge is prorated based on the remaining
            days in the current billing period.

            - If set to `false`, the charge is billed in full.

            - If not defined in the request, default value is `false`.
          example: false
        properties:
          $ref: '#/components/schemas/FixedChargeProperties'
          description: List of all thresholds utilized for calculating the fixed charge.
        units:
          type: number
          description: The number of units for the fixed charge.
          example: 1
        lago_parent_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Unique identifier of the parent fixed charge (for plan versions).
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        taxes:
          type: array
          description: List of taxes applied to the fixed charge.
          items:
            $ref: '#/components/schemas/TaxObject'
    TaxObject:
      type: object
      required:
        - lago_id
        - name
        - code
        - rate
        - applied_to_organization
        - created_at
      properties:
        lago_id:
          type: string
          format: uuid
          description: Unique identifier of the tax, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        name:
          type: string
          description: Name of the tax.
          example: TVA
        code:
          type: string
          description: >-
            Unique code used to identify the tax associated with the API
            request.
          example: french_standard_vat
        description:
          type:
            - string
            - 'null'
          description: Internal description of the tax
          example: French standard VAT
        rate:
          type: number
          description: The percentage rate of the tax
          example: 20
        applied_to_organization:
          type: boolean
          deprecated: true
          description: >-
            This field is deprecated and will be removed in a future version.
            When set to true, it applies the tax to the organization's default
            billing entity. To apply or remove a tax from any billing entity
            (including the default one), please use the `PUT
            /billing_entities/:code` endpoint instead.
          example: true
        created_at:
          type: string
          format: date-time
          description: Creation date of the tax.
          example: '2023-07-06T14:35:58Z'
    UsageThresholdObject:
      type: object
      required:
        - lago_id
        - threshold_display_name
        - amount_cents
        - recurring
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          format: uuid
          description: Unique identifier of the usage threshold created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        threshold_display_name:
          type:
            - string
            - 'null'
          description: The display name of the usage threshold.
          example: Threshold 1
        amount_cents:
          type: integer
          description: The amount to reach to trigger a `progressive_billing` invoice.
          example: 10000
        recurring:
          type: boolean
          description: >-
            This field when set to `true` indicates that a `progressive_billing`
            invoice will be created every time the lifetime usage increases by
            the specified amount.
          example: true
        created_at:
          type: string
          format: date-time
          description: >-
            The date and time when the usage threshold was created. It is
            expressed in UTC format according to the ISO 8601 datetime standard.
          example: '2023-06-27T19:43:42Z'
        updated_at:
          type: string
          format: date-time
          description: >-
            The date and time when the usage threshold was last updated. It is
            expressed in UTC format according to the ISO 8601 datetime standard.
          example: '2023-06-27T19:43:42Z'
    PlanEntitlement:
      type: object
      required:
        - entitlement
      properties:
        entitlement:
          $ref: '#/components/schemas/PlanEntitlementObject'
    MetadataObject:
      type:
        - object
        - 'null'
      description: >-
        Custom metadata stored as key-value pairs.

        Keys are strings (max 100 characters), values can be strings (max 255
        characters) or null.
      additionalProperties:
        type:
          - string
          - 'null'
      example:
        external_id: ext-123
        synced_at: '2024-01-15'
        source: null
    InvoiceCustomSectionObject:
      type: object
      required:
        - lago_id
        - name
        - code
      properties:
        lago_id:
          type: string
          format: uuid
          description: >-
            Unique identifier for the invoice custom section in the Lago
            application, generated by Lago to ensure record uniqueness within
            the system.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        name:
          type: string
          description: Name of the invoice custom section.
          example: EU Bank Details
        code:
          type: string
          description: >-
            Unique code identifying the invoice custom section for the API
            request.
          example: eu_bank_details
        description:
          type: string
          description: Internal description of the invoice custom section.
          example: This section contains the bank details for EU customers.
        details:
          type: string
          description: The value shown on the invoice PDF.
          example: 'Bank Name: Lago Bank, IBAN: FR7630004000031234567890143'
        display_name:
          type: string
          description: The name of the invoice custom section displayed on the invoice.
          example: 'Bank Details:'
        applied_to_organization:
          type: boolean
          deprecated: true
          description: >-
            This field is deprecated and will be removed in a future version.
            When set to true, it applies the invoice custom section to the
            organization's default billing entity. To apply or remove an invoice
            custom section from any billing entity (including the default one),
            please use the `PUT /billing_entities/:code` endpoint instead.
          example: true
        organization_id:
          type: string
          format: uuid
          description: >-
            Unique identifier for the organization associated with the invoice
            custom section.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        created_at:
          type: string
          format: date-time
          description: Creation date of the tax.
          example: '2023-07-06T14:35:58Z'
    ChargeFilterObject:
      type: object
      description: >-
        Values used to apply differentiated pricing based on additional event
        properties.
      required:
        - invoice_display_name
        - properties
        - values
      properties:
        invoice_display_name:
          type:
            - string
            - 'null'
          description: >-
            Specifies the name that will be displayed on an invoice. If no value
            is set for this field, the values of the filter will be used as the
            default display name.
          example: AWS
        properties:
          $ref: '#/components/schemas/ChargeProperties'
          description: List of all thresholds utilized for calculating the charge.
        values:
          type: object
          description: >-
            List of possible filter values. The key and values must match one of
            the billable metric filters.
          additionalProperties:
            type: array
            items:
              type: string
          example:
            region:
              - us-east-1
    PlanEntitlementObject:
      type: object
      required:
        - code
        - name
        - description
        - privileges
      properties:
        code:
          type: string
          example: seats
          description: Unique code used to identify the feature. Max 255 characters.
        name:
          type:
            - string
            - 'null'
          example: Number of seats
          description: Name of the feature. Max 255 characters.
        description:
          type:
            - string
            - 'null'
          example: Number of users of the account
          description: Description of the feature. Max 600 characters.
        privileges:
          type: array
          items:
            $ref: '#/components/schemas/PlanEntitlementPrivilegeObject'
          example:
            - 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
          description: >-
            Privileges associated with this feature. Each privilege must have a
            value assigned.
    PlanEntitlementPrivilegeObject:
      allOf:
        - $ref: '#/components/schemas/FeaturePrivilegeObject'
        - type: object
          required:
            - value
          properties:
            value:
              oneOf:
                - type: integer
                  description: Value for integer type privileges
                - type: boolean
                  description: Value for boolean type privileges
                - type: string
                  description: Value for string or select type privileges
              example: 10
              description: >-
                Value assigned to this privilege in the entitlement. Type
                depends on the privilege's value_type.
    FeaturePrivilegeObject:
      type: object
      required:
        - code
        - name
        - value_type
        - config
      properties:
        code:
          type: string
          example: max
          description: Unique code for the privilege.
        name:
          type:
            - string
            - 'null'
          example: Maximum
          description: Display name for the privilege.
        value_type:
          type: string
          enum:
            - integer
            - boolean
            - string
            - select
          example: integer
          description: 'Data type of the privilege value. Default: string'
        config:
          type: object
          properties:
            select_options:
              type: array
              items:
                type: string
              example:
                - google
                - okta
              description: Array of string, required only when value_type is `select`.
  responses:
    BadRequest:
      description: Bad Request error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorBadRequest'
    Unauthorized:
      description: Unauthorized error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorUnauthorized'
    NotFound:
      description: Not Found error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorNotFound'
    UnprocessableEntity:
      description: Unprocessable entity error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorUnprocessableEntity'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````