On-Demand Content Generation API
OpenAPI 3.0 specification for our internal content generation service.

openapi: 3.0.3
info:
  title: On-Demand Content Generation API
  description: API for generating personalized videos and landing pages using pre-configured templates and prospect data
  version: 1.0.0
servers:
  - url: https://api.yourdomain.com

paths:
  /templates:
    get:
      summary: Get all available content templates
      tags: [Templates]
      responses:
        '200':
          description: List of templates
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Template'
    post:
      summary: Create a new template
      tags: [Templates]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewTemplate'
      responses:
        '201':
          description: Template created successfully

  /templates/validate-fields:
    post:
      summary: Validate required fields for a given template
      tags: [Templates]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FieldValidationRequest'
      responses:
        '200':
          description: Field validation result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldValidationResponse'

  /content/generate:
    post:
      summary: Generate personalized content based on a selected template
      tags: [Content]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContentGenerationRequest'
      responses:
        '200':
          description: Content generation result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContentGenerationResponse'

  /content/log-usage:
    post:
      summary: Log content usage events (sent, viewed, clicked)
      tags: [Content]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UsageLogRequest'
      responses:
        '200':
          description: Usage log recorded

components:
  schemas:
    Template:
      type: object
      properties:
        id: { type: string }
        name: { type: string }
        description: { type: string }
        template_type: { type: string, enum: [video, landing_page] }
        required_fields: { type: array, items: { type: string } }
        template_url: { type: string }

    NewTemplate:
      type: object
      required: [name, template_type, required_fields, template_url]
      properties:
        name: { type: string }
        description: { type: string }
        template_type: { type: string, enum: [video, landing_page] }
        required_fields: { type: array, items: { type: string } }
        template_url: { type: string }

    FieldValidationRequest:
      type: object
      required: [template_id, prospect_data]
      properties:
        template_id: { type: string }
        prospect_data: { type: object, additionalProperties: { type: string } }

    FieldValidationResponse:
      type: object
      properties:
        valid: { type: boolean }
        missing_fields: { type: array, items: { type: string } }

    ContentGenerationRequest:
      type: object
      required: [template_id, prospect_id, agent_id, prospect_data]
      properties:
        template_id: { type: string }
        prospect_id: { type: string }
        agent_id: { type: string }
        prospect_data: { type: object, additionalProperties: { type: string } }

    ContentGenerationResponse:
      type: object
      properties:
        status: { type: string, enum: [success, error] }
        content_url: { type: string }
        error: { type: string }

    UsageLogRequest:
      type: object
      required: [prospect_id, agent_id, template_id, content_url, event_type, timestamp]
      properties:
        prospect_id: { type: string }
        agent_id: { type: string }
        template_id: { type: string }
        content_url: { type: string }
        event_type: { type: string, enum: [sent, viewed, clicked] }
        timestamp: { type: string, format: date-time }