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

# Track event

> Track an event for a contact. Automatically creates/updates the contact.



## OpenAPI

````yaml openapi.json POST /v1/track
openapi: 3.0.3
info:
  title: MailGlyph API
  description: >-
    Email platform API for transactional emails, campaigns, and marketing
    automation
  version: 1.0.0
  contact:
    name: MailGlyph Support
    url: https://mailglyph.com
servers:
  - url: https://api.mailglyph.com
    description: Production server
security:
  - ApiKeyAuth: []
tags:
  - name: Public API
    description: Public API endpoints for sending emails and tracking events
  - name: Events
    description: Event ingestion and querying
  - name: Contacts
    description: Contact management operations
  - name: Templates
    description: Email template management
  - name: Campaigns
    description: Email campaign management
  - name: Segments
    description: Audience segmentation
  - name: Workflows
    description: Workflow automation
paths:
  /v1/track:
    post:
      tags:
        - Public API
      summary: Track event
      description: Track an event for a contact. Automatically creates/updates the contact.
      operationId: trackEvent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - email
                - event
              properties:
                email:
                  type: string
                  format: email
                  description: Contact email
                event:
                  type: string
                  description: Event name
                subscribed:
                  type: boolean
                  description: >-
                    Whether contact is subscribed to marketing emails. Defaults
                    to true for event tracking.
                  default: true
                data:
                  description: >-
                    Optional event data and contact metadata. Choose `Empty
                    object` if you do not want to send any example preset keys.
                  oneOf:
                    - type: object
                      title: Example object
                      description: >-
                        Optional common event keys. You can still add additional
                        custom key/value pairs.
                      properties:
                        product:
                          type: string
                          example: Premium Plan
                        amount:
                          type: number
                          example: 99
                      example:
                        product: Premium Plan
                        amount: 99
                      additionalProperties: true
                    - type: object
                      title: Empty object
                      description: >-
                        No preset keys. Add any custom key/value pairs as
                        needed.
                      additionalProperties: true
            examples:
              Event with metadata:
                summary: Event with metadata
                value:
                  email: user@example.com
                  event: purchase
                  data:
                    product: Premium Plan
                    amount: 99
              Simple event:
                summary: Simple event
                value:
                  email: user@example.com
                  event: purchase
      responses:
        '200':
          description: Event tracked successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      contact:
                        type: string
                        description: Contact ID
                      event:
                        type: string
                        description: Event ID
                      timestamp:
                        type: string
                        format: date-time
components:
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        API Key authentication. **Secret keys (sk_*)** are required for all
        endpoints except `/v1/track`. **Public keys (pk_*)** only work with the
        `/v1/track` endpoint for client-side event tracking. Workspaces can have
        multiple active keys, and sender-domain operations enforce per-key
        domain scope when configured.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.