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

# Track Event

> Record a custom event for a contact. This endpoint does **not** create contacts, the contact must already exist.



## OpenAPI

````yaml /openapi.json post /v2/events
openapi: 3.1.0
info:
  title: Conversion API
  version: 2.0.0
  description: >-
    The Conversion API lets you programmatically manage contacts, track custom
    events, and manage their associated data.
servers:
  - url: https://pub-api.conversion.ai/api
security:
  - apiKey: []
paths:
  /v2/events:
    post:
      summary: Track Event
      description: >-
        Record a custom event for a contact. This endpoint does **not** create
        contacts, the contact must already exist.
      operationId: trackEvent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - event
              properties:
                userId:
                  type: string
                  description: >-
                    An external user identifier for the contact. At least one of
                    `userId` or `email` is required. If `userId` matches a
                    contact, that contact is used. If not, falls back to
                    `email`. If the email matches a contact that has a different
                    `userId`, a `conflicting_identifier` error is returned.
                  examples:
                    - user_12345
                email:
                  type: string
                  format: email
                  description: >-
                    The contact's email address. At least one of `userId` or
                    `email` is required.
                  examples:
                    - jane@example.com
                event:
                  type: string
                  description: >-
                    The name of the custom event to track (e.g.
                    `order_completed`, `log_in`). This is a freeform string.
                  examples:
                    - page_viewed
                eventId:
                  type: string
                  description: >-
                    An optional client-generated identifier for the event. Use
                    stable identifiers (like order IDs) to make retries
                    idempotent: if an event with this ID already exists, the
                    duplicate is ignored and the existing event is left
                    unchanged. If omitted, a new event is always created.
                  examples:
                    - evt_abc123
                data:
                  type: object
                  additionalProperties: {}
                  description: An optional map of custom data to attach to the event.
                  examples:
                    - product_id: '1234567890'
                      quantity: 2
                timestamp:
                  type: string
                  format: date-time
                  description: >-
                    An optional ISO 8601 timestamp for when the event occurred.
                    Defaults to the current time if omitted.
                  examples:
                    - '2026-03-31T14:30:00Z'
            examples:
              track-with-email:
                summary: Track event by email
                value:
                  email: jane@example.com
                  event: log_in
                  data:
                    device: mobile
                    location: US
              track-with-userId:
                summary: Track event by userId
                value:
                  userId: user_12345
                  event: plan_upgraded
                  data:
                    plan: pro
                    annual: true
              track-with-idempotency:
                summary: Track event with idempotency key
                value:
                  email: jane@example.com
                  event: order_completed
                  eventId: evt_abc123
                  data:
                    product_id: '1234567890'
                    quantity: 2
                  timestamp: '2026-03-31T14:30:00Z'
      responses:
        '200':
          description: Event tracked successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      cnvEventId:
                        type: string
                        format: uuid
                        description: The Conversion engagement ID for the recorded event.
                      cnvContactId:
                        type: string
                        format: uuid
                        description: >-
                          The Conversion contact ID of the contact the event was
                          recorded against.
              examples:
                tracked:
                  summary: Event tracked
                  value:
                    data:
                      cnvEventId: b2c3d4e5-f6a7-8901-bcde-f12345678901
                      cnvContactId: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        '400':
          description: The request was malformed or contained invalid data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing-identifier:
                  summary: Missing identifier
                  value:
                    error:
                      code: missing_identifier
                      message: either 'userId' or 'email' is required
                missing-event:
                  summary: Missing event name
                  value:
                    error:
                      code: missing_event
                      message: '''event name'' is required'
                invalid-email:
                  summary: Invalid email
                  value:
                    error:
                      code: invalid_email
                      message: 'invalid email format: not-an-email'
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                unauthorized:
                  summary: Missing or invalid API key
                  value:
                    error:
                      code: unauthorized
                      message: API key is required
        '404':
          description: The contact could not be found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                contact-not-found:
                  summary: Contact not found
                  value:
                    error:
                      code: contact_not_found
                      message: contact not found
                contact-id-not-found:
                  summary: Contact ID not found
                  value:
                    error:
                      code: contact_id_not_found
                      message: contact not found with the provided contactId
        '409':
          description: The provided identifiers conflict with an existing contact.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                conflicting-identifier:
                  summary: Conflicting identifier
                  value:
                    error:
                      code: conflicting_identifier
                      message: contact found by email but has a different userId
        '500':
          description: An unexpected server error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                internal:
                  summary: Internal error
                  value:
                    error:
                      code: internal_error
                      message: failed to track event
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: A machine-readable error code.
              examples:
                - invalid_email
            message:
              type: string
              description: A human-readable error description.
              examples:
                - 'invalid email format: not-an-email'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        Your Conversion API key. Found in **Settings > Integrations** in the
        dashboard. Format: `sk_live_<key_id>_<secret>`.

````