{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/xavio-in/json-schema/xavio-in-create-story-request-schema.json",
  "title": "CreateStoryRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/xavio-in-stories-api-openapi.yml#/components/schemas/CreateStoryRequest",
  "type": "object",
  "properties": {
    "backgrounds": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Background"
      },
      "minItems": 1,
      "description": "One or more slides."
    },
    "caption": {
      "type": [
        "string",
        "null"
      ],
      "description": "Cluster-wide caption."
    },
    "audience": {
      "type": "string",
      "enum": [
        "public",
        "followers",
        "sponsored",
        "flash",
        "past_customers",
        "cart_abandoners",
        "lead_no_purchase",
        "custom_segment",
        "list"
      ],
      "description": "Audience kind — see /api/v1/public/audiences."
    },
    "audience_list_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Required when audience='list'."
    },
    "expires_at": {
      "type": "string",
      "format": "date-time",
      "description": "ISO timestamp the stories expire."
    },
    "category_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Category id — see /api/v1/public/categories."
    },
    "is_showcase": {
      "type": "boolean",
      "description": "Pin as a showcase entry (tier-gated)."
    },
    "overlays": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Overlay"
      },
      "description": "Optional inline components."
    }
  },
  "required": [
    "backgrounds",
    "audience"
  ],
  "$defs": {
    "Background": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "image",
            "video",
            "audio",
            "text"
          ],
          "description": "Slide media type."
        },
        "media_url": {
          "type": "string",
          "format": "uri",
          "description": "URL to the uploaded media (required for image/video/audio)."
        },
        "duration_ms": {
          "type": "integer",
          "minimum": 1000,
          "maximum": 60000,
          "description": "Slide duration in ms (default 5000)."
        },
        "caption": {
          "type": [
            "string",
            "null"
          ],
          "description": "Per-slide caption — overrides the cluster-wide caption."
        },
        "source_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Optional embed URL (e.g. YouTube) for URL-mode video stories."
        },
        "source_provider": {
          "type": [
            "string",
            "null"
          ],
          "description": "Provider key from @/lib/url-video (paired with source_url)."
        }
      },
      "required": [
        "type",
        "media_url"
      ]
    },
    "Overlay": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Component id (see /api/v1/public/components)."
        },
        "config": {
          "type": "object",
          "description": "Component-specific config blob; shape depends on `type`."
        },
        "position": {
          "type": "string",
          "enum": [
            "top",
            "center",
            "bottom",
            "custom"
          ],
          "description": "Default landing position."
        },
        "z_index": {
          "type": "integer",
          "description": "Stacking order within the slide."
        },
        "anchor_slide_idx": {
          "type": "integer",
          "description": "0-based slide index this overlay anchors to (defaults to 0 = cluster head)."
        }
      },
      "required": [
        "type",
        "config"
      ]
    }
  }
}