{"openapi":"3.1.0","info":{"title":"HLS Manager API","description":"\nAPI cho website/ứng dụng ngoài **tra mã nhúng, nhập video từ URL, sửa thông tin, nhận webhook** khi video mã hoá xong.\n\n### Xác thực\nGửi khoá trong header `X-Api-Key: <khoá>`. Riêng yêu cầu **GET** chấp nhận thêm `?key=<khoá>` (tiện cho thử nhanh,\nkhông khuyên dùng vì khoá lọt vào nhật ký). Khoá tạo ở trang quản lý › Cài đặt › Khoá API; khoá đầy đủ chỉ hiện **1 lần**.\n\nQuyền: `read` (chỉ đọc) và `write` (đọc + ghi). Khoá `read` gọi endpoint ghi → **403** `insufficient_scope`.\n\n### Giới hạn lượt\nMặc định **600 lượt/phút/khoá** (cửa sổ trượt 60 giây, chỉnh được theo từng khoá). Mỗi phản hồi thành công có header\n`X-RateLimit-Limit`, `X-RateLimit-Remaining`. Vượt giới hạn → **429** `rate_limited` kèm `Retry-After` (giây).\n\n### Lỗi\nMọi lỗi trả JSON `{\"error\": \"câu tiếng Việt\", \"code\": \"slug\"}` với mã HTTP 400/401/403/404/409/429 (hiếm: 500, 507).\nDữ liệu gửi sai kiểu cũng trả **400** `invalid_request` (không dùng 422).\n\n### Cấu trúc video\nMọi endpoint trả video theo cùng một cấu trúc; URL là **tuyệt đối** theo địa chỉ công khai của máy chủ.\n`hls_url`, `embed_url`, `embed_code`, `thumb_url` = `null` khi video chưa `done`. Thời gian là chuỗi ISO 8601 giờ UTC (`...Z`).\n\n### Webhook\nKhi video `done` / `error` / bị xoá, máy chủ POST JSON `{\"event\", \"video\", \"sent_at\"}` tới URL đã đăng ký, header\n`X-Hls-Signature: sha256=<HMAC-SHA256(secret, thân yêu cầu)>`, `X-Hls-Event`, `X-Hls-Delivery`. Phản hồi 2xx = thành công;\nlỗi thì thử lại 3 lần sau 10 giây, 60 giây, 10 phút.\n","version":"1.0.0"},"paths":{"/videos":{"get":{"tags":["Video"],"summary":"Danh sách video","operationId":"list_videos_videos_get","security":[{"KhoaHeader":[]},{"KhoaQuery":[]}],"parameters":[{"name":"q","in":"query","required":false,"schema":{"type":"string","description":"Tìm trong tiêu đề, ghi chú, thẻ, hoặc trùng mã id","default":"","title":"Q"},"description":"Tìm trong tiêu đề, ghi chú, thẻ, hoặc trùng mã id"},{"name":"tag","in":"query","required":false,"schema":{"type":"string","description":"Lọc đúng 1 thẻ","default":"","title":"Tag"},"description":"Lọc đúng 1 thẻ"},{"name":"status","in":"query","required":false,"schema":{"type":"string","description":"Trạng thái (mặc định done); nhiều giá trị cách dấu phẩy; all = mọi trạng thái","default":"done","title":"Status"},"description":"Trạng thái (mặc định done); nhiều giá trị cách dấu phẩy; all = mọi trạng thái"},{"name":"folder","in":"query","required":false,"schema":{"type":"string","description":"all | none (chưa phân loại) | <mã thư mục>","default":"all","title":"Folder"},"description":"all | none (chưa phân loại) | <mã thư mục>"},{"name":"page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"description":"Trang, từ 1","default":1,"title":"Page"},"description":"Trang, từ 1"},{"name":"per_page","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Số video mỗi trang (≤200)","default":50,"title":"Per Page"},"description":"Số video mỗi trang (≤200)"},{"name":"sort","in":"query","required":false,"schema":{"enum":["created_at","encoded_at","title","duration_sec","size_bytes","folder","plays"],"type":"string","description":"Cột sắp xếp; folder = theo tên thư mục (chưa phân loại cuối); plays = tổng lượt xem","default":"created_at","title":"Sort"},"description":"Cột sắp xếp; folder = theo tên thư mục (chưa phân loại cuối); plays = tổng lượt xem"},{"name":"order","in":"query","required":false,"schema":{"enum":["asc","desc"],"type":"string","description":"Chiều sắp xếp","default":"desc","title":"Order"},"description":"Chiều sắp xếp"},{"name":"since","in":"query","required":false,"schema":{"type":"string","description":"Chỉ lấy video có encoded_at (hoặc created_at nếu chưa mã hoá) ≥ thời điểm ISO 8601 này — dùng để đồng bộ dần","default":"","title":"Since"},"description":"Chỉ lấy video có encoded_at (hoặc created_at nếu chưa mã hoá) ≥ thời điểm ISO 8601 này — dùng để đồng bộ dần"},{"name":"from","in":"query","required":false,"schema":{"type":"string","description":"Từ ngày YYYY-MM-DD (giờ Việt Nam), lọc theo ngày hoàn tất encoded_at (video chưa done: created_at)","default":"","title":"From"},"description":"Từ ngày YYYY-MM-DD (giờ Việt Nam), lọc theo ngày hoàn tất encoded_at (video chưa done: created_at)"},{"name":"to","in":"query","required":false,"schema":{"type":"string","description":"Đến hết ngày YYYY-MM-DD (giờ Việt Nam)","default":"","title":"To"},"description":"Đến hết ngày YYYY-MM-DD (giờ Việt Nam)"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoList"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}},"/videos/lookup":{"get":{"tags":["Tra cứu"],"summary":"Tra 1 tiêu đề → mã nhúng","description":"Chỉ tìm video **done**. Không thấy vẫn trả 200 với `found: false`.","operationId":"lookup_one_videos_lookup_get","security":[{"KhoaHeader":[]},{"KhoaQuery":[]}],"parameters":[{"name":"title","in":"query","required":true,"schema":{"type":"string","minLength":1,"maxLength":500,"description":"Tiêu đề cần tìm","title":"Title"},"description":"Tiêu đề cần tìm"},{"name":"mode","in":"query","required":false,"schema":{"enum":["exact","contains"],"type":"string","description":"exact | contains","default":"exact","title":"Mode"},"description":"exact | contains"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LookupOne"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}},"post":{"tags":["Tra cứu"],"summary":"Tra hàng loạt tiêu đề (≤200)","description":"Dùng cho đồng bộ bài viết: gửi tối đa 200 tiêu đề/lần, nhận về mã nhúng từng tiêu đề.\nPOST nhưng chỉ cần quyền **read**.","operationId":"lookup_batch_videos_lookup_post","security":[{"KhoaHeader":[]},{"KhoaQuery":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LookupBatchIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LookupBatchOut"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}},"/videos/by-external/{site}/{post_id}":{"get":{"tags":["Tra cứu"],"summary":"Tìm video theo external_id (site:post_id)","description":"`GET /videos/by-external/wp/123` tìm video có `external_id = \"wp:123\"` (mọi trạng thái trừ đã xoá).","operationId":"by_external_videos_by_external__site___post_id__get","security":[{"KhoaHeader":[]},{"KhoaQuery":[]}],"parameters":[{"name":"site","in":"path","required":true,"schema":{"type":"string","description":"Phần site, vd wp","title":"Site"},"description":"Phần site, vd wp"},{"name":"post_id","in":"path","required":true,"schema":{"type":"string","description":"Phần post_id, vd 123","title":"Post Id"},"description":"Phần post_id, vd 123"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Video"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}},"/videos/{id}":{"get":{"tags":["Video"],"summary":"Chi tiết 1 video","operationId":"video_detail_videos__id__get","security":[{"KhoaHeader":[]},{"KhoaQuery":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","description":"Mã video 12 ký tự","title":"Id"},"description":"Mã video 12 ký tự"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Video"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}},"patch":{"tags":["Video"],"summary":"Sửa tiêu đề/thẻ/ghi chú/external_id/thư mục","description":"Chỉ trường **có gửi** mới đổi. `external_id: null` hoặc `\"\"` = bỏ liên kết; `folder_id: null` = chưa phân loại.","operationId":"patch_video_videos__id__patch","security":[{"KhoaHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","description":"Mã video","title":"Id"},"description":"Mã video"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchV1"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Video"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"403":{"description":"Khoá chỉ có quyền read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"409":{"description":"external_id trùng","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}},"delete":{"tags":["Video"],"summary":"Xoá video","description":"Xoá HLS + nguồn tải lên, gỡ external_id, gửi webhook `video.deleted`. Đang mã hoá thì dừng ffmpeg.","operationId":"delete_videos__id__delete","security":[{"KhoaHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","description":"Mã video","title":"Id"},"description":"Mã video"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkOut"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"403":{"description":"Khoá chỉ có quyền read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}},"/videos/{id}/stats":{"get":{"tags":["Video"],"summary":"Lượt xem theo ngày của 1 video","operationId":"video_stats_videos__id__stats_get","security":[{"KhoaHeader":[]},{"KhoaQuery":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","description":"Mã video","title":"Id"},"description":"Mã video"},{"name":"days","in":"query","required":false,"schema":{"type":"integer","maximum":365,"minimum":1,"description":"Số ngày tính tới hôm nay","default":30,"title":"Days"},"description":"Số ngày tính tới hôm nay"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoStatsOut"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}},"/videos/{id}/embed":{"get":{"tags":["Video"],"summary":"Mã nhúng của 1 video","operationId":"video_embed_videos__id__embed_get","security":[{"KhoaHeader":[]},{"KhoaQuery":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","description":"Mã video","title":"Id"},"description":"Mã video"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Embed"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"409":{"description":"Video chưa done (not_ready)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}},"/tags":{"get":{"tags":["Danh mục"],"summary":"Danh sách thẻ (đếm video done)","operationId":"tags_tags_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagList"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}},"security":[{"KhoaHeader":[]},{"KhoaQuery":[]}]}},"/folders":{"get":{"tags":["Danh mục"],"summary":"Danh sách thư mục","operationId":"folders_folders_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FolderList"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}},"security":[{"KhoaHeader":[]},{"KhoaQuery":[]}]}},"/stats":{"get":{"tags":["Hệ thống"],"summary":"Thống kê","operationId":"stats_stats_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Stats"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}},"security":[{"KhoaHeader":[]},{"KhoaQuery":[]}]}},"/stats/series":{"get":{"tags":["Hệ thống"],"summary":"Thống kê theo ngày (video, lượt xem, băng thông)","description":"Số liệu từng ngày để vẽ biểu đồ. Lượt xem và băng thông đọc từ nhật ký nginx mỗi 60 giây (và ngay khi gọi);\nbỏ qua request từ chính máy chủ (127.0.0.1). Video tính theo `encoded_at` của video đang `done`.","operationId":"stats_series_stats_series_get","security":[{"KhoaHeader":[]},{"KhoaQuery":[]}],"parameters":[{"name":"days","in":"query","required":false,"schema":{"type":"integer","maximum":365,"minimum":1,"description":"Số ngày tính tới hôm nay (1–365), vd 7, 30, 90","default":30,"title":"Days"},"description":"Số ngày tính tới hôm nay (1–365), vd 7, 30, 90"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Series"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}},"/jobs":{"get":{"tags":["Hệ thống"],"summary":"Hàng đợi xử lý (tải về / mã hoá / lỗi)","description":"Xếp: encoding, downloading, queued (cũ trước), error, rồi các trạng thái khác.","operationId":"jobs_jobs_get","security":[{"KhoaHeader":[]},{"KhoaQuery":[]}],"parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string","description":"Trạng thái, cách dấu phẩy: downloading, queued, encoding, error, cancelled, done; all","default":"queued,downloading,encoding,error","title":"Status"},"description":"Trạng thái, cách dấu phẩy: downloading, queued, encoding, error, cancelled, done; all"},{"name":"page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"default":1,"title":"Page"}},{"name":"per_page","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Per Page"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobList"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}},"/videos/import":{"post":{"tags":["Video"],"summary":"Nhập video từ link trực tiếp","description":"Tạo video trạng thái `downloading`, tải nền rồi tự mã hoá. Theo dõi bằng `GET /videos/{id}`, `GET /jobs`\nhoặc webhook `video.done`. Chỉ nhận link trực tiếp tới tệp video mà bạn có quyền phát; không tách luồng từ\nnền tảng khác.","operationId":"import_video_videos_import_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Video"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"403":{"description":"Khoá chỉ có quyền read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"409":{"description":"external_id đã gắn video khác (thân lỗi có video_id)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}},"security":[{"KhoaHeader":[]}]}},"/videos/{id}/reencode":{"post":{"tags":["Video"],"summary":"Mã hoá lại","description":"Đưa lại hàng đợi. Cần còn tệp nguồn (máy chủ mặc định xoá nguồn sau khi mã hoá xong → thường 409 no_source).","operationId":"reencode_videos__id__reencode_post","security":[{"KhoaHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","description":"Mã video","title":"Id"},"description":"Mã video"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Video"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"403":{"description":"Khoá chỉ có quyền read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"409":{"description":"Đang xử lý (busy) hoặc không còn tệp nguồn (no_source)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}},"/webhooks":{"get":{"tags":["Webhook"],"summary":"Danh sách webhook","operationId":"wh_list_webhooks_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookList"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"403":{"description":"Khoá chỉ có quyền read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}},"security":[{"KhoaHeader":[]}]},"post":{"tags":["Webhook"],"summary":"Đăng ký webhook","description":"`secret` bỏ trống → máy chủ sinh 32 ký tự. Secret đầy đủ CHỈ trả trong phản hồi này — lưu lại để xác minh chữ ký.","operationId":"wh_create_webhooks_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookCreated"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"403":{"description":"Khoá chỉ có quyền read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}},"security":[{"KhoaHeader":[]}]}},"/webhooks/{id}":{"delete":{"tags":["Webhook"],"summary":"Xoá webhook","operationId":"wh_delete_webhooks__id__delete","security":[{"KhoaHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","description":"Mã webhook","title":"Id"},"description":"Mã webhook"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkOut"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"403":{"description":"Khoá chỉ có quyền read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}},"/webhooks/{id}/deliveries":{"get":{"tags":["Webhook"],"summary":"Nhật ký gửi webhook","operationId":"wh_deliveries_webhooks__id__deliveries_get","security":[{"KhoaHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","title":"Id"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Số lần gửi gần nhất","default":20,"title":"Limit"},"description":"Số lần gửi gần nhất"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeliveryList"}}}},"400":{"description":"Dữ liệu sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"401":{"description":"Thiếu/sai/tắt khoá","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"429":{"description":"Vượt giới hạn lượt (header Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"403":{"description":"Khoá chỉ có quyền read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOut"}}}}}}}},"components":{"schemas":{"Delivery":{"properties":{"id":{"type":"integer","title":"Id"},"webhook_id":{"type":"integer","title":"Webhook Id"},"event":{"type":"string","title":"Event"},"video_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Video Id"},"status":{"type":"string","title":"Status","description":"pending (chờ gửi/chờ thử lại) | success | failed (hết 4 lần)"},"attempts":{"type":"integer","title":"Attempts","description":"Số lần đã gửi (tối đa 4 = 1 + 3 lần thử lại)"},"response_code":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Response Code","description":"Mã HTTP máy nhận trả lần gần nhất"},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"},"duration_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Duration Ms"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"},"last_attempt_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Attempt At"},"next_attempt_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Next Attempt At","description":"Lúc thử lại kế tiếp (khi pending)"}},"type":"object","required":["id","webhook_id","event","status","attempts"],"title":"Delivery"},"DeliveryList":{"properties":{"items":{"items":{"$ref":"#/components/schemas/Delivery"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total"}},"type":"object","required":["items","total"],"title":"DeliveryList"},"Embed":{"properties":{"id":{"type":"string","title":"Id"},"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title"},"embed_url":{"type":"string","title":"Embed Url"},"embed_code":{"type":"string","title":"Embed Code"},"hls_url":{"type":"string","title":"Hls Url"},"thumb_url":{"type":"string","title":"Thumb Url"},"width":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Width"},"height":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Height"}},"type":"object","required":["id","embed_url","embed_code","hls_url","thumb_url"],"title":"Embed"},"ErrorOut":{"properties":{"error":{"type":"string","title":"Error","description":"Câu báo tiếng Việt"},"code":{"type":"string","title":"Code","description":"Mã lỗi (slug) để máy đọc"}},"type":"object","required":["error","code"],"title":"ErrorOut","example":{"code":"invalid_api_key","error":"Khoá API không đúng"}},"Folder":{"properties":{"id":{"type":"integer","title":"Id"},"name":{"type":"string","title":"Name"},"count":{"type":"integer","title":"Count","description":"Số video (mọi trạng thái trừ đã xoá)"},"done_count":{"type":"integer","title":"Done Count","description":"Số video done"},"size_bytes":{"type":"integer","title":"Size Bytes","description":"Tổng dung lượng (size_bytes) các video done trong thư mục","default":0},"latest_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Latest At","description":"encoded_at mới nhất trong thư mục (null nếu chưa có video done)"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"}},"type":"object","required":["id","name","count","done_count"],"title":"Folder"},"FolderList":{"properties":{"items":{"items":{"$ref":"#/components/schemas/Folder"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total"}},"type":"object","required":["items","total"],"title":"FolderList"},"ImportIn":{"properties":{"url":{"type":"string","title":"Url","description":"Link http/https TRỰC TIẾP tới tệp video (mp4/mkv/mov/webm). Không nhận m3u8, trang web, hay địa chỉ mạng nội bộ"},"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title","description":"Tiêu đề (mặc định = tên tệp)"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags","description":"Thẻ"},"note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Note","description":"Ghi chú"},"external_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Id","description":"site:post_id; trùng video khác → 409 external_id_exists"},"folder_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Folder Id","description":"Mã thư mục"}},"type":"object","required":["url"],"title":"ImportIn","example":{"external_id":"wp:123","note":"","tags":["mẫu"],"title":"Phim mẫu","url":"https://cdn.vidu.com/phim/abc.mp4"}},"Job":{"properties":{"id":{"type":"string","title":"Id","description":"Mã video 12 ký tự a-z0-9 (cũng là tên thư mục HLS)"},"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title","description":"Tiêu đề"},"status":{"type":"string","title":"Status","description":"downloading | queued | encoding | done | error | cancelled"},"duration_sec":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Duration Sec","description":"Thời lượng (giây), có sau khi mã hoá"},"width":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Width","description":"Chiều rộng nguồn (px)"},"height":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Height","description":"Chiều cao nguồn (px)"},"size_bytes":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Size Bytes","description":"Dung lượng tệp nguồn (byte)"},"renditions":{"items":{"type":"string"},"type":"array","title":"Renditions","description":"Các bậc chất lượng đã mã hoá, vd [\"480p\",\"720p\"]"},"tags":{"items":{"type":"string"},"type":"array","title":"Tags","description":"Thẻ"},"note":{"type":"string","title":"Note","description":"Ghi chú"},"external_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Id","description":"Mã bên ngoài dạng site:post_id (duy nhất)"},"folder_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Folder Id","description":"Mã thư mục; null = chưa phân loại"},"folder_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Folder Name","description":"Tên thư mục"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At","description":"Lúc tạo (ISO 8601 UTC)"},"encoded_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Encoded At","description":"Lúc mã hoá xong (ISO 8601 UTC)"},"hls_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Hls Url","description":"Link master.m3u8 tuyệt đối (null khi chưa done)"},"embed_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Embed Url","description":"Link trang nhúng /embed/<id> (null khi chưa done)"},"embed_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Embed Code","description":"Mã <iframe> dán vào bài viết (null khi chưa done)"},"thumb_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Thumb Url","description":"Ảnh đại diện thumb.jpg (null khi chưa done)"},"plays_total":{"type":"integer","title":"Plays Total","description":"Tổng lượt xem (1 lượt/IP/video/giờ, từ nhật ký nginx)","default":0},"plays_7d":{"type":"integer","title":"Plays 7D","description":"Lượt xem 7 ngày gần nhất (gồm hôm nay, giờ VN)","default":0},"bytes_total":{"type":"integer","title":"Bytes Total","description":"Tổng băng thông đã phát của video (byte)","default":0},"progress":{"type":"number","title":"Progress","description":"Tiến độ 0–100 (tải về hoặc mã hoá)"},"error_msg":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Msg","description":"Lý do lỗi khi status = error"}},"type":"object","required":["id","status","renditions","tags","note","progress"],"title":"Job","example":{"created_at":"2026-11-06T03:00:00Z","duration_sec":30.0,"embed_code":"<iframe src=\"https://play.getphimsexhay.com/embed/k3v9x2m1q8ab\" width=\"100%\" height=\"100%\" frameborder=\"0\" allowfullscreen allow=\"autoplay; fullscreen\"></iframe>","embed_url":"https://play.getphimsexhay.com/embed/k3v9x2m1q8ab","encoded_at":"2026-11-06T03:00:42Z","external_id":"wp:123","folder_id":1,"folder_name":"Phim lẻ","height":720,"hls_url":"https://play.getphimsexhay.com/hls/k3v9x2m1q8ab/master.m3u8","id":"k3v9x2m1q8ab","note":"","renditions":["480p","720p"],"size_bytes":5242880,"status":"done","tags":["mẫu"],"thumb_url":"https://play.getphimsexhay.com/hls/k3v9x2m1q8ab/thumb.jpg","title":"Phim mẫu 30 giây","width":1280}},"JobList":{"properties":{"items":{"items":{"$ref":"#/components/schemas/Job"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total"},"page":{"type":"integer","title":"Page"},"per_page":{"type":"integer","title":"Per Page"}},"type":"object","required":["items","total","page","per_page"],"title":"JobList"},"LookupBatchIn":{"properties":{"titles":{"items":{"type":"string"},"type":"array","title":"Titles","description":"Danh sách tiêu đề, tối đa 200"},"mode":{"type":"string","enum":["exact","contains"],"title":"Mode","description":"exact: chỉ trùng hẳn; contains: không trùng thì tìm video có tiêu đề chứa chuỗi","default":"exact"}},"type":"object","required":["titles"],"title":"LookupBatchIn","example":{"mode":"exact","titles":["Phim mẫu 30 giây","Không có"]}},"LookupBatchOut":{"properties":{"results":{"additionalProperties":{"$ref":"#/components/schemas/LookupResult"},"type":"object","title":"Results","description":"Khoá = tiêu đề đã gửi (giữ nguyên chuỗi)"},"found":{"type":"integer","title":"Found","description":"Số tiêu đề tìm thấy"},"total":{"type":"integer","title":"Total","description":"Số tiêu đề (đã bỏ trùng)"}},"type":"object","required":["results","found","total"],"title":"LookupBatchOut"},"LookupOne":{"properties":{"found":{"type":"boolean","title":"Found","description":"Có video done khớp tiêu đề không"},"match":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Match","description":"exact (trùng hẳn, không phân biệt hoa thường/khoảng trắng) | contains (chứa chuỗi, chỉ khi mode=contains)"},"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id","description":"Mã video 12 ký tự a-z0-9 (cũng là tên thư mục HLS)"},"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title","description":"Tiêu đề"},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status","description":"downloading | queued | encoding | done | error | cancelled"},"duration_sec":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Duration Sec","description":"Thời lượng (giây), có sau khi mã hoá"},"width":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Width","description":"Chiều rộng nguồn (px)"},"height":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Height","description":"Chiều cao nguồn (px)"},"size_bytes":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Size Bytes","description":"Dung lượng tệp nguồn (byte)"},"renditions":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Renditions","description":"Các bậc chất lượng đã mã hoá, vd [\"480p\",\"720p\"]"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags","description":"Thẻ"},"note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Note","description":"Ghi chú"},"external_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Id","description":"Mã bên ngoài dạng site:post_id (duy nhất)"},"folder_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Folder Id","description":"Mã thư mục; null = chưa phân loại"},"folder_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Folder Name","description":"Tên thư mục"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At","description":"Lúc tạo (ISO 8601 UTC)"},"encoded_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Encoded At","description":"Lúc mã hoá xong (ISO 8601 UTC)"},"hls_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Hls Url","description":"Link master.m3u8 tuyệt đối (null khi chưa done)"},"embed_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Embed Url","description":"Link trang nhúng /embed/<id> (null khi chưa done)"},"embed_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Embed Code","description":"Mã <iframe> dán vào bài viết (null khi chưa done)"},"thumb_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Thumb Url","description":"Ảnh đại diện thumb.jpg (null khi chưa done)"},"plays_total":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Plays Total","description":"Tổng lượt xem (1 lượt/IP/video/giờ, từ nhật ký nginx)"},"plays_7d":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Plays 7D","description":"Lượt xem 7 ngày gần nhất (gồm hôm nay, giờ VN)"},"bytes_total":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Bytes Total","description":"Tổng băng thông đã phát của video (byte)"},"query":{"type":"string","title":"Query","description":"Tiêu đề đã hỏi"}},"type":"object","required":["found","query"],"title":"LookupOne"},"LookupResult":{"properties":{"found":{"type":"boolean","title":"Found","description":"Có video done khớp tiêu đề không"},"match":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Match","description":"exact (trùng hẳn, không phân biệt hoa thường/khoảng trắng) | contains (chứa chuỗi, chỉ khi mode=contains)"},"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id","description":"Mã video 12 ký tự a-z0-9 (cũng là tên thư mục HLS)"},"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title","description":"Tiêu đề"},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status","description":"downloading | queued | encoding | done | error | cancelled"},"duration_sec":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Duration Sec","description":"Thời lượng (giây), có sau khi mã hoá"},"width":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Width","description":"Chiều rộng nguồn (px)"},"height":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Height","description":"Chiều cao nguồn (px)"},"size_bytes":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Size Bytes","description":"Dung lượng tệp nguồn (byte)"},"renditions":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Renditions","description":"Các bậc chất lượng đã mã hoá, vd [\"480p\",\"720p\"]"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags","description":"Thẻ"},"note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Note","description":"Ghi chú"},"external_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Id","description":"Mã bên ngoài dạng site:post_id (duy nhất)"},"folder_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Folder Id","description":"Mã thư mục; null = chưa phân loại"},"folder_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Folder Name","description":"Tên thư mục"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At","description":"Lúc tạo (ISO 8601 UTC)"},"encoded_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Encoded At","description":"Lúc mã hoá xong (ISO 8601 UTC)"},"hls_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Hls Url","description":"Link master.m3u8 tuyệt đối (null khi chưa done)"},"embed_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Embed Url","description":"Link trang nhúng /embed/<id> (null khi chưa done)"},"embed_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Embed Code","description":"Mã <iframe> dán vào bài viết (null khi chưa done)"},"thumb_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Thumb Url","description":"Ảnh đại diện thumb.jpg (null khi chưa done)"},"plays_total":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Plays Total","description":"Tổng lượt xem (1 lượt/IP/video/giờ, từ nhật ký nginx)"},"plays_7d":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Plays 7D","description":"Lượt xem 7 ngày gần nhất (gồm hôm nay, giờ VN)"},"bytes_total":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Bytes Total","description":"Tổng băng thông đã phát của video (byte)"}},"type":"object","required":["found"],"title":"LookupResult"},"OkOut":{"properties":{"ok":{"type":"boolean","title":"Ok"},"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id"}},"type":"object","required":["ok"],"title":"OkOut"},"PatchV1":{"properties":{"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags"},"note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Note"},"external_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Id"},"folder_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Folder Id"}},"type":"object","title":"PatchV1","example":{"external_id":"wp:456","tags":["a","b"],"title":"Tên mới"}},"Series":{"properties":{"from":{"type":"string","title":"From","description":"Ngày đầu khoảng"},"to":{"type":"string","title":"To","description":"Ngày cuối khoảng (hôm nay)"},"tz":{"type":"string","title":"Tz","description":"Múi giờ dùng để chia ngày"},"days":{"items":{"$ref":"#/components/schemas/SeriesDay"},"type":"array","title":"Days","description":"Đủ mọi ngày trong khoảng, cũ trước; ngày không có dữ liệu = 0"},"totals":{"$ref":"#/components/schemas/SeriesTotals"},"updated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated At","description":"Lần đọc nhật ký nginx gần nhất (ISO UTC)"},"log_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Log Error","description":"Lỗi đọc nhật ký (null nếu ổn)"},"data_since":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Data Since","description":"Ngày sớm nhất có số liệu lượt xem/băng thông"}},"type":"object","required":["from","to","tz","days","totals"],"title":"Series","example":{"data_since":"2026-11-05","days":[{"date":"2026-11-04","hls_bytes":0,"hls_requests":0,"plays":0,"unique_ips":0,"videos_done":0,"videos_total":0},{"date":"2026-11-05","hls_bytes":2147483648,"hls_requests":5400,"plays":310,"unique_ips":120,"videos_done":40,"videos_total":40},{"date":"2026-11-06","hls_bytes":734003200,"hls_requests":1500,"plays":95,"unique_ips":48,"videos_done":23,"videos_total":63}],"from":"2026-11-04","to":"2026-11-06","totals":{"hls_bytes":2881486848,"hls_requests":6900,"plays":405,"unique_ips":150,"videos_done":63,"videos_total":63,"videos_total_start":0},"tz":"+07:00","updated_at":"2026-11-06T02:10:00Z"}},"SeriesDay":{"properties":{"date":{"type":"string","title":"Date","description":"Ngày YYYY-MM-DD theo múi giờ thống kê (mặc định +07:00)"},"videos_total":{"type":"integer","title":"Videos Total","description":"Tổng video đang `done` có encoded_at tới hết ngày này (tích luỹ)"},"videos_done":{"type":"integer","title":"Videos Done","description":"Số video mã hoá xong trong ngày"},"plays":{"type":"integer","title":"Plays","description":"Lượt xem: GET /embed/<id> hoặc master.m3u8, 1 lượt/IP/video/giờ"},"hls_bytes":{"type":"integer","title":"Hls Bytes","description":"Băng thông: tổng byte đã gửi của mọi request /hls/"},"hls_requests":{"type":"integer","title":"Hls Requests","description":"Số request /hls/ (m3u8, .ts, ảnh)"},"unique_ips":{"type":"integer","title":"Unique Ips","description":"Số IP khác nhau gọi /hls/ hoặc /embed/ trong ngày"}},"type":"object","required":["date","videos_total","videos_done","plays","hls_bytes","hls_requests","unique_ips"],"title":"SeriesDay"},"SeriesTotals":{"properties":{"videos_total":{"type":"integer","title":"Videos Total","description":"Tổng video cuối khoảng (= videos_total ngày cuối)"},"videos_total_start":{"type":"integer","title":"Videos Total Start","description":"Tổng video trước ngày đầu khoảng"},"videos_done":{"type":"integer","title":"Videos Done"},"plays":{"type":"integer","title":"Plays"},"hls_bytes":{"type":"integer","title":"Hls Bytes"},"hls_requests":{"type":"integer","title":"Hls Requests"},"unique_ips":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Unique Ips","description":"IP khác nhau cả khoảng (null nếu danh sách IP cũ đã dọn)"}},"type":"object","required":["videos_total","videos_total_start","videos_done","plays","hls_bytes","hls_requests"],"title":"SeriesTotals"},"Stats":{"properties":{"total":{"type":"integer","title":"Total","description":"Mọi video trừ đã xoá"},"done":{"type":"integer","title":"Done"},"queued":{"type":"integer","title":"Queued"},"encoding":{"type":"integer","title":"Encoding"},"downloading":{"type":"integer","title":"Downloading"},"error":{"type":"integer","title":"Error"},"cancelled":{"type":"integer","title":"Cancelled"},"done_7d":{"type":"integer","title":"Done 7D","description":"Số video xong trong 7 ngày"},"plays_today":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Plays Today","description":"Lượt xem hôm nay (1 lượt/IP/video/giờ, ngày theo giờ VN; null nếu không đọc được log)"},"disk_free_bytes":{"type":"integer","title":"Disk Free Bytes"},"disk_total_bytes":{"type":"integer","title":"Disk Total Bytes"},"out_bytes":{"type":"integer","title":"Out Bytes","description":"Dung lượng HLS đã mã hoá"}},"type":"object","required":["total","done","queued","encoding","downloading","error","cancelled","done_7d","disk_free_bytes","disk_total_bytes","out_bytes"],"title":"Stats"},"TagItem":{"properties":{"tag":{"type":"string","title":"Tag"},"count":{"type":"integer","title":"Count","description":"Số video done có thẻ này"}},"type":"object","required":["tag","count"],"title":"TagItem"},"TagList":{"properties":{"items":{"items":{"$ref":"#/components/schemas/TagItem"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total"}},"type":"object","required":["items","total"],"title":"TagList"},"Video":{"properties":{"id":{"type":"string","title":"Id","description":"Mã video 12 ký tự a-z0-9 (cũng là tên thư mục HLS)"},"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title","description":"Tiêu đề"},"status":{"type":"string","title":"Status","description":"downloading | queued | encoding | done | error | cancelled"},"duration_sec":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Duration Sec","description":"Thời lượng (giây), có sau khi mã hoá"},"width":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Width","description":"Chiều rộng nguồn (px)"},"height":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Height","description":"Chiều cao nguồn (px)"},"size_bytes":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Size Bytes","description":"Dung lượng tệp nguồn (byte)"},"renditions":{"items":{"type":"string"},"type":"array","title":"Renditions","description":"Các bậc chất lượng đã mã hoá, vd [\"480p\",\"720p\"]"},"tags":{"items":{"type":"string"},"type":"array","title":"Tags","description":"Thẻ"},"note":{"type":"string","title":"Note","description":"Ghi chú"},"external_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Id","description":"Mã bên ngoài dạng site:post_id (duy nhất)"},"folder_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Folder Id","description":"Mã thư mục; null = chưa phân loại"},"folder_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Folder Name","description":"Tên thư mục"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At","description":"Lúc tạo (ISO 8601 UTC)"},"encoded_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Encoded At","description":"Lúc mã hoá xong (ISO 8601 UTC)"},"hls_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Hls Url","description":"Link master.m3u8 tuyệt đối (null khi chưa done)"},"embed_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Embed Url","description":"Link trang nhúng /embed/<id> (null khi chưa done)"},"embed_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Embed Code","description":"Mã <iframe> dán vào bài viết (null khi chưa done)"},"thumb_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Thumb Url","description":"Ảnh đại diện thumb.jpg (null khi chưa done)"},"plays_total":{"type":"integer","title":"Plays Total","description":"Tổng lượt xem (1 lượt/IP/video/giờ, từ nhật ký nginx)","default":0},"plays_7d":{"type":"integer","title":"Plays 7D","description":"Lượt xem 7 ngày gần nhất (gồm hôm nay, giờ VN)","default":0},"bytes_total":{"type":"integer","title":"Bytes Total","description":"Tổng băng thông đã phát của video (byte)","default":0}},"type":"object","required":["id","status","renditions","tags","note"],"title":"Video","example":{"created_at":"2026-11-06T03:00:00Z","duration_sec":30.0,"embed_code":"<iframe src=\"https://play.getphimsexhay.com/embed/k3v9x2m1q8ab\" width=\"100%\" height=\"100%\" frameborder=\"0\" allowfullscreen allow=\"autoplay; fullscreen\"></iframe>","embed_url":"https://play.getphimsexhay.com/embed/k3v9x2m1q8ab","encoded_at":"2026-11-06T03:00:42Z","external_id":"wp:123","folder_id":1,"folder_name":"Phim lẻ","height":720,"hls_url":"https://play.getphimsexhay.com/hls/k3v9x2m1q8ab/master.m3u8","id":"k3v9x2m1q8ab","note":"","renditions":["480p","720p"],"size_bytes":5242880,"status":"done","tags":["mẫu"],"thumb_url":"https://play.getphimsexhay.com/hls/k3v9x2m1q8ab/thumb.jpg","title":"Phim mẫu 30 giây","width":1280}},"VideoList":{"properties":{"items":{"items":{"$ref":"#/components/schemas/Video"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Tổng số video khớp bộ lọc"},"page":{"type":"integer","title":"Page"},"per_page":{"type":"integer","title":"Per Page"}},"type":"object","required":["items","total","page","per_page"],"title":"VideoList"},"VideoStatsDay":{"properties":{"date":{"type":"string","title":"Date","description":"Ngày YYYY-MM-DD (giờ VN)"},"plays":{"type":"integer","title":"Plays"},"bytes":{"type":"integer","title":"Bytes"}},"type":"object","required":["date","plays","bytes"],"title":"VideoStatsDay"},"VideoStatsOut":{"properties":{"id":{"type":"string","title":"Id"},"from":{"type":"string","title":"From"},"to":{"type":"string","title":"To"},"tz":{"type":"string","title":"Tz"},"days":{"items":{"$ref":"#/components/schemas/VideoStatsDay"},"type":"array","title":"Days","description":"Đủ mọi ngày trong khoảng, ngày trống = 0"},"totals":{"additionalProperties":{"type":"integer"},"type":"object","title":"Totals","description":"Tổng trong khoảng: plays, bytes"},"all_time":{"additionalProperties":{"type":"integer"},"type":"object","title":"All Time","description":"plays_total, plays_7d, bytes_total"}},"type":"object","required":["id","from","to","tz","days","totals","all_time"],"title":"VideoStatsOut","example":{"all_time":{"bytes_total":209715200,"plays_7d":10,"plays_total":10},"days":[{"bytes":52428800,"date":"2026-11-05","plays":3},{"bytes":157286400,"date":"2026-11-06","plays":7}],"from":"2026-11-05","id":"bvpxgt50id8d","to":"2026-11-06","totals":{"bytes":209715200,"plays":10},"tz":"+07:00"}},"Webhook":{"properties":{"id":{"type":"integer","title":"Id"},"url":{"type":"string","title":"Url"},"events":{"items":{"type":"string"},"type":"array","title":"Events"},"enabled":{"type":"boolean","title":"Enabled"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"},"secret_hint":{"type":"string","title":"Secret Hint","description":"4 ký tự đầu của secret + …"},"last_status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Status","description":"Trạng thái lần gửi gần nhất: pending | success | failed"},"last_attempt_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Attempt At"},"last_response_code":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Last Response Code"}},"type":"object","required":["id","url","events","enabled","secret_hint"],"title":"Webhook"},"WebhookCreated":{"properties":{"id":{"type":"integer","title":"Id"},"url":{"type":"string","title":"Url"},"events":{"items":{"type":"string"},"type":"array","title":"Events"},"enabled":{"type":"boolean","title":"Enabled"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"},"secret_hint":{"type":"string","title":"Secret Hint","description":"4 ký tự đầu của secret + …"},"last_status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Status","description":"Trạng thái lần gửi gần nhất: pending | success | failed"},"last_attempt_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Attempt At"},"last_response_code":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Last Response Code"},"secret":{"type":"string","title":"Secret","description":"Secret đầy đủ — CHỈ trả 1 lần khi tạo"}},"type":"object","required":["id","url","events","enabled","secret_hint","secret"],"title":"WebhookCreated"},"WebhookIn":{"properties":{"url":{"type":"string","title":"Url","description":"URL http(s) công khai nhận POST"},"events":{"items":{"type":"string"},"type":"array","title":"Events","description":"Tập con của video.done, video.error, video.deleted (mặc định cả 3)"},"secret":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Secret","description":"Chuỗi bí mật ký HMAC (16–200 ký tự, không dấu cách); bỏ trống để máy chủ sinh"}},"type":"object","required":["url"],"title":"WebhookIn","example":{"events":["video.done","video.error"],"secret":"","url":"https://web-cua-ban.com/wp-json/hls/v1/webhook"}},"WebhookList":{"properties":{"items":{"items":{"$ref":"#/components/schemas/Webhook"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total"}},"type":"object","required":["items","total"],"title":"WebhookList"}},"securitySchemes":{"KhoaHeader":{"type":"apiKey","description":"Khoá API trong header (khuyên dùng).","in":"header","name":"X-Api-Key"},"KhoaQuery":{"type":"apiKey","description":"Khoá API trong query — CHỈ cho yêu cầu GET.","in":"query","name":"key"}}},"tags":[{"name":"Video","description":"Danh sách, chi tiết, mã nhúng, nhập từ URL, sửa, mã hoá lại, xoá."},{"name":"Tra cứu","description":"Tìm video theo tiêu đề (1 hoặc hàng loạt) hoặc theo mã bài viết bên ngoài (external_id)."},{"name":"Danh mục","description":"Thẻ (tag) và thư mục."},{"name":"Hệ thống","description":"Thống kê và hàng đợi xử lý."},{"name":"Webhook","description":"Đăng ký URL nhận sự kiện video.done, video.error, video.deleted (cần quyền write)."}],"servers":[{"url":"https://play.getphimsexhay.com/api/v1","description":"Máy chủ này"}]}