Lago Events API

Everything about Event collection

OpenAPI Specification

lago-events-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Lago API documentation Add_ons Events API
  description: Lago API allows your application to push customer information and metrics (events) from your application to the billing application.
  version: 1.15.0
  license:
    name: AGPLv3
    identifier: AGPLv3
  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 Lagos cluster
security:
- bearerAuth: []
tags:
- name: Events
  description: Everything about Event collection
  externalDocs:
    description: Find out more
    url: https://doc.getlago.com/docs/api/events/event-object
paths:
  /events:
    post:
      tags:
      - Events
      summary: Lago Send usage events
      description: This endpoint is used for transmitting usage measurement events to either a designated customer or a specific subscription.
      operationId: createEvent
      requestBody:
        description: Event payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventInput'
        required: true
      responses:
        '200':
          description: Event
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    get:
      tags:
      - Events
      summary: Lago List all events
      description: This endpoint is used for retrieving all events.
      operationId: findAllEvents
      parameters:
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/per_page'
      - $ref: '#/components/parameters/external_subscription_id'
      - name: code
        in: query
        description: Filter events by its code.
        required: false
        explode: true
        schema:
          type: string
          example: event-123
      - name: timestamp_from
        in: query
        description: Filter events by timestamp starting from a specific date.
        required: false
        explode: true
        schema:
          type: string
          format: date-time
          example: '2022-08-08T00:00:00Z'
      - name: timestamp_to
        in: query
        description: Filter events by timestamp up to a specific date.
        required: false
        explode: true
        schema:
          type: string
          format: date-time
          example: '2022-08-08T00:00:00Z'
      responses:
        '200':
          description: Events
          content:
            application/json:
              schema:
                type: object
                required:
                - events
                - meta
                properties:
                  events:
                    type: array
                    items:
                      $ref: '#/components/schemas/EventObject'
                  meta:
                    $ref: '#/components/schemas/PaginationMeta'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /events/batch:
    post:
      tags:
      - Events
      summary: Lago Batch multiple events
      description: This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
      operationId: createBatchEvents
      requestBody:
        description: Batch events payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventBatchInput'
        required: true
      responses:
        '200':
          description: Event received
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
  /events/estimate_fees:
    post:
      tags:
      - Events
      summary: Lago Estimate fees for a pay in advance charge
      description: Estimate the fees that would be created after reception of an event for a billable metric attached to one or multiple pay in advance charges
      operationId: eventEstimateFees
      requestBody:
        description: Event estimate payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventEstimateFeesInput'
        required: true
      responses:
        '200':
          description: Fees estimate
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Fees'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
  /events/{transaction_id}:
    parameters:
    - name: transaction_id
      in: path
      description: This field represents the unique identifier sent for this specific event (must be URL encoded).
      required: true
      schema:
        type: string
        example: transaction_1234567890
    get:
      tags:
      - Events
      summary: Lago Retrieve a specific event
      description: This endpoint is used for retrieving a specific usage measurement event that has been sent to a customer or a subscription.
      operationId: findEvent
      responses:
        '200':
          description: Event
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
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
          description: Next page.
          example: 3
          nullable: true
        prev_page:
          type: integer
          description: Previous page.
          example: 1
          nullable: true
        total_pages:
          type: integer
          description: Total number of pages.
          example: 4
        total_count:
          type: integer
          description: Total number of records.
          example: 70
    Fees:
      type: object
      required:
      - fees
      properties:
        fees:
          type: array
          items:
            $ref: '#/components/schemas/FeeObject'
    Event:
      type: object
      required:
      - event
      properties:
        event:
          $ref: '#/components/schemas/EventObject'
    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
    EventInput:
      type: object
      required:
      - event
      properties:
        event:
          type: object
          required:
          - transaction_id
          - external_subscription_id
          - code
          properties:
            transaction_id:
              type: string
              example: transaction_1234567890
              description: This field represents a unique identifier for the event. It is crucial for ensuring idempotency, meaning that each event can be uniquely identified and processed without causing any unintended side effects.
            external_subscription_id:
              type: string
              example: sub_1234567890
              description: The unique identifier of the subscription in your application. This field is mandatory in order to link events to the correct customer subscription.
            code:
              type: string
              example: storage
              description: The code that identifies a targeted billable metric. It is essential that this code matches the `code` property of one of your active billable metrics. If the provided code does not correspond to any active billable metric, it will be ignored during the process.
            timestamp:
              anyOf:
              - type: integer
              - type: string
              example: '1651240791.123'
              description: 'This field captures the Unix timestamp in seconds indicating the occurrence of the event in Coordinated Universal Time (UTC).

                If this timestamp is not provided, the API will automatically set it to the time of event reception.

                You can also provide miliseconds precision by appending decimals to the timestamp.

                '
            precise_total_amount_cents:
              type: string
              nullable: true
              example: '1234.56'
              description: The precise total amount in cents with precision used by the `dynamic` pricing model to compute the usage amount.
            properties:
              type: object
              description: This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
              additionalProperties:
                oneOf:
                - type: string
                - type: integer
                - type: number
              example:
                gb: 10
    BaseAppliedTax:
      type: object
      properties:
        lago_id:
          type: string
          format: uuid
          description: Unique identifier of the applied tax, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_tax_id:
          type: string
          format: uuid
          description: Unique identifier of the tax, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        tax_name:
          type: string
          description: Name of the tax.
          example: TVA
        tax_code:
          type: string
          description: Unique code used to identify the tax associated with the API request.
          example: french_standard_vat
        tax_rate:
          type: number
          description: The percentage rate of the tax
          example: 20
        tax_description:
          type: string
          description: Internal description of the taxe
          example: French standard VAT
        amount_cents:
          type: integer
          description: Amount of the tax
          example: 2000
        amount_currency:
          allOf:
          - $ref: '#/components/schemas/Currency'
          - description: Currency of the tax
            example: USD
        created_at:
          type: string
          format: date-time
          description: The date and time when the applied tax 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 applied tax was initially created.
          example: '2022-09-14T16:35:31Z'
    EventBatchInput:
      type: object
      required:
      - events
      properties:
        events:
          type: array
          items:
            $ref: '#/components/schemas/EventInput/properties/event'
    EventEstimateFeesInput:
      type: object
      required:
      - event
      properties:
        event:
          type: object
          required:
          - code
          - external_subscription_id
          properties:
            code:
              type: string
              example: storage
              description: The code that identifies a targeted billable metric. It is essential that this code matches the `code` property of one of your active billable metrics. If the provided code does not correspond to any active billable metric, it will be ignored during the process.
            external_subscription_id:
              type: string
              example: sub_1234567890
              description: The unique identifier of the subscription within your application.
            properties:
              type: object
              description: This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
    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
    ApiErrorUnauthorized:
      type: object
      required:
      - status
      - error
      properties:
        status:
          type: integer
          format: int32
          example: 401
        error:
          type: string
          example: Unauthorized
    ApiErrorBadRequest:
      type: object
      required:
      - status
      - error
      properties:
        status:
          type: integer
          format: int32
          example: 400
        error:
          type: string
          example: Bad request
    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
      - 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
    EventObject:
      type: object
      required:
      - lago_id
      - transaction_id
      - lago_customer_id
      - code
      - timestamp
      - lago_subscription_id
      - external_subscription_id
      - created_at
      properties:
        lago_id:
          type: string
          format: uuid
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          description: Unique identifier assigned to the event within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the event's record within the Lago system
        transaction_id:
          type: string
          example: transaction_1234567890
          description: This field represents a unique identifier for the event. It is crucial for ensuring idempotency, meaning that each event can be uniquely identified and processed without causing any unintended side effects.
        lago_customer_id:
          type: string
          format: uuid
          nullable: true
          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
        code:
          type: string
          example: storage
          description: The code that identifies a targeted billable metric. It is essential that this code matches the `code` property of one of your active billable metrics. If the provided code does not correspond to any active billable metric, it will be ignored during the process.
        timestamp:
          type: string
          format: date-time
          example: '2022-04-29T08:59:51.123Z'
          description: This field captures the Unix timestamp in seconds indicating the occurrence of the event in Coordinated Universal Time (UTC). If this timestamp is not provided, the API will automatically set it to the time of event reception.
        precise_total_amount_cents:
          type: string
          nullable: true
          example: '1234.56'
          description: The precise total amount that was sent in the event payload. This filed is used by the `dynamic` pricing model.
        properties:
          type: object
          description: This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
          properties:
            operation_type:
              type: string
              description: The `operation_type` field is only necessary when adding or removing a specific unit when the targeted billable metric adopts a `unique_count_agg` aggregation method. In other cases, the `operation_type` field is not required. The valid values for the `operation_type` field are `add` or `remove`, which indicate whether the unit is being added or removed from the unique count aggregation, respectively.
              enum:
              - add
              - remove
          additionalProperties:
            oneOf:
            - type: string
            - type: integer
            - type: number
          example:
            gb: 10
        lago_subscription_id:
          type: string
          format: uuid
          nullable: true
          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_subscription_id:
          type: string
          example: sub_1234567890
          description: The unique identifier of the subscription within your application. It is a mandatory field when the customer possesses multiple subscriptions or when the `external_customer_id` is not provided.
        created_at:
          type: string
          format: date-time
          example: '2022-04-29T08:59:51Z'
          description: The creation date of the event's record in the Lago application, presented in the ISO 8601 datetime format, specifically in Coordinated Universal Time (UTC). It provides the precise timestamp of when the event's record was created within the Lago application
    FeeAppliedTaxObject:
      allOf:
      - $ref: '#/components/schemas/BaseAppliedTax'
      type: object
      properties:
        lago_fee_id:
          type: string
          format: uuid
          description: Unique identifier of the fee, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
    FeeObject:
      type: object
      required:
      - item
      - amount_cents
      - amount_currency
      - taxes_amount_cents
      - taxes_rate
      - total_amount_cents
      - total_amount_currency
      - pay_in_advance
      - invoiceable
      - units
      - precise_unit_amount
      - payment_status
      properties:
        lago_id:
          type: string
          format: uuid
          nullable: true
          description: Unique identifier assigned to the fee within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the fee's record within the Lago system.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_charge_id:
          type: string
          format: uuid
          nullable: true
          description: Unique identifier assigned to the charge that the fee belongs to
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_charge_filter_id:
          type: string
          format: uuid
          nullable: true
          description: Unique identifier assigned to the charge filter that the fee belongs to
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_invoice_id:
          type: string
          format: uuid
          nullable: true
          description: Unique identifier assigned to the invoice that the fee belongs to
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_true_up_fee_id:
          type: string
          format: uuid
          nullable: true
          description: Unique identifier assigned to the true-up fee when a minimum has been set to the charge. This identifier helps to distinguish and manage the true-up fee associated with the charge, which may be applicable when a minimum threshold or limit is set for the charge amount.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_true_up_parent_fee_id:
          type: string
          format: uuid
          nullable: true
          description: Unique identifier assigned to the parent fee on which the true-up fee is assigned. This identifier establishes the relationship between the parent fee and the associated true-up fee.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_subscription_id:
          type: string
          format: uuid
          nullable: true
          description: Unique identifier assigned to the subscription, created by Lago. This field is specifically displayed when the fee type is charge or subscription.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_customer_id:
          type: string
          format: uuid
          nullable: true
          description: Unique identifier assigned to the customer, created by Lago. This field is specifically displayed when the fee type is charge or subscription.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        external_customer_id:
          type: string
          nullable: true
          description: Unique identifier assigned to the customer in your application. This field is specifically displayed when the fee type is charge or subscription.
          example: external_id
        external_subscription_id:
          type: string
          nullable: true
          description: Unique identifier assigned to the subscription in your application. This field is specifically displayed when the fee type is charge or subscription.
          example: external_id
        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 (SF1)
        amount_cents:
          type: integer
          description: The cost of this specific fee, excluding any applicable taxes.
          example: 100
        precise_amount:
          type: string
          description: The cost of this specific fee, excluding any applicable taxes, with precision.
          example: '1.0001'
        precise_total_amount:
          type: string
          description: The cost of this specific fee, including any applicable taxes, with precision.
          example: '1.0212'
        amount_currency:
          allOf:
          - $ref: '#/components/schemas/Currency'
          - description: The currency of this specific fee. It indicates the monetary unit in which the fee's cost is expressed.
            example: EUR
        taxes_amount_cents:
          type: integer
          description: The cost of the tax associated with this specific fee.
          example: 20
        taxes_precise_amount:
          type: string
          description: The cost of the tax associated with this specific fee, with precision.
          example: '0.20123'
        taxes_rate:
          type: number
          description: The tax rate associated with this specific fee.
          example: 20
        units:
          type: string
          description: The number of units used to charge the customer. This field indicates the quantity or count of units consumed or utilized in the context of the charge. It helps in determining the basis for calculating the fee or cost associated with the usage of the service or product provided to the customer.
          example: '0.32'
        precise_unit_amount:
          type: string
          description: The unit amount of the fee per unit, with precision.
          example: '312.5'
        total_amount_cents:
          type: integer
          description: The cost of this specific fee, including any applicable taxes.
          example: 120
        total_amount_currency:
          allOf:
          - $ref: '#/components/schemas/Currency'
          - description: The currency of this specific fee, including any applicable taxes.
            example: EUR
        events_count:
          type: integer
          description: The number of events that have been sent and used to charge the customer. This field indicates the count or quantity of events that have been processed and considered in the charging process.
          example: 23
        pay_in_advance:
          type: boolean
          description: Flag that indicates whether the fee was paid in advance. It serves as a boolean value, where `true` represents that the fee was paid in advance (straightaway), and `false` indicates that the fee was not paid in arrears (at the end of the period).
          example: true
        invoiceable:
          type: boolean
          description: Flag that indicates whether the fee was included on the invoice. It serves as a boolean value, where `true` represents that the fee was included on the invoice, and `false` indicates that the fee was not included on the invoice.
          example: true
        from_date:
          type: string
          format: date-time
          nullable: true
          description: The beginning date of the period that the fee covers. It is applicable only to `subscription` and `charge` fees. This field indicates the start date of the billing period or subscription period associated with the fee.
          example: '2022-04-29T08:59:51Z'
        to_date:
          type: string
          format: date-time
          nullable: true
          description: The ending date of the period that the fee covers. It is applicable only to `subscription` and `charge` fees. This field indicates the end date of the billing period or subscription period associated with the fee.
          example: '2022-05-29T08:59:51Z'
        payment_status:
          type: string
          enum:
          - pending
          - succeeded
          - failed
          - refunded
          description: Indicates the payment status of the fee. It represents the current status of the payment associated with the fee. The possible values for this field are `pending`, `succeeded`, `failed` and `refunded`.
          example: pending
        created_at:
          type: string
          format: date-time
          nullable: true
          description: The date and time when the fee was created. It is provided in Coordinated Universal Time (UTC) format.
          example: '2022-08-24T14:58:59Z'
        succeeded_at:
          type: string
          format: date-time
          nullable: true
          description: The date and time when the payment for the fee was successfully processed. It is provided in Coordinated Universal Time (UTC) format.
          example: '2022-08-24T14:58:59Z'
        failed_at:
          type: string
          format: date-time
          nullable: true
          description: The date and time when the payment for the fee failed to process. It is provided in Coordinated Universal Time (UTC) format.
          example: '2022-08-24T14:58:59Z'
        refunded_at:
          type: string
          format: date-time
          nullable: true
          description: The date and time when the payment for the fee was refunded. It is provided in Coordinated Universal Time (UTC) format
          example: '2022-08-24T14:58:59Z'
        event_transaction_id:
          type: string
          nullable: true
          description: Unique identifier assigned to the transaction. This field is specifically displayed when the fee type is `charge` and the payment for the fee is made in advance (`pay_in_advance` is set to `true`).
          example: transaction_1234567890
        amount_details:
          allOf:
          - type: object
            properties:
              graduated_ranges:
                type: array
                description: Graduated ranges, used for a `graduated` charge model.
                items:
                  type: object
                  required:
                  - units
                  - from_value
                  - to_value
                  - flat_unit_amount
                  - per_unit_amount
                  - per_unit_total_amount
                  - total_with_flat_amount
                  properties:
                    units:
                      type: string
                      pattern: ^[0-9]+.?[0-9]*$
                      example: '10.0'
                      description: Total units received in Lago.
                    from_value:
                      type: integer
                      description: Lower value of a tier. It is either 0 or the previous range's `to_value + 1`.
                      example: 0
                    to_value:
                      type: integer
                      description: 'Highest value of a tier.

                        - This value is higher than the from_value of the same tier.

                        - This value is null for the last tier.'
                      nullable: true
                      example: 10
                    flat_unit_amount:
                      type: string
                      description: Flat unit amount within a specified tier.
                      example: '1.0'
                    per_unit_amount:
                      type: string
                      description: Amount per unit within a specified tier.
                      example: '1.0'
                    per_unit_total_amount:
                      type: string
                      description: Total amount of received units to be charged within a specified tier.
                      example: '10.0'
                    total_with_flat_amount:
                      type: string
                      description: Total amount to be charged for a specific tier, taking into account the flat_unit_amount and the per_unit_total_amount.
                      example: '11.0'
              graduated_percentage_ranges:
                type: array
                description: Graduated percentage ranges, used for a `graduated_percentage` charge model.
                items:
                  type: object
                  required:
                  - units
                  - from_value
                  - to_value
                  - flat_unit_amount
                  - rate
                  - per_unit_total_amount
                  - total_with_flat_amount
                  properties:
                    units:
                      type: string
                      pattern: ^[0-9]+.?[0-9]*$
                      example: '10.0'
                      description: Total units received in Lago.
           

# --- truncated at 32 KB (41 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/lago/refs/heads/main/openapi/lago-events-api-openapi.yml