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

# Add Usage



## OpenAPI

````yaml POST /billing/usage
openapi: 3.1.0
info:
  title: OpenAPI Valyx API
  description: To demonstrate features in the Valyx
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.valyx.com
security:
  - bearerAuth:
      - demo-api
tags:
  - name: billing
    description: External Billing APIs
  - name: external
    description: External APIs for customers
  - name: invoice
    description: Invoice APIs
  - name: creditNote
    description: Credit Note APIs
paths:
  /billing/usage:
    parameters:
      - name: X-Valyx-Signature
        in: header
        required: true
        description: Auth key to authenticate the request
        schema:
          type: string
    post:
      tags:
        - billing
      operationId: post_add_usage
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUsageAPIRequestModel'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageAdditionResponseModel'
components:
  schemas:
    CreateUsageAPIRequestModel:
      type: object
      required:
        - eventTimeStamp
        - metrics
        - usageReferenceId
        - buyerId
        - tags
      properties:
        buyerId:
          type: string
          description: Unique identifier of the buyer associated with this usage event
          example: buyer_12345
        contractId:
          type: string
          description: Identifier of the contract under which the usage is recorded
          example: contract_67890
        eventId:
          type: string
          description: Optional unique ID for this usage event, useful for idempotency
          example: event_abc123
        eventTimeStamp:
          type: integer
          description: Unix timestamp in milliseconds representing when the usage occurred
          example: 1755079200000
        tags:
          type: object
          description: Custom key-value tags associated with this usage
          additionalProperties:
            type: string
          example:
            region: US-East
            plan: Enterprise
            feature: premium_support
        metrics:
          type: array
          description: List of usage metrics for this event
          items:
            type: object
            properties:
              usage_driver_id:
                type: string
                description: Identifier for the usage driver or metric type
                example: usage_driver_001
              quantity:
                type: number
                format: float
                description: The measured quantity for this usage driver
                example: 42.5
              count:
                type: integer
                description: Optional count associated with this metric
                example: 1
        usageReferenceId:
          type: string
          description: A unique reference ID for tracking this usage event across systems
          example: usage_ref_98765
        metadata:
          type: object
          description: >-
            Optional metadata for storing extra key-value information about the
            usage event.
          additionalProperties: true
          example:
            company_id: '3932'
            recon_date: '2025-05-06 00:00:00'
            company_name: Reliance Europa Limited
            old_bag_status: Returned
    UsageAdditionResponseModel:
      properties:
        error:
          type: string
        message:
          type: string
        data:
          $ref: '#/components/schemas/UsageAdditionResponseModelData'
      type: object
    UsageAdditionResponseModelData:
      properties:
        usagesAdded:
          type: array
          items:
            $ref: '#/components/schemas/UsageAdditionResponseModelDatausagesAdded'
        errors:
          type: array
          items:
            type: string
            description: errors
      type: object
    UsageAdditionResponseModelDatausagesAdded:
      properties:
        usageDriverId:
          type: string
          description: usageDriverId
        usageDriverName:
          type: string
          description: usageDriverName
        contractId:
          type: string
          description: contractId
        value:
          type: number
          description: value
      type: object

````