> ## 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 wallet alert

> This endpoint allows you to create a new alert for a wallet.

<Info>
  You can also create multiple wallet alerts at once.
</Info>


## OpenAPI

````yaml POST /customers/{external_customer_id}/wallets/{wallet_code}/alerts
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.45.2
  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:
  /customers/{external_customer_id}/wallets/{wallet_code}/alerts:
    parameters:
      - $ref: '#/components/parameters/external_customer_id_path'
      - $ref: '#/components/parameters/wallet_code'
    post:
      tags:
        - wallets
      summary: Create wallet alert(s)
      description: >-
        This endpoint allows you to create new alerts for a wallet. Send a
        single alert object wrapped in `alert` key to create one alert, or an
        array of alert objects wrapped in `alerts` key to create multiple alerts
        atomically.
      operationId: createCustomerWalletAlert
      requestBody:
        description: Create a new alert for a wallet
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/WalletAlertCreateInput'
                - $ref: '#/components/schemas/WalletAlertBatchCreateInput'
        required: true
      responses:
        '200':
          description: Wallet alert(s) created
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/WalletAlert'
                  - $ref: '#/components/schemas/WalletAlerts'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
components:
  parameters:
    external_customer_id_path:
      name: external_customer_id
      in: path
      description: >-
        The customer external unique identifier (provided by your own
        application)
      required: true
      schema:
        type: string
        example: 5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba
    wallet_code:
      name: wallet_code
      in: path
      description: >-
        A unique wallet identifier within a customer. It is either set by the
        user at creation or auto-generated by Lago if not provided.
      required: true
      schema:
        type: string
        example: wallet-code
  schemas:
    WalletAlertCreateInput:
      type: object
      required:
        - alert
      properties:
        alert:
          allOf:
            - $ref: '#/components/schemas/AlertBaseInput'
            - type: object
              required:
                - alert_type
                - code
                - thresholds
              properties:
                alert_type:
                  type: string
                  description: The type of alert.
                  enum:
                    - wallet_balance_amount
                    - wallet_credits_balance
                    - wallet_ongoing_balance_amount
                    - wallet_credits_ongoing_balance
                  example: wallet_balance_amount
                code:
                  type: string
                  description: Unique code used to identify the alert.
                  example: wallet_balance_alert
                name:
                  type:
                    - string
                    - 'null'
                  description: The name of the alert.
                  example: Wallet Balance Alert
    WalletAlertBatchCreateInput:
      type: object
      required:
        - alerts
      properties:
        alerts:
          type: array
          description: >-
            Array of alerts to create. All alerts are created atomically - if
            any fail validation, none are created.
          items:
            allOf:
              - $ref: '#/components/schemas/AlertBaseInput'
              - type: object
                required:
                  - alert_type
                  - code
                  - thresholds
                properties:
                  alert_type:
                    type: string
                    description: The type of alert.
                    enum:
                      - wallet_balance_amount
                      - wallet_credits_balance
                      - wallet_ongoing_balance_amount
                      - wallet_credits_ongoing_balance
                    example: wallet_balance_amount
                  code:
                    type: string
                    description: Unique code used to identify the alert.
                    example: wallet_balance_alert
                  name:
                    type:
                      - string
                      - 'null'
                    description: The name of the alert.
                    example: Wallet Balance Alert
    WalletAlert:
      type: object
      required:
        - alert
      properties:
        alert:
          $ref: '#/components/schemas/WalletAlertObject'
    WalletAlerts:
      type: object
      required:
        - alerts
      properties:
        alerts:
          type: array
          items:
            $ref: '#/components/schemas/WalletAlertObject'
        meta:
          $ref: '#/components/schemas/PaginationMeta'
    AlertBaseInput:
      type: object
      properties:
        code:
          type: string
          description: Unique code used to identify the alert.
          example: storage_threshold_alert
        name:
          type:
            - string
            - 'null'
          description: The name of the alert.
          example: Storage Usage Alert
        thresholds:
          type: array
          description: Array of thresholds associated with the alert.
          items:
            $ref: '#/components/schemas/AlertThresholdInput'
    WalletAlertObject:
      type: object
      required:
        - lago_id
        - lago_organization_id
        - external_subscription_id
        - billable_metric
        - alert_type
        - code
        - name
        - previous_value
        - last_processed_at
        - thresholds
        - created_at
      properties:
        lago_id:
          type: string
          format: uuid
          description: Unique identifier of the alert, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        lago_organization_id:
          type: string
          format: uuid
          description: Unique identifier of the organization, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        external_subscription_id:
          type: 'null'
        lago_wallet_id:
          type: string
          description: Unique identifier of the wallet, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        wallet_code:
          type: string
          description: >-
            The wallet external unique identifier (provided by your own
            application).
          example: wallet_code
        billable_metric:
          type: 'null'
        alert_type:
          type: string
          description: The type of alert.
          enum:
            - wallet_balance_amount
            - wallet_credits_balance
            - wallet_ongoing_balance_amount
            - wallet_credits_ongoing_balance
          example: wallet_balance_amount
        code:
          type: string
          description: Unique code used to identify the alert.
          example: wallet_balance_alert
        name:
          type:
            - string
            - 'null'
          description: The name of the alert.
          example: Wallet Balance Alert
        direction:
          type: string
          description: >-
            Indicates whether the alert is triggered when the monitored metric
            goes above or below the threshold.
          enum:
            - increasing
            - decreasing
          example: decreasing
        previous_value:
          type: number
          description: >-
            When the system checked if this alert should be triggered, this
            value was retrieved and checked against the thresholds.
          example: 1000
        last_processed_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            The date and time in UTC (ISO 8601) when the system checked if this
            alert should be triggered. Null until it's processed for the first
            time.
          example: '2025-05-19T10:04:21Z'
        thresholds:
          type: array
          description: Array of thresholds associated with the alert.
          items:
            $ref: '#/components/schemas/AlertThresholdObject'
        created_at:
          type: string
          format: date-time
          description: The date and time in UTC (ISO 8601) when the alert was created.
          example: '2025-03-20T10:00:00Z'
    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
    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
    AlertThresholdInput:
      allOf:
        - $ref: '#/components/schemas/AlertThresholdBaseObject'
        - type: object
          required:
            - value
          properties:
            value:
              oneOf:
                - type: integer
                - type: string
              description: >-
                A value that should trigger this alert. This can be an integer
                or a string formatted as a BigDecimal.
              example: 99
    AlertThresholdObject:
      allOf:
        - $ref: '#/components/schemas/AlertThresholdBaseObject'
        - type: object
          required:
            - code
            - value
            - recurring
          properties:
            value:
              type: string
              pattern: ^[0-9]+.?[0-9]*$
              description: >-
                A value that should trigger this alert, formatted as a
                BigDecimal.
              example: '99.0'
    AlertThresholdBaseObject:
      type: object
      properties:
        code:
          type:
            - string
            - 'null'
          description: Unique identifier of the usage threshold created by Lago.
          example: warn
        recurring:
          type: boolean
          default: false
          description: >-
            This field when set to `true` indicates that the alert will be
            retrigger when this threshold is reached after the last
            non-recurring threshold. Only one recurring threshold per alert
            allowed.
          example: false
  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

````