Billable Events Schema

Overview

The billable events schema defines the structure and fields for tracking usage events that contribute to customer billing. This schema is used across GitLab SaaS, Dedicated, and Self-Managed deployments to capture standardized usage data for billing purposes.

This document serves as the reference for the billable usage event schema based on the billable_usage jsonschema.

Field Descriptions

Event Identification Fields

Fields that uniquely identify and categorize the billable event.

FieldDescriptionSnowplow FieldType
event_idUnique identifier for the event (RFC9562 UUID)event_idUUID (String)
app_idIdentifier for the application (e.g., GitLab Duo Workflow, Dedicated Hosted Runners)app_idString
event_typeName of the billable event (breakdown of feature, e.g., code_review)event_typeString
timestampTimestamp when the event occurredcontext_generated_atString
correlation_idUnique request ID for each requestcorrelation_idString

Instance & Environment Fields

Fields that identify the GitLab deployment environment and instance.

FieldDescriptionSnowplow FieldType
realmSaaS, Dedicated, or SM (Self-Managed)realmString (enum)
deployment_typeDeployment type: .com, dedicated, or self-managed. Created to replace realm in the futuredeployment_typeString (enum)
unique_instance_idUnique ID of the GitLab instance where the request originatesunique_instance_idUUID (String)
instance_idUnique ID of the GitLab instance where the request originates (GitLab version < 17.11)instance_idUUID (String)
host_nameHostname of the GitLab instance where the request originates (e.g., abc.xyz.com)host_nameString

User & Resource Identification Fields

Fields that identify users, seats, and resources associated with the billable event.

FieldDescriptionSnowplow FieldType
subjectIdentifier for the user in the customer organization or identifier for runner where user identification is not presentsubjectString
global_user_idAnonymized global user ID which is unique across instancesglobal_user_idString
assignmentsProduct assignments associated with the user at the time of event creation (e.g., Duo Pro, Duo Enterprise)-Array[String]
project_idID of the associated project (e.g., 122344)project_idInteger
namespace_idID of the associated namespace (e.g., 3445555)namespace_idInteger
root_namespace_idID of the associated ultimate parent namespace (e.g., 5343322)root_namespace_idInteger
entity_idID of the entity associated with the evententity_idString
organization_idID of the associated organization (e.g., 1445)organization_idInteger

Usage Measurement Fields

Fields that capture the actual usage quantities for billing.

FieldDescriptionSnowplow FieldType
unit_of_measureThe base unit used for measurement and billing (e.g., ‘byte’, ‘second’, ‘request’). Used for accurate unit conversion and billing calculations.unit_of_measureString
quantityQuantity of usage measured in the specified unitquantityDecimal (Number)
metadataFlexible metadata field for key-value pairs or nested objects containing additional contextmetadataObject (JSON)

Implementation Guidelines

Required Fields for Billing

The following fields are critical for billing calculations and must be present in all billable events:

  • event_id: Ensures event uniqueness and deduplication
  • event_type: Categorizes the billable activity
  • unit_of_measure: Defines the billing unit
  • realm: Identifies the deployment model
  • timestamp: Enables time-based billing and analysis

Field Population Guidelines

  1. Event Identification: Always generate a unique RFC9562 UUID for event_id
  2. Timestamps: Use ISO 8601 format (e.g., 2025-11-04T10:30:00Z)
  3. Unit of Measure: Choose appropriate units (byte, second, token, request, etc.)
  4. Quantity: Must be a non-negative, non-zero number representing actual usage
  5. Metadata: Use for additional context that aids in analytics but is not required for billing

Metadata fields for GitLab Duo Agent Platform

FieldTypeDescriptionRequired
workflow_idStringUnique identifier for the workflow executionYes
execution_environmentStringEnvironment where the workflow was executed (e.g., duo_agent_platform)Yes
llm_operationsArrayList of LLM operations performed during the workflowYes
llm_operations[].token_countIntegerTotal number of tokens used in the operationYes
llm_operations[].model_idStringIdentifier of the LLM model used (e.g., claude-3-sonnet-20240229)Yes
llm_operations[].prompt_tokensIntegerNumber of tokens in the promptYes
llm_operations[].completion_tokensIntegerNumber of tokens in the completion/responseYes

Example:

{
    "workflow_id": "wf_123456",
    "execution_environment": "duo_agent_platform",
    "llm_operations": [
        {
            "token_count": 5328,
            "model_id": "claude-3-sonnet-20240229",
            "prompt_tokens": 3150,
            "completion_tokens": 2178
        },
        {
            "token_count": 5328,
            "model_id": "claude-opus-4.1",
            "prompt_tokens": 3150,
            "completion_tokens": 2178
        }
    ]
}