{"openapi":"3.1.0","info":{"title":"Innocom Iframe Subdomain — Agent API","version":"1.0.0","description":"Iframe Subdomain dựng một subdomain (vd khuyen-mai.ten-mien.vn) hiển thị nguyên một trang web khác trong iframe, bằng Cloudflare Worker, kèm tiêu đề/mô tả/ảnh chia sẻ riêng. Agent làm được: xem mapping, tên miền (zone), tài khoản Cloudflare (không lộ token); tạo mapping mới, cập nhật trạng thái, deploy lại worker, đồng bộ danh sách tên miền. Agent không xoá được mapping và không sửa được tài khoản hay token Cloudflare.\n\nCần API key `if_ak_…` do người dùng tạo ở https://iframe.innocom.co/?tab=ai-connect. Hướng dẫn đầy đủ: https://api-iframe.innocom.co/api/agent/v1/docs"},"servers":[{"url":"https://api-iframe.innocom.co/api/agent/v1"}],"security":[{"bearer":[]},{"apiKey":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Authorization: Bearer if_ak_…"},"apiKey":{"type":"apiKey","in":"header","name":"X-API-Key"}},"schemas":{"ThanhCong":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","examples":[200]},"message":{"type":"string"},"data":{},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}},"Loi":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","examples":[400]},"message":{"type":"string"},"errors":{"description":"Chi tiết lỗi (nếu có)"}}}},"responses":{"Loi":{"description":"Lỗi — đọc `message`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Loi"}}}}}},"paths":{"/me":{"get":{"operationId":"get_me","summary":"Kiểm tra key","description":"Trả người dùng sở hữu key, vai trò, scope, hạn dùng. Gọi đầu tiên.\n\nScope: `agent:read`","tags":["me"],"parameters":[],"x-scope":"agent:read","responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThanhCong"}}}},"400":{"$ref":"#/components/responses/Loi"},"401":{"$ref":"#/components/responses/Loi"},"403":{"$ref":"#/components/responses/Loi"},"404":{"$ref":"#/components/responses/Loi"},"409":{"$ref":"#/components/responses/Loi"},"429":{"$ref":"#/components/responses/Loi"}}}},"/overview":{"get":{"operationId":"get_overview","summary":"Tổng quan","description":"Số mapping theo trạng thái, 5 mapping mới nhất, các tài khoản Cloudflare (số zone, số mapping).\n\nScope: `agent:read`","tags":["overview"],"parameters":[],"x-scope":"agent:read","responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThanhCong"}}}},"400":{"$ref":"#/components/responses/Loi"},"401":{"$ref":"#/components/responses/Loi"},"403":{"$ref":"#/components/responses/Loi"},"404":{"$ref":"#/components/responses/Loi"},"409":{"$ref":"#/components/responses/Loi"},"429":{"$ref":"#/components/responses/Loi"}}}},"/mappings":{"get":{"operationId":"list_mappings","summary":"Danh sách mapping","description":"Lọc theo trạng thái, tài khoản, tên miền; tìm theo hostname/URL đích/tiêu đề bằng q.\n\nScope: `agent:read`","tags":["mappings"],"parameters":[{"name":"q","in":"query","required":false,"description":"Tìm trong hostname, URL đích, tiêu đề","schema":{"type":"string","description":"Tìm trong hostname, URL đích, tiêu đề"}},{"name":"status","in":"query","required":false,"description":"","schema":{"type":"string","description":"","enum":["pending","creating","provisioning","attached","error"]}},{"name":"account_key","in":"query","required":false,"description":"Mã tài khoản Cloudflare (list_accounts)","schema":{"type":"string","description":"Mã tài khoản Cloudflare (list_accounts)"}},{"name":"zone","in":"query","required":false,"description":"Tên miền, vd example.vn","schema":{"type":"string","description":"Tên miền, vd example.vn"}},{"name":"limit","in":"query","required":false,"description":"Số dòng mỗi trang","schema":{"type":"integer","description":"Số dòng mỗi trang","default":20,"minimum":1,"maximum":100}},{"name":"offset","in":"query","required":false,"description":"Bỏ qua bao nhiêu dòng","schema":{"type":"integer","description":"Bỏ qua bao nhiêu dòng","default":0,"minimum":0}}],"x-scope":"agent:read","responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThanhCong"}}}},"400":{"$ref":"#/components/responses/Loi"},"401":{"$ref":"#/components/responses/Loi"},"403":{"$ref":"#/components/responses/Loi"},"404":{"$ref":"#/components/responses/Loi"},"409":{"$ref":"#/components/responses/Loi"},"429":{"$ref":"#/components/responses/Loi"}}},"post":{"operationId":"create_mapping","summary":"Tạo mapping (deploy worker)","description":"Tạo subdomain hiển thị URL đích trong iframe: tạo Cloudflare Worker + DNS thật. dry_run kiểm tài khoản, tên miền, hostname trùng.\n\nScope: `agent:write`","tags":["mappings"],"parameters":[{"name":"dry_run","in":"query","required":false,"description":"true = chỉ kiểm tra và xem trước, KHÔNG ghi gì. Nên gọi trước rồi xác nhận với người dùng.","schema":{"type":"boolean"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Chuỗi duy nhất cho lệnh này; gọi lại cùng chuỗi trong 24h trả lại đúng kết quả cũ, không làm hai lần.","schema":{"type":"string"}}],"x-scope":"agent:write","responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThanhCong"}}}},"400":{"$ref":"#/components/responses/Loi"},"401":{"$ref":"#/components/responses/Loi"},"403":{"$ref":"#/components/responses/Loi"},"404":{"$ref":"#/components/responses/Loi"},"409":{"$ref":"#/components/responses/Loi"},"429":{"$ref":"#/components/responses/Loi"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"account_key":{"type":"string","description":"Mã tài khoản Cloudflare (list_accounts)","maxLength":50,"examples":["accA"]},"zone":{"type":"string","description":"Tên miền (vd example.vn) hoặc zone id","examples":["example.vn"]},"subdomain":{"type":"string","description":"Phần trước tên miền: chữ thường, số, gạch ngang","maxLength":63,"examples":["khuyen-mai"]},"url_a":{"type":"string","description":"URL trang đích hiển thị trong iframe","format":"uri","examples":["https://landing.example.com/"]},"title":{"type":"string","description":"Tiêu đề trang (SEO)","maxLength":200},"meta_description":{"type":"string","description":"Mô tả (SEO)","maxLength":500},"og_image":{"type":"string","description":"Ảnh chia sẻ","format":"uri"}},"required":["account_key","zone","subdomain","url_a"]}}}}}},"/mappings/{id}":{"get":{"operationId":"get_mapping","summary":"Chi tiết mapping","description":"Hostname, URL đích, SEO, trạng thái deploy/SSL/health, lỗi gần nhất.\n\nScope: `agent:read`","tags":["mappings"],"parameters":[{"name":"id","in":"path","required":true,"description":"Id mapping (UUID, lấy từ list_mappings)","schema":{"type":"string","description":"Id mapping (UUID, lấy từ list_mappings)","format":"uuid","examples":["11111111-2222-4333-8444-555555555555"]}}],"x-scope":"agent:read","responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThanhCong"}}}},"400":{"$ref":"#/components/responses/Loi"},"401":{"$ref":"#/components/responses/Loi"},"403":{"$ref":"#/components/responses/Loi"},"404":{"$ref":"#/components/responses/Loi"},"409":{"$ref":"#/components/responses/Loi"},"429":{"$ref":"#/components/responses/Loi"}}}},"/zones":{"get":{"operationId":"list_zones","summary":"Danh sách tên miền","description":"Tên miền (zone) dùng được để tạo subdomain.\n\nScope: `agent:read`","tags":["zones"],"parameters":[{"name":"q","in":"query","required":false,"description":"Tìm trong tên miền","schema":{"type":"string","description":"Tìm trong tên miền"}},{"name":"account_key","in":"query","required":false,"description":"Mã tài khoản Cloudflare","schema":{"type":"string","description":"Mã tài khoản Cloudflare"}},{"name":"limit","in":"query","required":false,"description":"Số dòng mỗi trang","schema":{"type":"integer","description":"Số dòng mỗi trang","default":20,"minimum":1,"maximum":100}},{"name":"offset","in":"query","required":false,"description":"Bỏ qua bao nhiêu dòng","schema":{"type":"integer","description":"Bỏ qua bao nhiêu dòng","default":0,"minimum":0}}],"x-scope":"agent:read","responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThanhCong"}}}},"400":{"$ref":"#/components/responses/Loi"},"401":{"$ref":"#/components/responses/Loi"},"403":{"$ref":"#/components/responses/Loi"},"404":{"$ref":"#/components/responses/Loi"},"409":{"$ref":"#/components/responses/Loi"},"429":{"$ref":"#/components/responses/Loi"}}}},"/accounts":{"get":{"operationId":"list_accounts","summary":"Tài khoản Cloudflare","description":"Mã, nhãn, tình trạng token (không bao giờ trả token).\n\nScope: `agent:read`","tags":["accounts"],"parameters":[],"x-scope":"agent:read","responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThanhCong"}}}},"400":{"$ref":"#/components/responses/Loi"},"401":{"$ref":"#/components/responses/Loi"},"403":{"$ref":"#/components/responses/Loi"},"404":{"$ref":"#/components/responses/Loi"},"409":{"$ref":"#/components/responses/Loi"},"429":{"$ref":"#/components/responses/Loi"}}}},"/mappings/{id}/refresh":{"post":{"operationId":"refresh_mapping","summary":"Cập nhật trạng thái mapping","description":"Hỏi lại Cloudflare trạng thái worker/SSL/DNS và lưu lại.\n\nScope: `agent:write`","tags":["mappings"],"parameters":[{"name":"id","in":"path","required":true,"description":"Id mapping (UUID, lấy từ list_mappings)","schema":{"type":"string","description":"Id mapping (UUID, lấy từ list_mappings)","format":"uuid","examples":["11111111-2222-4333-8444-555555555555"]}},{"name":"dry_run","in":"query","required":false,"description":"true = chỉ kiểm tra và xem trước, KHÔNG ghi gì. Nên gọi trước rồi xác nhận với người dùng.","schema":{"type":"boolean"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Chuỗi duy nhất cho lệnh này; gọi lại cùng chuỗi trong 24h trả lại đúng kết quả cũ, không làm hai lần.","schema":{"type":"string"}}],"x-scope":"agent:write","responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThanhCong"}}}},"400":{"$ref":"#/components/responses/Loi"},"401":{"$ref":"#/components/responses/Loi"},"403":{"$ref":"#/components/responses/Loi"},"404":{"$ref":"#/components/responses/Loi"},"409":{"$ref":"#/components/responses/Loi"},"429":{"$ref":"#/components/responses/Loi"}}}},"/mappings/{id}/redeploy":{"post":{"operationId":"redeploy_mapping","summary":"Deploy lại worker","description":"Ghi lại mã worker của mapping lên Cloudflare (dùng khi worker hỏng hoặc vừa đổi mẫu).\n\nScope: `agent:write`","tags":["mappings"],"parameters":[{"name":"id","in":"path","required":true,"description":"Id mapping (UUID, lấy từ list_mappings)","schema":{"type":"string","description":"Id mapping (UUID, lấy từ list_mappings)","format":"uuid","examples":["11111111-2222-4333-8444-555555555555"]}},{"name":"dry_run","in":"query","required":false,"description":"true = chỉ kiểm tra và xem trước, KHÔNG ghi gì. Nên gọi trước rồi xác nhận với người dùng.","schema":{"type":"boolean"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Chuỗi duy nhất cho lệnh này; gọi lại cùng chuỗi trong 24h trả lại đúng kết quả cũ, không làm hai lần.","schema":{"type":"string"}}],"x-scope":"agent:write","responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThanhCong"}}}},"400":{"$ref":"#/components/responses/Loi"},"401":{"$ref":"#/components/responses/Loi"},"403":{"$ref":"#/components/responses/Loi"},"404":{"$ref":"#/components/responses/Loi"},"409":{"$ref":"#/components/responses/Loi"},"429":{"$ref":"#/components/responses/Loi"}}}},"/zones/sync":{"post":{"operationId":"sync_zones","summary":"Đồng bộ tên miền","description":"Đọc danh sách tên miền mới nhất của một tài khoản Cloudflare.\n\nScope: `agent:write`","tags":["zones"],"parameters":[{"name":"dry_run","in":"query","required":false,"description":"true = chỉ kiểm tra và xem trước, KHÔNG ghi gì. Nên gọi trước rồi xác nhận với người dùng.","schema":{"type":"boolean"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Chuỗi duy nhất cho lệnh này; gọi lại cùng chuỗi trong 24h trả lại đúng kết quả cũ, không làm hai lần.","schema":{"type":"string"}}],"x-scope":"agent:write","responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThanhCong"}}}},"400":{"$ref":"#/components/responses/Loi"},"401":{"$ref":"#/components/responses/Loi"},"403":{"$ref":"#/components/responses/Loi"},"404":{"$ref":"#/components/responses/Loi"},"409":{"$ref":"#/components/responses/Loi"},"429":{"$ref":"#/components/responses/Loi"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"account_key":{"type":"string","description":"Mã tài khoản Cloudflare"}},"required":["account_key"]}}}}}}}}