Authentication
How to authenticate with the BlueAI API.
|
Overview
The BlueAI API uses session-based authentication compatible with Better Auth. After signing in, include the session cookie in all requests.
Session Cookie
After a successful sign-in via POST /api/v1/auth/sign-in/email, the API sets a better-auth.session_token cookie.
# Sign in
curl -X POST https://api.blueai.jp/api/v1/auth/sign-in/email \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"secret"}' \
-c cookies.txt
# Use the session cookie
curl https://api.blueai.jp/api/v1/me \
-b cookies.txtBrowser Requests
From browser JavaScript, include credentials: "include" in your fetch calls to automatically send the session cookie.
const res = await fetch("https://api.blueai.jp/api/v1/me", {
credentials: "include",
});
const data = await res.json();Organization Context
Most API endpoints operate within an organization context. The user's current organization is determined from the session. To switch organizations, use the organization selection endpoints.