Cayra Usage API

The usage API from Cayra — 6 operation(s) for usage.

Operations 6

POST /api/v1/usage/events Record Usage Event #
GET /api/v1/usage/balance Get Usage Balance #
GET /api/v1/usage/daily Get Daily Usage #
POST /api/v1/licenses/{license_key}/usage/events Record Usage Event With License Key #
GET /api/v1/licenses/{license_key}/usage/balance Get Usage Balance With License Key #
GET /api/v1/licenses/{license_key}/usage/daily Get Daily Usage With License Key #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/cayra-io:cayra-io-usage-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

cayra-io-usage-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Cayra License Server Usage API
  description: '# Cayra Chat Agent - License Management Server


    Centralized license management for on-premise deployments.


    ## Features


    - 🔑 License key generation (installation, update, trial)

    - ⏰ Dynamic expiry management (extend/shorten licenses)

    - 🔄 Activation tracking and monitoring

    - 💓 Heartbeat mechanism (1-hour intervals)

    - 📊 Audit logging for compliance

    - 🔐 JWT tokens with RSA-4096 encryption


    ## API Categories


    ### Admin Endpoints (Requires API Key)

    Manage licenses, view activations, update expiry dates.


    ### Client Endpoints (Public)

    Activate licenses, send heartbeats, check status.


    ## Authentication


    Admin endpoints require API key in header:

    ```

    X-Admin-API-Key: your-admin-key-here

    ```


    ## Security


    - 🔒 RSA-4096 asymmetric encryption

    - 🔐 JWT tokens for offline validation

    - 📝 Complete audit trail

    - 🛡️ Rate limiting (Phase 6)'
  contact:
    name: Cayra AI Team
    email: support@cayra.ai
  license:
    name: Proprietary
  version: 1.0.0
