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

# Record a usage event

> Records a usage event into the Usage timeseries collection.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/sdk/usages
openapi: 3.0.0
info:
  contact: {}
  description: The SolvaPay REST API specification
  title: SolvaPay REST API
  version: '1.0'
servers: []
security: []
tags: []
paths:
  /v1/sdk/usages:
    post:
      tags:
        - Usage
      summary: Record a usage event
      description: Records a usage event into the Usage timeseries collection.
      operationId: UsageSdkController_recordUsage
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUsageRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageRecordResponse'
          description: Usage recorded successfully
        '400':
          description: Validation failed
      security:
        - SecretKey: []
components:
  schemas:
    CreateUsageRequest:
      properties:
        actionType:
          default: api_call
          enum:
            - transaction
            - api_call
            - hour
            - email
            - storage
            - custom
          type: string
        customerRef:
          maxLength: 20
          minLength: 1
          type: string
        description:
          type: string
        duration:
          exclusiveMinimum: false
          minimum: 0
          type: number
        errorMessage:
          type: string
        idempotencyKey:
          maxLength: 256
          type: string
        metadata:
          additionalProperties: true
          type: object
        outcome:
          default: success
          enum:
            - success
            - paywall
            - fail
          type: string
        productRef:
          maxLength: 20
          type: string
        purchaseRef:
          maxLength: 20
          type: string
        timestamp:
          format: date-time
          type: string
        units:
          default: 1
          exclusiveMaximum: false
          exclusiveMinimum: false
          maximum: 100000
          minimum: 0
          type: integer
      required:
        - customerRef
        - timestamp
      type: object
    UsageRecordResponse:
      properties:
        creditDebit:
          oneOf:
            - $ref: '#/components/schemas/CreditDebitSuccessResponse'
            - $ref: '#/components/schemas/CreditDebitSkippedResponse'
        reference:
          example: usage_A1B2C3D4
          type: string
        success:
          example: true
          type: boolean
      required:
        - success
        - reference
      type: object
    CreditDebitSuccessResponse:
      properties:
        amount:
          description: >-
            Credits debited for this usage event (credits are USD-pegged at 100
            credits per minor unit, so a 1¢/unit charge debits 100 credits/unit)
          example: 100
          type: number
        autoRecharge:
          $ref: '#/components/schemas/AutoRechargeTriggeredResponse'
        debited:
          enum:
            - true
          type: number
        unitsRemaining:
          description: Estimated remaining units after debit
          example: 99
          type: number
      required:
        - debited
        - amount
        - unitsRemaining
      type: object
    CreditDebitSkippedResponse:
      properties:
        debited:
          enum:
            - false
          type: number
        reason:
          description: Reason no credit debit was recorded
          enum:
            - duplicate
            - no_product_ref
            - customer_not_found
            - no_active_purchase
            - plan_not_credit_based
          example: duplicate
          type: string
      required:
        - debited
        - reason
      type: object
    AutoRechargeTriggeredResponse:
      properties:
        triggered:
          description: >-
            Whether the server initiated an auto-recharge charge after this
            debit (TOPUP credit lands via webhook)
          example: true
          type: boolean
      required:
        - triggered
      type: object
  securitySchemes:
    SecretKey:
      bearerFormat: JWT
      description: >-
        Provider secret API key (sk_live_… / sk_test_…) supplied as a Bearer
        token.
      scheme: bearer
      type: http

````