{"openapi":"3.0.3","info":{"title":"Wigo Partner API","version":"1.0.0","description":"Tạo người dùng, đăng nhập một lần, tạo/đăng site và webhook cho đối tác Wigo. Xem https://trywigo.com/developers.html"},"servers":[{"url":"https://trywigo.com"}],
"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"wgk_test_… (sandbox) hoặc wgk_live_… (production)"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}}},"User":{"type":"object","properties":{"external_id":{"type":"string"},"email":{"type":"string"},"mode":{"type":"string","enum":["sandbox","live"]},"plan":{"type":"object","nullable":true,"properties":{"key":{"type":"string"},"label":{"type":"string"},"state":{"type":"string"},"source":{"type":"string"}}},"created_at":{"type":"string","format":"date-time"}}},"Site":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"status":{"type":"string"},"subdomain":{"type":"string","nullable":true},"url":{"type":"string","nullable":true}}}}},
"security":[{"bearer":[]}],
"paths":{
"/v1/ping":{"get":{"summary":"Kiểm tra khoá API","responses":{"200":{"description":"OK"},"401":{"description":"Khoá sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},
"/v1/users/{external_id}":{"parameters":[{"name":"external_id","in":"path","required":true,"schema":{"type":"string"}}],
 "put":{"summary":"Tạo/cập nhật người dùng (idempotent)","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"},"plan":{"type":"string","enum":["basic","pro"]}}}}}},"responses":{"200":{"description":"Đã có"},"201":{"description":"Đã tạo"},"409":{"description":"email_in_use | seat_limit | user_limit"}}},
 "get":{"summary":"Xem người dùng","responses":{"200":{"description":"OK"},"404":{"description":"Không có"}}},
 "delete":{"summary":"Xoá khỏi đối tác (trả ghế)","responses":{"200":{"description":"OK"},"404":{"description":"Không có"}}}},
"/v1/users/{external_id}/login-links":{"post":{"summary":"Liên kết đăng nhập một lần (60 giây)","parameters":[{"name":"external_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"redirect":{"type":"string","example":"/#/my-site"}}}}}},"responses":{"200":{"description":"{url, expires_in}"},"400":{"description":"bad_redirect"},"404":{"description":"Không có người dùng"}}}},
"/v1/users/{external_id}/sites":{"parameters":[{"name":"external_id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Danh sách site","responses":{"200":{"description":"{sites:[Site]}"}}},"post":{"summary":"Tạo site","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"template":{"type":"string"}}}}}},"responses":{"201":{"description":"{site}"},"409":{"description":"site_limit"}}}},
"/v1/sites/{id}/deploy":{"post":{"summary":"Đăng site","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["subdomain"],"properties":{"subdomain":{"type":"string"}}}}}},"responses":{"202":{"description":"{job_id, version}"},"404":{"description":"Không có site"}}}},
"/v1/usage":{"get":{"summary":"Số người dùng và ghế","responses":{"200":{"description":"OK"}}}},
"/v1/webhook":{"get":{"summary":"Xem cấu hình webhook","responses":{"200":{"description":"{webhook}"}}},"put":{"summary":"Đặt địa chỉ webhook (HTTPS)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":"string"}}}}}},"responses":{"200":{"description":"{webhook:{url,secret}}"},"400":{"description":"bad_url"}}}},
"/v1/webhook/test":{"post":{"summary":"Gửi sự kiện thử","responses":{"200":{"description":"{ok,status}"},"409":{"description":"no_webhook"}}}}}}
