openapi: 3.1.0
info:
  title: HTMLDrop API
  version: 1.0.0
  description: REST API for publishing and managing HTMLDrop pages.
servers:
  - url: https://htmldrop.in/api/v1
security:
  - bearerAuth: []
paths:
  /pages:
    get:
      summary: List pages
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
            default: 20
        - name: cursor
          in: query
          schema:
            type: string
      responses:
        "200":
          description: Page list
    post:
      summary: Publish a page
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PublishBody"
      responses:
        "200":
          description: Published page
  /pages/{slug}:
    get:
      summary: Get page metadata
      parameters:
        - $ref: "#/components/parameters/slug"
      responses:
        "200":
          description: Page metadata
    patch:
      summary: Update page content
      parameters:
        - $ref: "#/components/parameters/slug"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PublishBody"
      responses:
        "200":
          description: Updated page
    delete:
      summary: Delete a page
      parameters:
        - $ref: "#/components/parameters/slug"
      responses:
        "200":
          description: Deleted
  /pages/{slug}/settings:
    get:
      summary: Get page settings
      parameters:
        - $ref: "#/components/parameters/slug"
      responses:
        "200":
          description: Settings
    patch:
      summary: Update page settings
      parameters:
        - $ref: "#/components/parameters/slug"
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                password:
                  type: string
                clearPassword:
                  type: boolean
                expiresAt:
                  type: string
                  nullable: true
      responses:
        "200":
          description: Updated settings
  /pages/{slug}/analytics:
    get:
      summary: Get page analytics
      parameters:
        - $ref: "#/components/parameters/slug"
      responses:
        "200":
          description: Analytics payload
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key prefixed with hd_live_
  parameters:
    slug:
      name: slug
      in: path
      required: true
      schema:
        type: string
  schemas:
    PublishBody:
      type: object
      properties:
        html:
          type: string
        content:
          type: string
        format:
          type: string
          enum: [html, md]
        template:
          type: string
        title:
          type: string
        customSlug:
          type: string
        expiresAt:
          type: string
          nullable: true
