{
  "openapi": "3.1.0",
  "info": {
    "title": "Clippah clip API (limited beta)",
    "version": "0.2.0",
    "description": "Limited upload-first beta API. Requires an operator-issued account key and rights-cleared source MP4 with a timed VTT transcript. No payments, OAuth consent or YouTube download are supported. This endpoint is a hosted limited beta, not a production service or a claim of Muse approval."
  },
  "servers": [
    {
      "url": "https://api.clippahmedia.com"
    }
  ],
  "security": [
    {
      "BearerToken": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Per-account development token, not OAuth or Muse consent."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "CreateJob": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "file_base64",
          "captions_vtt",
          "rights_confirmed"
        ],
        "properties": {
          "file_base64": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "Original MP4 supplied by the user, max 25MB decoded; beta JSON/base64 upload transport."
          },
          "captions_vtt": {
            "type": "string",
            "description": "Timed WebVTT transcript for scored clip selection"
          },
          "rights_confirmed": {
            "type": "boolean",
            "const": true
          },
          "count": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4,
            "default": 1
          },
          "format": {
            "type": "string",
            "enum": [
              "short",
              "two_minute"
            ],
            "default": "short"
          },
          "caption_style": {
            "type": "string",
            "enum": [
              "minimal",
              "bold"
            ],
            "default": "minimal"
          }
        }
      },
      "Clip": {
        "type": "object",
        "properties": {
          "index": {
            "type": "integer"
          },
          "score": {
            "type": "integer"
          },
          "start_seconds": {
            "type": "number"
          },
          "duration_seconds": {
            "type": "number"
          },
          "width": {
            "type": "integer"
          },
          "height": {
            "type": "integer"
          },
          "size_bytes": {
            "type": "integer"
          },
          "download_url": {
            "type": "string",
            "description": "Relative signed path, valid for five minutes; account Bearer token is also required."
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "processing",
              "completed",
              "failed"
            ]
          },
          "clips": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Clip"
            }
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "type": "number",
            "description": "Unix seconds"
          }
        }
      }
    }
  },
  "paths": {
    "/health": {
      "get": {
        "operationId": "health",
        "security": [],
        "responses": {
          "200": {
            "description": "Process alive in limited beta; not a worker readiness or capacity signal"
          }
        }
      }
    },
    "/v1/jobs": {
      "post": {
        "operationId": "createClips",
        "summary": "Submit your own MP4 with a timed transcript for clip generation",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateJob"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted, poll status_url",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status",
                    "status_url"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "const": "queued"
                    },
                    "status_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Account job quota reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/jobs/{job_id}": {
      "get": {
        "operationId": "getClipJob",
        "parameters": [
          {
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Job status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "401": {
            "description": "Invalid token"
          },
          "404": {
            "description": "No job visible to this account"
          }
        }
      }
    },
    "/v1/jobs/{job_id}/clips/{index}": {
      "get": {
        "operationId": "downloadClip",
        "parameters": [
          {
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "index",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "exp",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "sig",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Private MP4",
            "content": {
              "video/mp4": {}
            }
          },
          "401": {
            "description": "Invalid token"
          },
          "403": {
            "description": "Invalid or expired signature"
          },
          "404": {
            "description": "No clip visible to this account"
          }
        }
      }
    }
  }
}
