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

# Ingest product events

> Ingests a batch of product-usage events (Segment-style). Feeds health, signals, and activation recompute.

Accepts server keys (`gt_live_`, scope `write:events`) or client-safe browser keys (`gt_pub_`, scope `write:ingest`). Public ingest is CORS-enabled.

**Scope:** `write:events` or `write:ingest` · **Max 1000 events per request.**



## OpenAPI

````yaml /openapi.json post /events
openapi: 3.1.0
info:
  title: GainTrace API
  version: 1.0.0
  description: >-
    The GainTrace REST API (v1). Read your customer data and push product-usage
    events, metric events, and signals into GainTrace.


    All endpoints are authenticated with a Bearer API key and scoped to a single
    workspace.
servers:
  - url: https://app.gaintrace.com/api/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Companies
    description: Read and manage canonical company records.
  - name: Signals
    description: Read, create, and manage buyer / risk signals.
  - name: Ingest
    description: Push product-usage and metric events into GainTrace.
  - name: Contacts
    description: Read and manage the people on an account.
  - name: Webhooks
    description: Subscribe to workspace events with signed, retried delivery.
paths:
  /events:
    post:
      tags:
        - Ingest
      summary: Ingest product events
      description: >-
        Ingests a batch of product-usage events (Segment-style). Feeds health,
        signals, and activation recompute.


        Accepts server keys (`gt_live_`, scope `write:events`) or client-safe
        browser keys (`gt_pub_`, scope `write:ingest`). Public ingest is
        CORS-enabled.


        **Scope:** `write:events` or `write:ingest` · **Max 1000 events per
        request.**
      operationId: ingestProductEvents
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - events
              properties:
                events:
                  type: array
                  minItems: 1
                  maxItems: 1000
                  items:
                    $ref: '#/components/schemas/ProductEvent'
      responses:
        '201':
          description: Events accepted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      inserted:
                        type: integer
                      duplicates:
                        type: integer
                      linked:
                        type: integer
                      errors:
                        type: integer
                  validation_errors:
                    type: array
                    items:
                      $ref: '#/components/schemas/EventValidationError'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    ProductEvent:
      type: object
      required:
        - event_name
        - timestamp
      properties:
        event_name:
          type: string
          maxLength: 255
          description: The event identifier, e.g. `report_exported`.
        timestamp:
          type: string
          format: date-time
          description: ISO 8601 event time.
        account_id:
          type: string
          description: Company/account external id or UUID.
        user_id:
          type: string
          description: End-user id.
        anonymous_id:
          type: string
        session_id:
          type: string
        event_category:
          type: string
        feature_name:
          type: string
        source:
          type: string
        source_event_id:
          type: string
          description: Idempotency key for dedup.
        value:
          type: number
        unit:
          type: string
        is_programmatic:
          type: boolean
        properties:
          type: object
          description: Arbitrary JSON, max 10KB serialized.
          additionalProperties: true
    EventValidationError:
      type: object
      properties:
        index:
          type: integer
          description: Index of the offending event in the batch.
        error:
          type: string
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable, safe error message.
        detail:
          type: string
        code:
          type: string
      required:
        - error
  responses:
    BadRequest:
      description: Invalid request body or parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Insufficient scope, or API v1 is not enabled for the workspace.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Per-key rate limit exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer API key. Secret server keys start with `gt_live_`; client-safe
        browser keys start with `gt_pub_` (write-only, origin-pinned). Create
        and scope keys in Settings → API Keys.

````