{
  "openapi": "3.1.0",
  "info": {
    "title": "Corolet API",
    "version": "1.0.0",
    "summary": "Let AI agents and scripts run a YouTube channel through Corolet Studio.",
    "description": "Read and configure the connected YouTube channel, follow every video from production to publication, and check credits. Corolet Studio finds topics the audience is searching for, writes and narrates the script, edits the video, designs the thumbnail and publishes at the audience's peak time. Connecting the YouTube channel itself is a one-time human step (Google consent) at connectUrl. Docs: https://corolet.com/docs",
    "contact": {
      "url": "https://corolet.com/docs"
    }
  },
  "servers": [
    {
      "url": "https://corolet.com/api"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "A key starting with cor_live_, created at https://corolet.com/app/api"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "connectUrl": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "Channel": {
        "type": "object",
        "properties": {
          "connected": {
            "type": "boolean"
          },
          "connectUrl": {
            "type": "string",
            "description": "Present when not connected: where a person connects the YouTube channel."
          },
          "youtubeChannelId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "handle": {
            "type": [
              "string",
              "null"
            ]
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the channel is about."
          },
          "autopilot": {
            "type": "boolean",
            "description": "true publishes on its own; false waits for approval in YouTube Studio."
          },
          "language": {
            "type": "string",
            "description": "Two-letter language code of scripts and narration."
          },
          "videosPerWeek": {
            "type": "integer"
          },
          "lengthMinutes": {
            "type": "integer"
          },
          "color": {
            "type": "string",
            "description": "Thumbnail colour, #RRGGBB."
          },
          "connectedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "missing": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "connected"
        ]
      },
      "ChannelUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "subject": {
            "type": "string",
            "maxLength": 600
          },
          "autopilot": {
            "type": "boolean"
          },
          "language": {
            "type": "string",
            "pattern": "^[a-z]{2}$"
          },
          "videosPerWeek": {
            "type": "integer",
            "minimum": 1
          },
          "lengthMinutes": {
            "type": "integer",
            "minimum": 3,
            "maximum": 30,
            "description": "Target length in minutes, capped by the plan: Free 5, Starter 10, Pro 15, Advanced 20, Enterprise 30."
          },
          "color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$"
          }
        }
      },
      "Video": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "in_production",
              "scheduled",
              "awaiting_approval",
              "published"
            ]
          },
          "title": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "publishAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "youtubeVideoId": {
            "type": [
              "string",
              "null"
            ]
          },
          "youtubeUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "studioUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "YouTube Studio edit page; publish from here when awaiting_approval."
          }
        },
        "required": [
          "id",
          "status",
          "createdAt"
        ]
      }
    },
    "responses": {
      "Unauthenticated": {
        "description": "Missing, wrong or revoked key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  },
  "paths": {
    "/v1/me": {
      "get": {
        "operationId": "getMe",
        "summary": "Workspace and credit balance",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workspace": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "plan": {
                          "type": "string"
                        }
                      }
                    },
                    "credits": {
                      "type": [
                        "number",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          }
        }
      }
    },
    "/v1/studio/channel": {
      "get": {
        "operationId": "getChannel",
        "summary": "The connected YouTube channel and its settings",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "channel": {
                      "$ref": "#/components/schemas/Channel"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          }
        }
      },
      "patch": {
        "operationId": "updateChannel",
        "summary": "Change what the Studio makes (subject, language, videos per week, length, colour, autopilot)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChannelUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "channel": {
                      "$ref": "#/components/schemas/Channel"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "NOTHING_TO_UPDATE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "409": {
            "description": "CHANNEL_NOT_CONNECTED (connectUrl included)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/studio/videos": {
      "get": {
        "operationId": "listVideos",
        "summary": "Videos, newest first",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "in_production",
                "scheduled",
                "awaiting_approval",
                "published"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "videos": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Video"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          }
        }
      }
    },
    "/v1/studio/videos/{id}": {
      "get": {
        "operationId": "getVideo",
        "summary": "One video",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "video": {
                      "$ref": "#/components/schemas/Video"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}