{
	"openapi": "3.0.0",
	"info": {
		"title": "Videnly API",
		"version": "1.0.0",
		"description": "API for managing video generation, queue, and user account details."
	},
	"paths": {
		"/v1/videos": {
			"get": {
				"summary": "Retrieve All Videos",
				"description": "Get all successful video generation logs with video URLs for the authenticated user",
				"tags": ["Videos"],
				"security": [{ "ApiKeyAuth": [] }],
				"responses": {
					"200": {
						"description": "Videos retrieved successfully",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"status": {
											"type": "string",
											"example": "success"
										},
										"message": {
											"type": "string",
											"example": "Videos retrieved successfully"
										},
										"videos": {
											"type": "array",
											"items": {
												"type": "object",
												"properties": {
													"id": {
														"type": "string",
														"description": "Unique ID for the log entry",
														"example": "xxxxxxxxxxxxxxxxxxxxxxxx"
													},
													"url": {
														"type": "string",
														"description": "URL of the generated video",
														"example": "https://cdn.videnly.com/videos/sample-video.mp4"
													},
													"projectId": {
														"type": "string",
														"description": "ID of the associated project",
														"example": "project123"
													},
													"createdAt": {
														"type": "string",
														"format": "date-time",
														"description": "Timestamp of the log creation",
														"example": "2024-11-07T14:23:45.213Z"
													}
												}
											}
										}
									}
								}
							}
						}
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"status": {
											"type": "string",
											"example": "error"
										},
										"message": {
											"type": "string",
											"example": "Failed to retrieve video logs"
										}
									}
								}
							}
						}
					}
				}
			}
		},
		"/v1/queue/add": {
			"post": {
				"summary": "Add video generation request to the queue",
				"description": "Adds a video generation request to the queue for later processing.",
				"operationId": "addQueue",
				"tags": ["Queue"],
				"security": [{ "ApiKeyAuth": [] }],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"type": "object",
								"properties": {
									"projectId": { "type": "string" },
									"overwriteSettings": { "type": "boolean" },
									"customPrompt": { "type": "string", "nullable": true }
								},
								"required": ["projectId"]
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Video generation request added successfully",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"status": { "type": "string" },
										"message": { "type": "string" },
										"newQueueItem": {
											"type": "object",
											"properties": {
												"queueId": { "type": "string" },
												"projectId": { "type": "string" },
												"status": { "type": "string" },
												"generationProgress": { "type": "integer" },
												"renderProgress": { "type": "integer" },
												"videoUrl": { "type": "string", "nullable": true },
												"createdAt": { "type": "string", "format": "date-time" }
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Invalid input or missing required fields"
					},
					"500": {
						"description": "Server error"
					}
				}
			}
		},
		"/v1/queue/progress/{queueId}": {
			"get": {
				"summary": "Get progress of a video generation request",
				"description": "Retrieves the current progress of a video generation request in the queue.",
				"operationId": "getQueueProgress",
				"tags": ["Queue"],
				"security": [{ "ApiKeyAuth": [] }],
				"parameters": [
					{
						"name": "queueId",
						"in": "path",
						"required": true,
						"schema": {
							"type": "string"
						},
						"description": "The unique ID of the queue item to retrieve progress for"
					}
				],
				"responses": {
					"200": {
						"description": "Queue item progress retrieved successfully",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"status": { "type": "string" },
										"message": { "type": "string" },
										"details": {
											"type": "object",
											"properties": {
												"status": { "type": "string" },
												"generationProgress": { "type": "integer" },
												"renderProgress": { "type": "integer" }
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Invalid queue ID format"
					},
					"404": {
						"description": "Queue item not found"
					},
					"500": {
						"description": "Server error"
					}
				}
			}
		},
		"/v1/queue/clear": {
			"post": {
				"summary": "Clear a specific queue item",
				"description": "Deletes a specific queue item belonging to the authenticated user.",
				"operationId": "clearQueueItem",
				"tags": ["Queue"],
				"security": [{ "ApiKeyAuth": [] }],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"type": "object",
								"properties": {
									"queueId": { "type": "string" }
								},
								"required": ["queueId"]
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Queue item cleared successfully",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"status": { "type": "string" },
										"message": { "type": "string" },
										"queueId": { "type": "string" }
									}
								}
							}
						}
					},
					"400": {
						"description": "Invalid queue ID format"
					},
					"404": {
						"description": "Queue item not found or not owned by the user"
					},
					"500": {
						"description": "Server error"
					}
				}
			}
		},
		"/v1/user/account": {
			"get": {
				"summary": "Retrieve account details",
				"description": "Retrieves the account details of the authenticated user.",
				"operationId": "getUserAccount",
				"tags": ["User"],
				"security": [{ "ApiKeyAuth": [] }],
				"responses": {
					"200": {
						"description": "Account details retrieved successfully",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"status": { "type": "string" },
										"name": { "type": "string" },
										"email": { "type": "string" },
										"statusCode": { "type": "integer" },
										"usage": {
											"type": "object",
											"properties": {
												"remainingCredits": { "type": "integer" }
											}
										},
										"requestCompletionTime": { "type": "string" },
										"timestamp": { "type": "string", "format": "date-time" }
									}
								}
							}
						}
					},
					"500": {
						"description": "Server error"
					}
				}
			}
		},
		"/v1/projects": {
			"get": {
				"summary": "Retrieve all projects",
				"description": "Fetches all projects associated with the authenticated user.",
				"operationId": "getAllProjects",
				"tags": ["Projects"],
				"security": [{ "ApiKeyAuth": [] }],
				"parameters": [
					{
						"name": "sort",
						"in": "query",
						"required": false,
						"schema": {
							"type": "string",
							"enum": ["updatedAt", "createdAt"],
							"default": "updatedAt"
						}
					},
					{
						"name": "order",
						"in": "query",
						"required": false,
						"schema": {
							"type": "string",
							"enum": ["asc", "desc"],
							"default": "desc"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Projects retrieved successfully",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"status": { "type": "string", "example": "success" },
										"message": { "type": "string", "example": "Project retrieved successfully" },
										"projects": {
											"type": "array",
											"items": {
												"type": "object",
												"properties": {
													"id": { "type": "string" },
													"name": { "type": "string" },
													"createdAt": { "type": "string", "format": "date-time" },
													"updatedAt": { "type": "string", "format": "date-time" }
												}
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Invalid sort or order parameters"
					},
					"500": {
						"description": "Server error"
					}
				}
			}
		}
	},
	"components": {
		"securitySchemes": {
			"ApiKeyAuth": {
				"type": "apiKey",
				"in": "header",
				"name": "Authorization",
				"description": "Use format `Bearer YOUR_API_KEY`."
			}
		}
	}
}
