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

# Create Usage Event

> Log a usage event from the agent worker.



## OpenAPI

````yaml /openapi.json post /api/usage/events
openapi: 3.1.0
info:
  title: Nenyax API
  description: Backend API for Nenyax Voice Agent Platform
  version: 0.1.0
servers:
  - url: http://localhost:8000
    description: Local development
security: []
paths:
  /api/usage/events:
    post:
      tags:
        - Usage
      summary: Create Usage Event
      description: Log a usage event from the agent worker.
      operationId: create_usage_event_api_usage_events_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UsageEventCreate'
        required: true
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageEventResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    UsageEventCreate:
      properties:
        session_id:
          type: string
          title: Session Id
        user_id:
          type: string
          title: User Id
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
        provider:
          type: string
          title: Provider
        event_type:
          $ref: '#/components/schemas/UsageEventType'
        quantity:
          anyOf:
            - type: number
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Quantity
        unit_cost:
          anyOf:
            - type: number
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Unit Cost
        total_cost:
          anyOf:
            - type: number
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Total Cost
      type: object
      required:
        - session_id
        - user_id
        - provider
        - event_type
        - quantity
        - unit_cost
        - total_cost
      title: UsageEventCreate
    UsageEventResponse:
      properties:
        id:
          type: string
          title: Id
        session_id:
          type: string
          title: Session Id
        user_id:
          type: string
          title: User Id
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
        provider:
          type: string
          title: Provider
        event_type:
          $ref: '#/components/schemas/UsageEventType'
        quantity:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Quantity
        unit_cost:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Unit Cost
        total_cost:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Total Cost
        created_at:
          type: string
          format: date-time
          title: Created At
      type: object
      required:
        - id
        - session_id
        - user_id
        - provider
        - event_type
        - quantity
        - unit_cost
        - total_cost
        - created_at
      title: UsageEventResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    UsageEventType:
      type: string
      enum:
        - stt_minutes
        - llm_tokens
        - tts_characters
      title: UsageEventType
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````