### Installing Lago Go Client Source: https://docs.getlago.com/api-reference/intro This command installs the official Lago Go client library using `go get`. This is the first step to integrate Lago's API functionalities into a Go application. ```bash go get github.com/getlago/lago-go-client@v1 ``` -------------------------------- ### Installing Lago Ruby Gem Directly Source: https://docs.getlago.com/api-reference/intro This command installs the `lago-ruby-client` gem directly using the `gem install` utility. This method is suitable if Bundler is not being used to manage project dependencies in your Ruby application. ```bash $ gem install lago-ruby-client ``` -------------------------------- ### Installing Lago on a Fresh System - Shell Source: https://github.com/getlago/lago This snippet provides the complete set of shell commands required to perform a fresh installation of Lago. It covers cloning the repository, navigating into the project directory, setting up the LAGO_RSA_PRIVATE_KEY environment variable by generating a new RSA key, sourcing the environment file, and finally starting all services using Docker Compose. ```shell # Get the code\ngit clone --depth 1 https://github.com/getlago/lago.git\n\n# Go to Lago folder\ncd lago\n\n# Set up environment configuration\necho \"LAGO_RSA_PRIVATE_KEY=\\\"\`openssl genrsa 2048 | base64\`\\\"\" >> .env\nsource .env\n\n# Start all the components\ndocker compose up ``` -------------------------------- ### Installing Lago Python Client Source: https://docs.getlago.com/api-reference/intro This command installs the official Lago Python client library using `pip`, the Python package installer. This is the essential first step to integrate Lago's API functionalities into any Python application. ```bash pip install lago-python-client ``` -------------------------------- ### Installing Lago Javascript Client Source: https://docs.getlago.com/api-reference/intro This command installs the official Lago Javascript client library using `npm`, the Node.js package manager. This is the first step to integrate Lago's API functionalities into a Javascript application. ```bash npm install lago-javascript-client ``` -------------------------------- ### Deploying Lago Locally: Fresh Install (Shell) Source: https://github.com/getlago/lago This snippet provides the complete set of shell commands required for a fresh local deployment of the Lago application. It clones the repository, navigates into the directory, generates and sets up the RSA private key in the environment, and starts all necessary components using Docker Compose. ```Shell git clone --depth 1 https://github.com/getlago/lago.git cd lago echo "LAGO_RSA_PRIVATE_KEY=\"\`openssl genrsa 2048 | base64\`\"" >> .env source .env docker compose up ``` -------------------------------- ### Documentation and Guides Navigation in JSX Source: https://docs.getlago.com/welcome This JSX component structures a dedicated section for navigating Lago's documentation and guides, starting with a central heading 'Get started with our billing docs and guides'. It utilizes a `CardGroup` to display three distinct `Card` components, each linking to a key resource: a general guide, API references, and the community Slack channel. Each card features an SVG icon, a descriptive title, and a brief summary, facilitating easy access to relevant information. ```JSX

Get started with our billing docs and guides

Guide

Learn everything about Lago billing engine. Build your first plans in minutes.

API References

Automate your billing actions with our API references and SDKs.

Community

Ask questions, share your feedback and get help from the community.

