> ## 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.

# Create Experiment

> Create a new experiment. Requires at least 2 variants with weights summing to exactly 10000.

Slug must be unique among active experiments, 3-60 characters, lowercase alphanumeric and hyphens.
Reserved slugs: events, api, admin, health, status, pixel, track, sdk.




## OpenAPI

````yaml post /experiments/api
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:
  /experiments/api:
    post:
      tags:
        - Experiments
      summary: Create experiment
      description: >
        Create a new experiment. Requires at least 2 variants with weights
        summing to exactly 10000.


        Slug must be unique among active experiments, 3-60 characters, lowercase
        alphanumeric and hyphens.

        Reserved slugs: events, api, admin, health, status, pixel, track, sdk.
      operationId: createExperiment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - type
                - slug
                - variants
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Experiment name
                  example: Homepage Hero A/B Test
                type:
                  type: string
                  enum:
                    - ab_test
                    - smart_link
                    - scheduled
                  description: Experiment type
                slug:
                  type: string
                  pattern: ^[a-z0-9][a-z0-9-]{1,58}[a-z0-9]$
                  description: URL-friendly identifier (3-60 chars)
                  example: homepage-hero-test
                templateUid:
                  type: string
                  description: Default template UID (optional if each variant has its own)
                  example: tmpl_xyz789
                variants:
                  type: array
                  minItems: 2
                  items:
                    $ref: '#/components/schemas/ExperimentVariant'
                  description: Variants with weights summing to 10000
                goalConfig:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - impressions_only
                        - click_through
                      default: impressions_only
                    destinationUrl:
                      type: string
                      format: uri
                banditConfig:
                  type: object
                  properties:
                    enabled:
                      type: boolean
                      default: false
                    algorithm:
                      type: string
                      enum:
                        - thompson_sampling
                        - epsilon_greedy
                      default: thompson_sampling
                    warmupImpressions:
                      type: integer
                      default: 50
                    recomputeIntervalMinutes:
                      type: integer
                      default: 15
                hypothesis:
                  type: string
                  maxLength: 500
                minimumSampleSize:
                  type: integer
                  default: 1000
                confidenceThreshold:
                  type: number
                  default: 0.95
                minimumRunDays:
                  type: integer
                  default: 7
                outputConfig:
                  type: object
                  properties:
                    format:
                      type: string
                      enum:
                        - png
                        - jpeg
                        - webp
                      default: png
                    quality:
                      type: number
                      default: 90
                fallbackImageUrl:
                  type: string
                  format: uri
                fallbackTemplateUid:
                  type: string
      responses:
        '201':
          description: Experiment created
          content:
            application/json:
              schema:
                type: object
                properties:
                  experiment:
                    $ref: '#/components/schemas/Experiment'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Slug already in use
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Experiment quota exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ExperimentVariant:
      type: object
      required:
        - id
        - weight
      properties:
        id:
          type: string
          description: Unique variant identifier
          pattern: ^[a-zA-Z0-9_-]+$
          example: variant-a
        name:
          type: string
          example: New Design
        templateUid:
          type: string
          description: Override template for this variant
        variables:
          type: object
          additionalProperties: true
          description: Template variables for this variant
        weight:
          type: integer
          minimum: 0
          maximum: 10000
          description: >-
            Traffic weight in basis points. All variant weights must sum to
            exactly 10000.
          example: 5000
        isDefault:
          type: boolean
          default: false
        conditions:
          $ref: '#/components/schemas/ConditionTree'
        schedule:
          $ref: '#/components/schemas/VariantSchedule'
        impressions:
          type: integer
          readOnly: true
          description: Total impressions for this variant
        clicks:
          type: integer
          readOnly: true
          description: Total clicks for this variant
    Experiment:
      type: object
      required:
        - uid
        - slug
        - type
        - name
        - status
        - variants
        - createdAt
        - updatedAt
      properties:
        uid:
          type: string
          example: exp_abc123
        slug:
          type: string
          description: >-
            URL-friendly identifier (3-60 chars, lowercase alphanumeric +
            hyphens)
          example: homepage-hero-test
        type:
          type: string
          enum:
            - ab_test
            - smart_link
            - scheduled
          description: Experiment type
        name:
          type: string
          description: Experiment name
          example: Homepage Hero A/B Test
        status:
          type: string
          enum:
            - draft
            - running
            - paused
            - completed
            - archived
          description: Current experiment status
        templateUid:
          type: string
          description: Default template UID for variants
          example: tmpl_xyz789
        variants:
          type: array
          items:
            $ref: '#/components/schemas/ExperimentVariant'
        goalConfig:
          $ref: '#/components/schemas/GoalConfig'
        banditConfig:
          $ref: '#/components/schemas/BanditConfig'
        hypothesis:
          type: string
          maxLength: 500
          description: Test hypothesis
        minimumSampleSize:
          type: integer
          default: 1000
        confidenceThreshold:
          type: number
          default: 0.95
        minimumRunDays:
          type: integer
          default: 7
        winnerVariantId:
          type: string
          nullable: true
          description: Winning variant ID (set when experiment is completed)
        winnerDeclaredAt:
          type: string
          format: date-time
          nullable: true
        fallbackImageUrl:
          type: string
          format: uri
          description: Image URL to serve after experiment ends
        outputConfig:
          type: object
          properties:
            format:
              type: string
              enum:
                - png
                - jpeg
                - webp
              default: png
            quality:
              type: number
              default: 90
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    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
    ConditionTree:
      type: object
      description: Nested AND/OR condition tree for smart link routing (max depth 3)
      properties:
        type:
          type: string
          enum:
            - group
            - rule
        operator:
          type: string
          enum:
            - AND
            - OR
          description: Logic operator for group nodes
        children:
          type: array
          items:
            $ref: '#/components/schemas/ConditionTree'
        property:
          type: string
          description: Context property to evaluate (for rule nodes)
        ruleOperator:
          type: string
          enum:
            - equals
            - not_equals
            - contains
            - not_contains
            - starts_with
            - ends_with
            - gt
            - lt
            - gte
            - lte
          description: Comparison operator for rule nodes
        value:
          description: Value to compare against
    VariantSchedule:
      type: object
      description: Time-based activation schedule for scheduled variants
      properties:
        startAt:
          type: string
          format: date-time
        endAt:
          type: string
          format: date-time
        recurrence:
          type: object
          properties:
            type:
              type: string
              enum:
                - none
                - daily
                - weekly
                - cron
              default: none
            cronExpression:
              type: string
              description: Cron expression (when type is cron)
            timezone:
              type: string
              default: UTC
              example: America/New_York
    GoalConfig:
      type: object
      properties:
        type:
          type: string
          enum:
            - impressions_only
            - click_through
          default: impressions_only
        destinationUrl:
          type: string
          format: uri
          description: Redirect URL for click-through goals
    BanditConfig:
      type: object
      description: Auto-optimization settings (A/B tests only)
      properties:
        enabled:
          type: boolean
          default: false
        algorithm:
          type: string
          enum:
            - thompson_sampling
          default: thompson_sampling
        warmupImpressions:
          type: integer
          default: 50
          description: Minimum impressions before optimization begins
        recomputeIntervalMinutes:
          type: integer
          default: 15
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key obtained from the Pictify dashboard

````