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

# Track Events

> Track impressions, views, clicks, and conversions for experiments.
Accepts a single event object or an array of up to 100 events.

**Authentication**: Use the `X-Write-Key` header or `writeKey` field in the request body.
Events are accepted without a write key, but this is strongly discouraged as it
allows anyone to inject events and corrupt experiment data.

**Rate limit**: 1000 requests/minute per IP. Max batch size: 100 events.




## OpenAPI

````yaml post /s/events
openapi: 3.1.0
info:
  title: Pictify API
  version: 1.0.0
  description: |
    Generate images, GIFs, and PDFs from HTML templates programmatically.

    ## Authentication
    All API requests require a Bearer token in the Authorization header:
    ```
    Authorization: Bearer pk_live_your_api_key
    ```

    ## Rate Limits
    - Free: 60 requests/minute
    - Pro: 300 requests/minute
    - Business: 1,000 requests/minute

    Rate limit headers are included in all responses.
  contact:
    email: support@pictify.io
    url: https://pictify.io
  license:
    name: MIT
servers:
  - url: https://api.pictify.io
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Images
    description: Image generation endpoints
  - name: GIFs
    description: GIF generation and capture
  - name: PDFs
    description: PDF generation
  - name: Templates
    description: Template management
  - name: Batch
    description: Batch rendering operations
  - name: Experiments
    description: A/B testing, smart links, and scheduled variant experiments
  - name: Webhooks
    description: Webhook subscription management
  - name: Bindings
    description: Data binding for auto-rendering
paths:
  /s/events:
    post:
      tags:
        - Experiments
      summary: Track experiment events
      description: >
        Track impressions, views, clicks, and conversions for experiments.

        Accepts a single event object or an array of up to 100 events.


        **Authentication**: Use the `X-Write-Key` header or `writeKey` field in
        the request body.

        Events are accepted without a write key, but this is strongly
        discouraged as it

        allows anyone to inject events and corrupt experiment data.


        **Rate limit**: 1000 requests/minute per IP. Max batch size: 100 events.
      operationId: trackExperimentEvents
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/ExperimentEvent'
                - type: array
                  items:
                    $ref: '#/components/schemas/ExperimentEvent'
                  maxItems: 100
          text/plain:
            schema:
              type: string
              description: JSON string (for sendBeacon compatibility)
      responses:
        '200':
          description: Events processed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExperimentEventResponse'
        '400':
          description: Invalid event data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - writeKeyAuth: []
        - {}
components:
  schemas:
    ExperimentEvent:
      type: object
      required:
        - event
        - experiment
      properties:
        event:
          type: string
          enum:
            - impression
            - view
            - click
            - conversion
          description: Event type
        experiment:
          type: string
          maxLength: 60
          description: Experiment slug
          example: homepage-hero-test
        variantId:
          type: string
          description: Variant that triggered the event
          example: variant-a
        channel:
          type: string
          enum:
            - web
            - email
            - ad
            - in-app
            - social
            - other
          description: Traffic channel
        device:
          type: string
          enum:
            - mobile
            - desktop
            - tablet
        referrer:
          type: string
        metadata:
          type: object
          description: Custom metadata (max 10KB, max depth 3)
        source:
          type: string
          enum:
            - sdk
            - api
          default: api
        writeKey:
          type: string
          description: Alternative to X-Write-Key header
    ExperimentEventResponse:
      type: object
      properties:
        ok:
          type: boolean
          example: true
        processed:
          type: integer
          example: 1
        errors:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              error:
                type: string
        warning:
          type: string
          description: Returns 'write_key_recommended' if no write key was provided
    Error:
      type: object
      required:
        - type
        - title
        - status
      properties:
        type:
          type: string
          format: uri
          description: Link to error documentation
          example: https://docs.pictify.io/errors/invalid-api-key
        title:
          type: string
          description: Short error title
          example: Invalid API Key
        status:
          type: integer
          description: HTTP status code
          example: 401
        detail:
          type: string
          description: Detailed error message
          example: The provided API key is invalid or has been revoked.
        instance:
          type: string
          description: Request path that caused the error
          example: /image
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key obtained from the Pictify dashboard
    writeKeyAuth:
      type: apiKey
      in: header
      name: X-Write-Key
      description: >-
        Write key for client-side experiment event tracking. Safe to expose in
        browser code.

````