> ## 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 multiple usage events in batch.



## OpenAPI

````yaml /api-reference/ubb_openapi_inline.json post /events/batch
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/batch:
    post:
      tags:
        - Events
      summary: Create multiple usage events in batch.
      operationId: CreateEventsBatch
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                events:
                  type: array
                  items:
                    $ref: '#/components/schemas/EventRequest'
            example:
              events:
                - transaction_id: event_t1_1753838783
                  external_subscription_id: 91624203-791a-4639-8c86-4693948b3a41
                  metric_code: Billable_Metrics_1753827008
                  timestamp: '2023-01-01T00:00:00Z'
                  properties:
                    gb: 10
                - transaction_id: event_t2_1753838783
                  external_subscription_id: 91624203-791a-4639-8c86-4693948b3a41
                  metric_code: Billable_Metrics_1753827008
                  timestamp: '2023-01-01T00:00:00Z'
                  properties:
                    gb: 10
      responses:
        '201':
          description: Events accepted for processing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventsAcceptedWithResults'
              example:
                status: ACCEPTED
                results:
                  success_count: 2
                  error_count: 0
        '400':
          $ref: '#/components/responses/BadRequest'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    EventRequest:
      allOf:
        - $ref: '#/components/schemas/EventBase'
    EventsAcceptedWithResults:
      allOf:
        - $ref: '#/components/schemas/EventAccepted'
        - type: object
          properties:
            results:
              type: object
              description: Results of the accepted events
              properties:
                success_count:
                  type: integer
                  description: Number of events successfully processed
                  example: 100
                error_count:
                  type: integer
                  description: Number of events that failed processing
                  example: 5
                errors:
                  type: array
                  description: Details about failed events
                  items:
                    type: object
                    properties:
                      transaction_id:
                        type: string
                        description: Transaction ID of the failed event
                      error_code:
                        type: string
                        description: Error code
                      error_message:
                        type: string
                        description: Detailed error message
                  example:
                    - transaction_id: txn_1234567890abcdef
                      error_code: invalid_data
                      error_message: The event data is invalid
    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
    EventAccepted:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/EventStatus'
    Error:
      type: object
      properties:
        name:
          type: string
        debug_id:
          type: string
        message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/ErrorDetail'
    DateTimeWithZone:
      type: string
      format: date-time
      description: Date and time in ISO 8601 format.
      example: '2023-10-01T12:00:00Z'
    EventStatus:
      type: string
      enum:
        - ACCEPTED
      description: Status indicating that the event has been accepted for processing
      example: ACCEPTED
    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.
    Conflict:
      description: >-
        Conflict - The request could not be completed due to a conflict with the
        current state of the resource.
      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: transaction_id
                issue: RESOURCE_ALREADY_EXISTS
                description: The resource identified by `field` already exists.
    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

````