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

# Record usage



## OpenAPI

````yaml POST /usages/
openapi: 3.0.3
info:
  title: Piriod API
  version: 1.0.0
  description: >
    Piriod API for billing, payments, procurement and collections.


    All requests require:

    - `Authorization: Token <api_token>` header.

    - `x-simple-workspace: <workspace_id>` header (the account/workspace
    identifier).

    - Optionally `x-piriod-test-mode: true` to operate against test-mode data.


    See the Documentation tab for getting started, integration flows,
    authentication,

    error handling and pagination/filtering guides.
servers:
  - url: https://api.piriod.com
    description: Production
security:
  - TokenAuth: []
paths:
  /usages/:
    post:
      tags:
        - Billing
      summary: Record usage
      parameters:
        - $ref: '#/components/parameters/WorkspaceHeader'
        - $ref: '#/components/parameters/TestModeHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Usage'
      responses:
        '201':
          description: Usage recorded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Usage'
        '400':
          $ref: '#/components/responses/ValidationFailed'
components:
  parameters:
    WorkspaceHeader:
      name: x-simple-workspace
      in: header
      required: true
      schema:
        type: string
      description: Workspace (account) identifier. Required for every request.
      example: acc_01H8XYZ123ABC
    TestModeHeader:
      name: x-piriod-test-mode
      in: header
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to operate against test-mode data. Defaults to `false`.
  schemas:
    Usage:
      type: object
      description: |
        A usage record posted against a metered subscription line. The line's
        plan must have `usage_scheme=metered`.
      properties:
        id:
          type: integer
          readOnly: true
        subscription_line:
          type: integer
          description: Subscription line ID this usage belongs to.
        date_time:
          type: string
          format: date-time
          description: Timestamp the usage was recorded for.
        quantity:
          type: number
        creation_scheme:
          type: string
          enum:
            - api
            - file
            - panel
          readOnly: true
        created:
          type: string
          format: date-time
          readOnly: true
      required:
        - subscription_line
        - date_time
        - quantity
    ValidationError:
      type: object
      additionalProperties:
        type: array
        items:
          type: string
      description: |
        Field-keyed error map. The special key `non_field_errors` carries
        errors that are not bound to a specific field.
      example:
        name:
          - This field is required.
        non_field_errors:
          - x-simple-workspace header is required.
  responses:
    ValidationFailed:
      description: Request body or query parameters failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
  securitySchemes:
    TokenAuth:
      type: apiKey
      in: header
      name: Authorization
      description: |
        Use header `Authorization: Token <api_token>`.
        API tokens are obtained from the Piriod dashboard.

````