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

# Create a new usage event



## OpenAPI

````yaml /api-reference/ubb_openapi_inline.json post /events
openapi: 3.0.1
info:
  title: Usage Based Billing API
  version: 1.0.0
  description: An Orchestrator for Usage Based Billing and Payments
servers:
  - url: https://api-m.sandbox.paypal.com/v1/commerce/billing
security:
  - BearerAuth:
      - read
      - write
tags:
  - name: Alerts
    description: API endpoints for managing subscription alerts
  - name: Events
    description: API endpoints for managing events
  - name: Metrics
    description: API endpoints for metrics and usage data
  - name: Merchant Activation
    description: API endpoint for merchant activation
  - name: Credit Notes
    description: API endpoints for credit notes management
  - name: Customers
    description: API endpoints for customer management
  - name: Invoices
    description: API endpoints for invoice management
  - name: Plans
    description: API endpoints for subscription plans
  - name: Subscriptions
    description: API endpoints for subscriptions
  - name: Wallets
    description: API endpoints for wallet management
  - name: Taxes
    description: API endpoints for tax management
  - name: Billing Entities
    description: API endpoints for billing entities
  - name: Features
    description: API endpoints for managing features and privileges
  - name: Entitlements
    description: API endpoints for managing plan and subscription entitlements
paths:
  /events:
    post:
      tags:
        - Events
      summary: Create a new usage event
      operationId: CreateEvent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventRequest'
      responses:
        '201':
          description: Event created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventResponse'
              example:
                transaction_id: event_1753818829
                metric_code: 91624203-791a-4639-8c86-4693948b3a41
                external_subscription_id: d2d628e8-e7fb-412f-b09c-7f70ee58b50a
                timestamp: '2025-07-29T12:53:49.076-07:00'
                properties:
                  gb: 10
                id: d80447f2-0f34-4612-86ae-152160dc66c5
                created_at: '2025-07-29T12:53:49-07:00'
        '400':
          $ref: '#/components/responses/BadRequest'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    EventRequest:
      allOf:
        - $ref: '#/components/schemas/EventBase'
    EventResponse:
      allOf:
        - $ref: '#/components/schemas/EventBase'
        - type: object
          properties:
            id:
              type: string
              description: Unique identifier for the event
              example: evt_1234567890abcdef
            created_at:
              allOf:
                - $ref: '#/components/schemas/DateTimeWithZone'
              description: Timestamp when the event was created
              example: '2023-01-01T00:00:00Z'
    EventBase:
      type: object
      properties:
        transaction_id:
          type: string
          description: Unique identifier for the transaction associated with the event
          example: txn_1234567890abcdef
        external_subscription_id:
          type: string
          description: External subscription ID associated with the event
          example: sub_1234567890abcdef
        metric_code:
          type: string
          description: >-
            Identifier for the targeted metric. This value must match the `code`
            property of an active metric; otherwise, it will be disregarded
            during processing.
          example: event_code_123456
        timestamp:
          allOf:
            - $ref: '#/components/schemas/DateTimeWithZone'
          description: Timestamp when the event occurred
          example: '2023-01-01T00:00:00Z'
        properties:
          type: object
      required:
        - transaction_id
        - metric_code
        - external_subscription_id
    DateTimeWithZone:
      type: string
      format: date-time
      description: Date and time in ISO 8601 format.
      example: '2023-10-01T12:00:00Z'
    Error:
      type: object
      properties:
        name:
          type: string
        debug_id:
          type: string
        message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/ErrorDetail'
    ErrorDetail:
      type: object
      properties:
        field:
          type: string
        value:
          type: string
        location:
          type: string
        issue:
          type: string
        description:
          type: string
  responses:
    BadRequest:
      description: Bad Request - Invalid input data
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            name: INVALID_REQUEST
            message: >-
              Request is not well-formed, syntactically incorrect, or violates
              schema.
            debug_id: dc99e3955cdd8
            details:
              - field: /email
                value: abc
                location: body
                issue: INVALID_PARAMETER_VALUE
                description: The value of a field does not conform to the expected format.
    Forbidden:
      description: Authorization failed due to insufficient permissions.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            name: NOT_AUTHORIZED
            message: Authorization failed due to insufficient permissions.
            debug_id: 565f78f101498
            details:
              - issue: PERMISSION_DENIED
                description: >-
                  You do not have permission to access or perform operations on
                  this resource.
    UnprocessableEntity:
      description: Bad Request - Invalid input data
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            name: UNPROCESSABLE_ENTITY
            message: >-
              The requested action could not be performed, semantically
              incorrect, or failed business validation.
            debug_id: 90957fca61718
            details:
              - field: /email
                value: sdfwdj@sdfs.com
                location: body
                issue: UNSUPPORTED_EMAIL
                description: The email provided is not supported.
    InternalServerError:
      description: Internal Server Error - An unexpected error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            name: INTERNAL_SERVER_ERROR
            message: An internal server error has occurred.
            debug_id: 90957fca61718
  securitySchemes:
    BearerAuth:
      type: oauth2
      description: >-
        Use the /v1/oauth2/token endpoint to obtain an access token and pass it
        as a Bearer token in the Authorization header.
      flows:
        clientCredentials:
          tokenUrl: https://api-m.sandbox.paypal.com/v1/oauth2/token
          scopes:
            read: Read access
            write: Write access

````