Kết nối IAI Flow API trong 5 phút. Login → session → fetch flows → trigger run.
credentials: "include")Gửi credentials. API trả về Set-Cookie header với session token. Cookie được tự động lưu bởi browser.
POST https://api.flow.iai.one/api/auth/login
Content-Type: application/json
{
"email": "you@company.com",
"password": "your-password"
}
{
"authenticated": true,
"user": {
"id": "usr_...",
"email": "you@company.com",
"name": "Your Name"
},
"workspace": {
"workspaceId": "ws_...",
"name": "My Workspace",
"role": "owner"
}
}
iai_session được set với HttpOnly; Secure; SameSite=None. Mọi request sau chỉ cần credentials: "include".
GET https://api.flow.iai.one/api/auth/session
// credentials: "include"
{
"authenticated": true,
"user": { ... },
"workspace": { ... }
}
GET https://api.flow.iai.one/api/flows
// credentials: "include"
{
"items": [
{
"id": "wf_...",
"name": "My Flow",
"status": "active",
"version": 1,
"updated_at": "2026-01-01T00:00:00Z"
}
]
}
POST https://api.flow.iai.one/api/workflows/{id}/run
Content-Type: application/json
// credentials: "include"
{
"input": { "topic": "AI trends 2026" }
}
{
"run_id": "run_...",
"status": "running",
"started_at": "2026-01-01T00:00:00Z"
}
GET https://api.flow.iai.one/api/runs/{run_id}
// credentials: "include"
{
"run": {
"id": "run_...",
"status": "success",
"duration_ms": 1240,
"output": { ... }
}
}
status là success hoặc failed.
const API = "https://api.flow.iai.one";
// 1. Login
const login = await fetch(`${API}/api/auth/login`, {
method: "POST",
credentials: "include",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, password })
}).then(r => r.json());
// 2. List flows
const { items: flows } = await fetch(`${API}/api/flows`, {
credentials: "include"
}).then(r => r.json());
// 3. Run first flow
const run = await fetch(`${API}/api/workflows/${flows[0].id}/run`, {
method: "POST",
credentials: "include",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ input: {} })
}).then(r => r.json());
console.log("Run ID:", run.run_id);