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

# Track Events (Batch)

> Record up to 500 events in one request with row-level partial success: one malformed row never fails the batch. Idempotency is per row via dedupeKey; a request-level Idempotency-Key header is rejected. Aggregate properties payloads are limited to 1MB.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/events/batch
openapi: 3.1.0
info:
  title: Migma.ai API (v1)
  description: >-
    API for managing brands, contacts, email generation, sending, and
    integrations.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.migma.ai
    description: Production
security:
  - apiKeyAuth: []
tags:
  - name: Projects/Brands
    description: Manage projects (brands) and import from websites
  - name: Contacts
    description: Manage your contacts, segments, tags, and topics
  - name: Segments
    description: Create and manage dynamic contact segments
  - name: Tags
    description: Organize contacts with tags
  - name: Topics
    description: Manage subscription topics and preferences
  - name: Emails
    description: Generate, send, and export emails
  - name: Email Validation
    description: Validate email content for compatibility and deliverability
  - name: Email Previews
    description: Preview emails across devices and email clients
  - name: Domains
    description: Manage sending domains and verification
  - name: Webhooks
    description: Manage webhook endpoints for real-time event notifications
  - name: Events
    description: Record customer events and conversions
  - name: Integrations
    description: Third-party platform integrations
  - name: Campaigns
    description: Create, schedule, send, and manage email campaigns
  - name: Project Editing
    description: Edit project assets, logos, images, and knowledge base entries
paths:
  /v1/events/batch:
    post:
      tags:
        - Events
      summary: Track Events (Batch)
      description: >-
        Record up to 500 events in one request with row-level partial success:
        one malformed row never fails the batch. Idempotency is per row via
        dedupeKey; a request-level Idempotency-Key header is rejected. Aggregate
        properties payloads are limited to 1MB.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - projectId
                - events
              properties:
                projectId:
                  type: string
                events:
                  type: array
                  minItems: 1
                  maxItems: 500
                  items:
                    $ref: '#/components/schemas/IngestEventRow'
      responses:
        '201':
          description: Batch processed with per-row results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponseTrackEventBatchResult'
        '400':
          description: >-
            Envelope invalid, aggregate payload too large, or request-level
            Idempotency-Key supplied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
        '403':
          description: Missing audience:write permission or no access to the project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
components:
  schemas:
    IngestEventRow:
      type: object
      required:
        - name
        - identifiers
      properties:
        name:
          type: string
          maxLength: 120
          description: >-
            Event name, e.g. purchase.completed. Names containing refund or
            cancelled record negative conversion amounts.
        origin:
          type: string
          maxLength: 80
          default: api
        eventVersion:
          type: string
          maxLength: 40
        identifiers:
          $ref: '#/components/schemas/EventIdentifiers'
        profile:
          $ref: '#/components/schemas/EventProfile'
        properties:
          type: object
          additionalProperties: true
          description: >-
            Event facts. Up to 16KB, 50 top-level keys, 4 levels deep. A numeric
            value (major units, e.g. 49.99) together with
            identifiers.externalOrderId records a conversion; currency is an ISO
            code, default USD.
        occurredAt:
          type: string
          format: date-time
          description: When the event happened. Defaults to receipt time.
        dedupeKey:
          type: string
          maxLength: 200
          description: >-
            Event-identity dedupe key. Replaying the same key stores nothing and
            returns the original eventId.
    ApiResponseTrackEventBatchResult:
      allOf:
        - $ref: '#/components/schemas/ApiResponse'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/TrackEventBatchResult'
    ApiResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          nullable: true
        error:
          type: string
          nullable: true
      required:
        - success
    EventIdentifiers:
      type: object
      description: >-
        Contact identity for the event. At least one of email or subscriberId is
        required. Provider ids (externalCustomerId, externalCheckoutId,
        externalOrderId) support integrations and conversion attribution.
      properties:
        email:
          type: string
          format: email
        subscriberId:
          type: string
        externalCustomerId:
          type: string
          maxLength: 200
        externalCheckoutId:
          type: string
          maxLength: 200
        externalOrderId:
          type: string
          maxLength: 200
          description: >-
            The provider's order or charge id. Required for the event to record
            a conversion.
    EventProfile:
      type: object
      description: >-
        Contact metadata to update. Profile updates never change subscription
        status, tags, or consent. Events never opt a contact in.
      properties:
        firstName:
          type: string
          maxLength: 120
        lastName:
          type: string
          maxLength: 120
        phone:
          type: string
          maxLength: 80
        country:
          type: string
          maxLength: 80
        language:
          type: string
          maxLength: 40
        customFields:
          type: object
          additionalProperties: true
    TrackEventBatchResult:
      type: object
      properties:
        accepted:
          type: integer
        duplicates:
          type: integer
        results:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              stored:
                type: boolean
              eventId:
                type: string
              dedupeKey:
                type: string
        invalid:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              error:
                type: string
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key authentication. Use 'Authorization: Bearer YOUR_API_KEY' where
        YOUR_API_KEY is obtained from the Migma dashboard under Settings →
        Developers → API Keys.

````