tags:
- name: Usage
paths:
  /api/v1/usage/events:
    post:
      tags:
      - Usage
      summary: Record Usage Event
      description: 'Record a usage event coming from the chat service.


        This endpoint is internal and protected by a service API key.'
      operationId: record_usage_event_api_v1_usage_events_post
      parameters:
      - name: X-Usage-API-Key
        in: header
        required: false
        schema:
          type: string
          title: X-Usage-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UsageEventRequest'
      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'
  /api/v1/usage/balance:
    get:
      tags:
      - Usage
      summary: Get Usage Balance
      description: Retrieve current balance for a license.
      operationId: get_usage_balance_api_v1_usage_balance_get
      parameters:
      - name: license_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
          description: License identifier
          title: License Id
        description: License identifier
      - name: X-Usage-API-Key
        in: header
        required: false
        schema:
          type: string
          title: X-Usage-Api-Key
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageBalanceResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/usage/daily:
    get:
      tags:
      - Usage
      summary: Get Daily Usage
      description: Retrieve aggregated daily usage data for a license.
      operationId: get_daily_usage_api_v1_usage_daily_get
      parameters:
      - name: license_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
          description: License identifier
          title: License Id
        description: License identifier
      - name: start_date
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            format: date
          - type: 'null'
          description: Start date (inclusive)
          title: Start Date
        description: Start date (inclusive)
      - name: end_date
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            format: date
          - type: 'null'
          description: End date (inclusive)
          title: End Date
        description: End date (inclusive)
      - name: model_name
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Filter by specific model name
          title: Model Name
        description: Filter by specific model name
      - name: X-Usage-API-Key
        in: header
        required: false
        schema:
          type: string
          title: X-Usage-Api-Key
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DailyUsageListResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/licenses/{license_key}/usage/events:
    post:
      tags:
      - Usage
      summary: Record Usage Event With License Key
      description: Record usage for a license using the license key as the credential.
      operationId: record_usage_event_with_license_key_api_v1_licenses__license_key__usage_events_post
      parameters:
      - name: license_key
        in: path
        required: true
        schema:
          type: string
          title: License Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LicenseUsageEventRequest'
      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'
  /api/v1/licenses/{license_key}/usage/balance:
    get:
      tags:
      - Usage
      summary: Get Usage Balance With License Key
      description: Fetch usage balance for a license via license key authentication.
      operationId: get_usage_balance_with_license_key_api_v1_licenses__license_key__usage_balance_get
      parameters:
      - name: license_key
        in: path
        required: true
        schema:
          type: string
          title: License Key
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageBalanceResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/licenses/{license_key}/usage/daily:
    get:
      tags:
      - Usage
      summary: Get Daily Usage With License Key
      description: Retrieve aggregated daily usage for a license via license key authentication.
      operationId: get_daily_usage_with_license_key_api_v1_licenses__license_key__usage_daily_get
      parameters:
      - name: license_key
        in: path
        required: true
        schema:
          type: string
          title: License Key
      - name: start_date
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            format: date
          - type: 'null'
          description: Start date (inclusive)
          title: Start Date
        description: Start date (inclusive)
      - name: end_date
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            format: date
          - type: 'null'
          description: End date (inclusive)
          title: End Date
        description: End date (inclusive)
      - name: model_name
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Filter by specific model name
          title: Model Name
        description: Filter by specific model name
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DailyUsageListResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    DailyUsageEntry:
      properties:
        usage_date:
          type: string
          format: date
          title: Usage Date
        model_name:
          type: string
          title: Model Name
        input_tokens:
          type: integer
          title: Input Tokens
        output_tokens:
          type: integer
          title: Output Tokens
        total_cost:
          type: number
          title: Total Cost
      type: object
      required:
      - usage_date
      - model_name
      - input_tokens
      - output_tokens
      - total_cost
      title: DailyUsageEntry
      description: Aggregated usage entry.
    UsageEventResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        balance:
          $ref: '#/components/schemas/UsageBalanceSummary'
        daily_usage:
          $ref: '#/components/schemas/DailyUsageEntry'
      type: object
      required:
      - balance
      - daily_usage
      title: UsageEventResponse
      description: Response after persisting a usage event.
    UsageBalanceSummary:
      properties:
        license_id:
          type: string
          format: uuid
          title: License Id
        current_balance:
          type: number
          title: Current Balance
        currency:
          type: string
          title: Currency
        allow_external_api:
          type: boolean
          title: Allow External Api
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
      - license_id
      - current_balance
      - currency
      - allow_external_api
      - updated_at
      title: UsageBalanceSummary
      description: Balance information for a license.
    LicenseUsageEventRequest:
      properties:
        model_name:
          type: string
          maxLength: 128
          title: Model Name
          description: LLM model name
        input_tokens:
          type: integer
          minimum: 0.0
          title: Input Tokens
          description: Prompt tokens consumed
          default: 0
        output_tokens:
          type: integer
          minimum: 0.0
          title: Output Tokens
          description: Completion tokens produced
          default: 0
        cache_read_tokens:
          type: integer
          minimum: 0.0
          title: Cache Read Tokens
          description: Prompt cache read tokens (if provider supports)
          default: 0
        cache_creation_tokens:
          type: integer
          minimum: 0.0
          title: Cache Creation Tokens
          description: Prompt cache creation tokens (if provider supports)
          default: 0
        idempotency_key:
          anyOf:
          - type: string
            maxLength: 255
          - type: 'null'
          title: Idempotency Key
          description: Optional idempotency key for dedupe
        run_id:
          anyOf:
          - type: string
            maxLength: 255
          - type: 'null'
          title: Run Id
          description: Optional execution run identifier
        total_cost:
          type: number
          minimum: 0.0
          title: Total Cost
          description: Cost in license currency
        usage_date:
          anyOf:
          - type: string
            format: date
          - type: 'null'
          title: Usage Date
          description: Override usage date (defaults to current UTC date)
      type: object
      required:
      - model_name
      - total_cost
      title: LicenseUsageEventRequest
      description: Usage event payload for license-key scoped endpoints.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
            - type: string
            - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
      - loc
      - msg
      - type
      title: ValidationError
    UsageBalanceResponse:
      properties:
        balance:
          $ref: '#/components/schemas/UsageBalanceSummary'
      type: object
      required:
      - balance
      title: UsageBalanceResponse
      description: Response wrapper for balance endpoint.
    DailyUsageListResponse:
      properties:
        license_id:
          type: string
          format: uuid
          title: License Id
        usage:
          items:
            $ref: '#/components/schemas/DailyUsageEntry'
          type: array
          title: Usage
        total_input_tokens:
          type: integer
          title: Total Input Tokens
        total_output_tokens:
          type: integer
          title: Total Output Tokens
        total_cost:
          type: number
          title: Total Cost
      type: object
      required:
      - license_id
      - usage
      - total_input_tokens
      - total_output_tokens
      - total_cost
      title: DailyUsageListResponse
      description: Daily usage list response.
    UsageEventRequest:
      properties:
        license_id:
          type: string
          format: uuid
          title: License Id
          description: License identifier (UUID)
        model_name:
          type: string
          maxLength: 128
          title: Model Name
          description: LLM model name
        input_tokens:
          type: integer
          minimum: 0.0
          title: Input Tokens
          description: Prompt tokens consumed
          default: 0
        output_tokens:
          type: integer
          minimum: 0.0
          title: Output Tokens
          description: Completion tokens produced
          default: 0
        cache_read_tokens:
          type: integer
          minimum: 0.0
          title: Cache Read Tokens
          description: Prompt cache read tokens (if provider supports)
          default: 0
        cache_creation_tokens:
          type: integer
          minimum: 0.0
          title: Cache Creation Tokens
          description: Prompt cache creation tokens (if provider supports)
          default: 0
        idempotency_key:
          anyOf:
          - type: string
            maxLength: 255
          - type: 'null'
          title: Idempotency Key
          description: Optional idempotency key for dedupe
        run_id:
          anyOf:
          - type: string
            maxLength: 255
          - type: 'null'
          title: Run Id
          description: Optional execution run identifier
        total_cost:
          type: number
          minimum: 0.0
          title: Total Cost
          description: Cost in license currency
        usage_date:
          anyOf:
          - type: string
            format: date
          - type: 'null'
          title: Usage Date
          description: Override usage date (defaults to current UTC date)
      type: object
      required:
      - license_id
      - model_name
      - total_cost
      title: UsageEventRequest
      description: Request body for reporting usage events.