``` -------------------------------- ### Running Lago with Advanced Docker Commands (Shell) Source: https://docs.getlago.com/guide/self-hosted/docker This sequence of shell commands provides a more granular setup for Lago. It involves cloning the repository, navigating into the directory, generating and setting an RSA private key in the `.env` file, starting the API service, creating and migrating the database, and finally starting all other necessary Docker Compose components. This method offers more control over the setup process. ```shell # Get the code git clone https://github.com/getlago/lago.git # Go to Lago folder cd lago # Set up environment configuration echo "LAGO_RSA_PRIVATE_KEY=\"`openssl genrsa 2048 | base64 | tr -d '\n'`\"" >> .env source .env # Start the api docker compose up -d api # Create the database docker compose exec api rails db:create docker compose exec api rails db:migrate # Start all other components docker compose up ``` -------------------------------- ### Initializing Lago Go Client Source: https://docs.getlago.com/api-reference/intro This snippet demonstrates how to import and initialize the Lago Go client. It shows how to create a client instance and set the API key, including an option to specify a custom base URL for self-hosted instances or different server regions (e.g., EU) instead of the default US region. ```go import "github.com/getlago/lago-go-client" func main() { // By default, this will connect to Lago's hosted servers in the US region. lagoClient := lago.New().SetApiKey("__YOU_API_KEY__") // If you are self-hosting Lago or using a different region (e.g., EU), // you need to specify the base URL to connect to the correct Lago instance. // Replace '__YOUR_LAGO_URL__' with the appropriate URL for your Lago instance. // Example: 'https://api.eu.getlago.com/api/v1' for the EU region. // lagoClient := lago.New().SetApiKey("__YOUR_API_KEY__").SetBaseURL("__YOUR_LAGO_URL__") } ``` -------------------------------- ### Initializing Lago Python Client Source: https://docs.getlago.com/api-reference/intro This snippet demonstrates how to initialize the Lago Python client. It shows how to create a client instance using an API key, with an optional parameter to specify a custom API URL for self-hosted instances or different server regions (e.g., EU) instead of the default US region. ```python from lago_python_client import Client # By default, this connects to Lago's hosted servers in the US region. client = Client(api_key='__YOUR_API_KEY__') # If you are self-hosting Lago or using a different server region, # specify the API URL to connect to the correct instance. # Replace '__YOUR_LAGO_URL__' with the appropriate URL for your Lago server. # Example: 'https://api.eu.getlago.com/api/v1' for the EU region. # client = Client(api_key='__YOUR_API_KEY__', api_url='__YOUR_LAGO_URL__') ``` -------------------------------- ### Initializing Lago Ruby Client Source: https://docs.getlago.com/api-reference/intro This snippet demonstrates how to require and initialize the Lago Ruby client. It shows how to create a client instance with an API key, including an option to specify a custom API URL for self-hosted instances or different server regions (e.g., EU) instead of the default US region. ```ruby require 'lago-ruby-client' # By default, this will connect to the US region of Lago's hosted servers. client = Lago::Api::Client.new(api_key: '__YOUR_API_KEY__') # If you are self-hosting Lago or using Lago in a different region (e.g., Europe), # you need to specify the API URL to connect to the correct server. # For example, you can provide the base URL for your specific Lago instance. # This example shows how to specify a different Lago server when needed. # # Replace '__YOUR_LAGO_URL__' with the appropriate URL of your Lago instance. # Example: 'https://api.eu.getlago.com/api/v1' for the EU region. # # client = Lago::Api::Client.new( # api_key: '__YOUR_API_KEY__', # api_url: '__YOUR_LAGO_URL__' # ) ``` -------------------------------- ### Initializing Lago Javascript Client Source: https://docs.getlago.com/api-reference/intro This snippet demonstrates how to import and initialize the Lago Javascript client. It shows how to create a client instance with an API key, including an option to specify a custom base URL for self-hosted instances or different server regions (e.g., EU) instead of the default US region. ```javascript import { Client } from 'lago-javascript-client' // By default, this will connect to Lago's hosted servers in the US region. const client = Client('__YOUR_API_KEY__') // If you are self-hosting Lago or using a different region (e.g., EU), // you need to specify the base URL to connect to the correct Lago instance. // Replace '__YOUR_LAGO_URL__' with the appropriate URL for your Lago instance. // Example: 'https://api.eu.getlago.com/api/v1' for the EU region. // const client = Client('__YOUR_API_KEY__', { baseUrl: '__YOUR_LAGO_URL__' }) ``` -------------------------------- ### Retrieving Plans via OpenAPI GET /plans (YAML) Source: https://docs.getlago.com/api-reference/plans/get-all-plans This YAML snippet defines the OpenAPI specification for the `GET /plans` endpoint. It details the request parameters (pagination), security scheme (bearerAuth), and a comprehensive example of the successful `200` response, including various plan attributes, minimum commitment, and charge models (package, graduated, standard). ```yaml paths: path: /plans method: get servers: - url: https://api.getlago.com/api/v1 description: US Lago cluster - url: https://api.eu.getlago.com/api/v1 description: EU Lago cluster request: security: - title: bearerAuth parameters: query: {} header: Authorization: type: http scheme: bearer cookie: {} parameters: path: {} query: page: schema: - type: integer required: false description: Page number. example: 1 explode: true per_page: schema: - type: integer required: false description: Number of records per page. example: 20 explode: true header: {} cookie: {} body: {} response: '200': application/json: schemaArray: - type: object properties: plans: allOf: - type: array items: $ref: '#/components/schemas/PlanObject' meta: allOf: - $ref: '#/components/schemas/PaginationMeta' refIdentifier: '#/components/schemas/PlansPaginated' requiredProperties: - plans - meta examples: example: value: plans: - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 name: Startup invoice_display_name: Startup plan created_at: '2023-06-27T19:43:42Z' code: startup interval: monthly description: '' amount_cents: 10000 amount_currency: USD trial_period: 5 pay_in_advance: true bill_charges_monthly: null minimum_commitment: lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 plan_code: premium amount_cents: 100000 invoice_display_name: Minimum Commitment (C1) interval: monthly created_at: '2022-04-29T08:59:51Z' updated_at: '2022-04-29T08:59:51Z' taxes: - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 name: TVA code: french_standard_vat description: French standard VAT rate: 20 applied_to_organization: true created_at: '2023-07-06T14:35:58Z' charges: - 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 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 ``` -------------------------------- ### Updating Lago - Shell Source: https://github.com/getlago/lago This command is used to update an existing Lago installation. It restarts all Docker Compose services, pulling any updated images and applying necessary changes. ```shell docker compose up ``` -------------------------------- ### Example Lago Startup Plan Definition (YAML) Source: https://docs.getlago.com/api-reference/plans/update This comprehensive example illustrates a 'Startup' billing plan definition in Lago, including general plan details, minimum commitment, and various charge models. It showcases 'package', 'graduated', 'standard', and 'volume' charges, demonstrating how different pricing structures can be combined within a single plan. This configuration defines how customers are billed for services. ```YAML plan: name: Startup invoice_display_name: Startup plan code: startup interval: monthly description: Plan for early stage startups. amount_cents: 10000 amount_currency: USD trial_period: 5 pay_in_advance: true bill_charges_monthly: null tax_codes: - french_standard_vat minimum_commitment: amount_cents: 100000 invoice_display_name: Minimum Commitment (C1) tax_codes: - french_standard_vat charges: - billable_metric_id: 1a901a90-1a90-1a90-1a90-1a901a91 charge_model: package invoiceable: true invoice_display_name: Setup pay_in_advance: false prorated: false min_amount_cents: 3000 properties: amount: '30' free_units: 100 package_size: 1000 tax_codes: - french_standard_vat - billable_metric_id: 1a901a90-1a90-1a90-1a90-1a901a92 charge_model: graduated invoiceable: true invoice_display_name: Setup pay_in_advance: false prorated: false min_amount_cents: 0 properties: graduated_ranges: - to_value: 10 from_value: 0 flat_amount: '10' per_unit_amount: '0.5' - to_value: null from_value: 11 flat_amount: '0' per_unit_amount: '0.4' - billable_metric_id: 1a901a90-1a90-1a90-1a90-1a901a93 charge_model: standard invoiceable: true invoice_display_name: Setup pay_in_advance: true regroup_paid_fees: null prorated: false min_amount_cents: 0 properties: {} - billable_metric_id: 1a901a90-1a90-1a90-1a90-1a901a94 charge_model: volume invoiceable: true ``` -------------------------------- ### Unauthorized 401 Error Response Schema and Example (YAML) Source: https://docs.getlago.com/api-reference/subscriptions/assign-plan This YAML snippet defines the schema and provides an example for a 401 Unauthorized error response. This error indicates that the client must authenticate itself to get the requested response. ```YAML application/json: schemaArray: - type: object properties: status: allOf: - type: integer format: int32 example: 401 error: allOf: - type: string example: Unauthorized refIdentifier: '#/components/schemas/ApiErrorUnauthorized' requiredProperties: - status - error ``` -------------------------------- ### Retrieve Subscriptions via OpenAPI GET Endpoint (YAML) Source: https://docs.getlago.com/api-reference/subscriptions/get-all This OpenAPI specification defines the GET /subscriptions endpoint. It details the request parameters for filtering (page, per_page, external_customer_id, plan_code, status), security requirements (bearerAuth), and the structure of successful (200) and unauthorized (401) responses, including examples. ```YAML paths: path: /subscriptions method: get servers: - url: https://api.getlago.com/api/v1 description: US Lago cluster - url: https://api.eu.getlago.com/api/v1 description: EU Lago cluster request: security: - title: bearerAuth parameters: query: {} header: Authorization: type: http scheme: bearer cookie: {} parameters: path: {} query: page: schema: - type: integer required: false description: Page number. example: 1 explode: true per_page: schema: - type: integer required: false description: Number of records per page. example: 20 explode: true external_customer_id: schema: - type: string required: false description: >- The customer external unique identifier (provided by your own application) example: 5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba explode: true plan_code: schema: - type: string required: false 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. example: premium explode: true status[]: schema: - type: array items: allOf: - type: string enum: - pending - canceled - terminated - active required: false description: >- If the field is not defined, Lago will return only `active` subscriptions. However, if you wish to fetch subscriptions by different status you can define them in a status[] query param. Available filter values: `pending`, `canceled`, `terminated`, `active`. example: - active - pending explode: true header: {} cookie: {} body: {} response: '200': application/json: schemaArray: - type: object properties: subscriptions: allOf: - type: array items: $ref: '#/components/schemas/SubscriptionObject' meta: allOf: - $ref: '#/components/schemas/PaginationMeta' refIdentifier: '#/components/schemas/SubscriptionsPaginated' requiredProperties: - subscriptions - meta examples: example: value: subscriptions: - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 external_id: 5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba lago_customer_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 external_customer_id: 5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba billing_time: anniversary name: Repository A plan_code: premium status: active created_at: '2022-08-08T00:00:00Z' canceled_at: '2022-09-14T16:35:31Z' started_at: '2022-08-08T00:00:00Z' ending_at: '2022-10-08T00:00:00Z' subscription_at: '2022-08-08T00:00:00Z' terminated_at: '2022-09-14T16:35:31Z' previous_plan_code: null next_plan_code: null downgrade_plan_date: '2022-04-30' trial_ended_at: '2022-08-08T00:00:00Z' current_billing_period_started_at: '2022-08-08T00:00:00Z' current_billing_period_ending_at: '2022-09-08T00:00:00Z' meta: current_page: 2 next_page: 3 prev_page: 1 total_pages: 4 total_count: 70 description: List of subscriptions '401': application/json: schemaArray: - type: object properties: status: allOf: - type: integer format: int32 example: 401 error: allOf: - type: string example: Unauthorized refIdentifier: '#/components/schemas/ApiErrorUnauthorized' requiredProperties: - status - error examples: example: value: status: 401 ``` -------------------------------- ### Creating a Wallet (Input Example) - YAML Source: https://docs.getlago.com/api-reference/wallets/create This YAML snippet demonstrates the structure for creating a new wallet, including basic details, credit amounts, customer association, expiration, and optional recurring transaction rules and metadata. It shows how to define initial paid and granted credits, link to an external customer, and set up automated top-up rules. ```YAML wallet: name: Prepaid rate_amount: '1.5' currency: USD paid_credits: '20.0' granted_credits: '10.0' external_customer_id: hooli_1234 expiration_at: '2022-07-07T23:59:59Z' invoice_requires_successful_payment: false transaction_metadata: - key: example_key value: example_value - key: another_key value: another_value recurring_transaction_rules: - paid_credits: '20.0' granted_credits: '10.0' method: target trigger: interval interval: monthly started_at: '2022-08-08T00:00:00Z' expiration_at: '2023-09-30T23:59:59Z' threshold_credits: '20.0' target_ongoing_balance: '200.0' invoice_requires_successful_payment: false transaction_metadata: - key: example_key value: example_value - key: another_key value: another_value ``` -------------------------------- ### Defining GET /payments Endpoint in OpenAPI Source: https://docs.getlago.com/api-reference/payments/get-all This OpenAPI YAML snippet defines the GET /payments endpoint for retrieving payment information. It specifies available servers, bearer token security, query parameters for pagination (page, per_page), filtering by external_customer_id and lago_invoice_id, and the structure of successful (200 OK) and unauthorized (401) responses, including example data. ```YAML paths: path: /payments method: get servers: - url: https://api.getlago.com/api/v1 description: US Lago cluster - url: https://api.eu.getlago.com/api/v1 description: EU Lago cluster request: security: - title: bearerAuth parameters: query: {} header: Authorization: type: http scheme: bearer cookie: {} parameters: path: {} query: page: schema: - type: integer required: false description: Page number. example: 1 explode: true per_page: schema: - type: integer required: false description: Number of records per page. example: 20 explode: true external_customer_id: schema: - type: string required: false description: Unique identifier assigned to the customer in your application. example: 5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba explode: true lago_invoice_id: schema: - type: string required: false description: >- Unique identifier assigned to the invoice within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the invoice's record within the Lago system. format: uuid example: 1a901a90-1a90-1a90-1a90-1a901a901a90 header: {} cookie: {} body: {} response: '200': application/json: schemaArray: - type: object properties: payments: allOf: - type: array items: $ref: '#/components/schemas/PaymentManualObject' meta: allOf: - $ref: '#/components/schemas/PaginationMeta' refIdentifier: '#/components/schemas/PaymentsPaginated' requiredProperties: - payments - meta examples: example: value: payments: - lago_id: 4cf085a7-c196-4f07-a543-97c50ec6e8b2 invoice_ids: - 486b147a-02a1-4ccf-8603-f3541fc25e7a amount_cents: 100 amount_currency: USD payment_status: succeeded type: manual reference: ref1 external_payment_id: null created_at: '2025-02-20T00:00:00Z' meta: current_page: 2 next_page: 3 prev_page: 1 total_pages: 4 total_count: 70 description: Payments '401': application/json: schemaArray: - type: object properties: status: allOf: - type: integer format: int32 example: 401 error: allOf: - type: string example: Unauthorized refIdentifier: '#/components/schemas/ApiErrorUnauthorized' requiredProperties: - status - error examples: example: value: status: 401 error: Unauthorized description: Unauthorized error deprecated: false type: path components: schemas: PaginationMeta: type: object required: - current_page - total_pages - total_count properties: current_page: type: integer description: Current page. example: 2 next_page: type: - integer - 'null' description: Next page. example: 3 prev_page: type: - integer - 'null' description: Previous page. example: 1 total_pages: type: integer description: Total number of pages. example: 4 total_count: type: integer description: Total number of records. example: 70 PaymentManualObject: type: object required: - payment properties: lago_id: type: string format: uuid description: The unique identifier of the payment, created by Lago. example: 4cf085a7-c196-4f07-a543-97c50ec6e8b2 invoice_ids: type: array description: List of invoice IDs associated with the payment. items: type: string format: uuid example: 486b147a-02a1-4ccf-8603-f3541fc25e7a amount_cents: type: integer ``` -------------------------------- ### Retrieve Wallets via OpenAPI GET /wallets Endpoint Source: https://docs.getlago.com/api-reference/wallets/get-all This OpenAPI specification defines the GET /wallets endpoint, allowing retrieval of wallet information. It includes details on query parameters like 'page', 'per_page', and 'external_customer_id', security requirements using bearer authentication, and expected success (200) and unauthorized (401) responses with their respective schemas and examples. ```yaml paths: path: /wallets method: get servers: - url: https://api.getlago.com/api/v1 description: US Lago cluster - url: https://api.eu.getlago.com/api/v1 description: EU Lago cluster request: security: - title: bearerAuth parameters: query: {} header: Authorization: type: http scheme: bearer cookie: {} parameters: path: {} query: page: schema: - type: integer required: false description: Page number. example: 1 explode: true per_page: schema: - type: integer required: false description: Number of records per page. example: 20 explode: true external_customer_id: schema: - type: string required: true description: >- The customer external unique identifier (provided by your own application). example: 5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba explode: true header: {} cookie: {} body: {} response: '200': application/json: schemaArray: - type: object properties: wallets: allOf: - type: array items: $ref: '#/components/schemas/WalletObject' meta: allOf: - $ref: '#/components/schemas/PaginationMeta' refIdentifier: '#/components/schemas/WalletsPaginated' requiredProperties: - wallets - meta examples: example: value: wallets: - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 lago_customer_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 external_customer_id: hooli_1234 status: active currency: USD name: Prepaid rate_amount: '1.5' credits_balance: '28.0' balance_cents: 1000 consumed_credits: '2.0' created_at: '2022-04-29T08:59:51Z' expiration_at: null last_balance_sync_at: '2022-04-29T08:59:51Z' last_consumed_credit_at: '2022-04-29T08:59:51Z' terminated_at: '2022-09-14T16:35:31Z' invoice_requires_successful_payment: false recurring_transaction_rules: - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 trigger: interval method: target interval: monthly status: active threshold_credits: '20.0' paid_credits: '20.0' granted_credits: '10.0' started_at: '2022-08-08T00:00:00Z' target_ongoing_balance: '200.0' created_at: '2022-04-29T08:59:51Z' expiration_at: '2023-09-30T23:59:59Z' invoice_requires_successful_payment: false transaction_metadata: - key: example_key value: example_value - key: another_key value: another_value ongoing_balance_cents: 800 ongoing_usage_balance_cents: 200 credits_ongoing_balance: '8.0' credits_ongoing_usage_balance: '2.0' meta: current_page: 2 next_page: 3 prev_page: 1 total_pages: 4 total_count: 70 description: Wallets '401': application/json: schemaArray: - type: object properties: status: allOf: - type: integer format: int32 example: 401 error: allOf: - type: string example: Unauthorized refIdentifier: '#/components/schemas/ApiErrorUnauthorized' requiredProperties: - status - error examples: example: value: status: 401 error: Unauthorized description: Unauthorized error deprecated: false type: path components: schemas: Currency: type: string example: USD enum: - AED - AFN - ALL - AMD - ANG - AOA - ARS - AUD - AWG - AZN - BAM - BBD - BDT - BGN - BIF - BMD - BND ``` -------------------------------- ### Creating a Plan with Package Charges using Lago API (Bash) Source: https://docs.getlago.com/templates/payg/algolia This snippet demonstrates how to create a new 'pay-as-you-go' plan named "Algolia Starter" in Lago using the API. It configures a monthly interval with no subscription fee and includes a charge for "search_requests" using the "package" charge model. The charge defines a package price of $1.50 per 1,000 units, with the first 10,000 units being free. ```bash LAGO_URL="https://api.getlago.com" API_KEY="__YOUR_API_KEY__" curl --location --request POST "$LAGO_URL/api/v1/plans" \ --header "Authorization: Bearer $API_KEY" \ --header 'Content-Type: application/json' \ --data-raw '{ "plan": { "name": "Algolia Starter", "code": "algolia_starter", "interval": "monthly", "amount_cents": 0, "amount_currency": "USD", "trial_period": 0.0, "pay_in_advance": false, "charges": [ { "billable_metric_id": "15879740-102e-43bd-a6bc-15d865bb1b85", "billable_metric_code": "search_requests", "charge_model": "package", "invoiceable": true, "pay_in_advance": false, "prorated": false, "min_amount_cents": 0, "properties": { "amount": "1.50", "free_units": 10000, "package_size": 1000 }, "filters": [], "taxes": [] } ] } }' ``` -------------------------------- ### Adding Lago Ruby Gem with Bundler Source: https://docs.getlago.com/api-reference/intro This command adds the `lago-ruby-client` gem to your Gemfile using Bundler, a dependency manager for Ruby. This is the recommended way to manage Ruby dependencies for integrating with the Lago API. ```bash bundle add lago-ruby-client ``` -------------------------------- ### Retrieving Events via OpenAPI GET Request (YAML) Source: https://docs.getlago.com/api-reference/events/list-events This OpenAPI YAML snippet defines the GET /events endpoint, specifying its available servers, security requirements (bearerAuth), and various query parameters for filtering and pagination. It also details the structure of successful (200 OK) and unauthorized (401) responses, including example payloads and references to shared schemas like PaginationMeta and EventObject. ```YAML paths: path: /events method: get servers: - url: https://api.getlago.com/api/v1 description: US Lago cluster - url: https://api.eu.getlago.com/api/v1 description: EU Lago cluster request: security: - title: bearerAuth parameters: query: {} header: Authorization: type: http scheme: bearer cookie: {} parameters: path: {} query: page: schema: - type: integer required: false description: Page number. example: 1 explode: true per_page: schema: - type: integer required: false description: Number of records per page. example: 20 explode: true external_subscription_id: schema: - type: string required: false description: External subscription ID example: 5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba explode: true code: schema: - type: string required: false description: Filter events by its code. example: event-123 explode: true timestamp_from: schema: - type: string required: false description: Filter events by timestamp starting from a specific date. format: date-time example: '2022-08-08T00:00:00Z' explode: true timestamp_to: schema: - type: string required: false description: Filter events by timestamp up to a specific date. format: date-time example: '2022-08-08T00:00:00Z' explode: true header: {} cookie: {} body: {} response: '200': application/json: schemaArray: - type: object properties: events: allOf: - type: array items: $ref: '#/components/schemas/EventObject' meta: allOf: - $ref: '#/components/schemas/PaginationMeta' refIdentifier: '#/components/schemas/EventsPaginated' requiredProperties: - events - meta examples: example: value: events: - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 transaction_id: transaction_1234567890 lago_customer_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 code: storage timestamp: '2022-04-29T08:59:51.123Z' precise_total_amount_cents: '1234.56' properties: gb: 10 lago_subscription_id: 1a901a90-1a90-1a90-1a90-1a901a901a90 external_subscription_id: sub_1234567890 created_at: '2022-04-29T08:59:51Z' meta: current_page: 2 next_page: 3 prev_page: 1 total_pages: 4 total_count: 70 description: Events '401': application/json: schemaArray: - type: object properties: status: allOf: - type: integer format: int32 example: 401 error: allOf: - type: string example: Unauthorized refIdentifier: '#/components/schemas/ApiErrorUnauthorized' requiredProperties: - status - error examples: example: value: status: 401 error: Unauthorized description: Unauthorized error deprecated: false type: path components: schemas: PaginationMeta: type: object required: - current_page - total_pages - total_count properties: current_page: type: integer description: Current page. example: 2 next_page: type: - integer - 'null' description: Next page. example: 3 prev_page: type: - integer - 'null' description: Previous page. example: 1 total_pages: type: integer description: Total number of pages. example: 4 total_count: type: integer description: Total number of records. example: 70 EventObject: type: object required: - lago_id - transaction_id - lago_customer_id - code - timestamp - lago_subscription_id ```