MethodUse CaseHeaderAPI KeyServer-side, agents, SDKs, MCP toolsX-API-Key: ak_...Bearer JWTUser sessions, web appsAuthorization: Bearer <token>OAuth2Social login (LinkedIn, GitHub)Standard OAuth2 flow
Get a key via npx zerodb init or from the dashboard.
python
import requests
response = requests.get(
"https://api.ainative.studio/api/v1/public/credits/balance",
headers={"X-API-Key": "ak_your_key"}
)
typescript
const res = await fetch("https://api.ainative.studio/api/v1/public/credits/balance", {
headers: { "X-API-Key": "ak_your_key" }
});
python
# Register
resp = requests.post(
"https://api.ainative.studio/api/v1/auth/register",
json={"email": "user@example.com", "password": "securepass", "name": "Alice"}
)
token = resp.json()["access_token"]
# Login
resp = requests.post(
"https://api.ainative.studio/api/v1/auth/login",
json={"email": "user@example.com", "password": "securepass"}
)
access_token = resp.json()["access_token"]
refresh_token = resp.json()["refresh_token"]
python
headers = {"Authorization": f"Bearer {access_token}"}
me = requests.get("https://api.ainative.studio/api/v1/users/me", headers=headers).json()
python
resp = requests.post(
"https://api.ainative.studio/api/v1/auth/refresh",
json={"refresh_token": refresh_token}
)
new_access_token = resp.json()["access_token"]
python
requests.post(
"https://api.ainative.studio/api/v1/auth/logout",
headers={"Authorization": f"Bearer {access_token}"}
)
python
# LinkedIn
resp = requests.post(
"https://api.ainative.studio/api/v1/auth/linkedin/callback",
json={"code": oauth_code, "redirect_uri": "https://yourapp.com/callback"}
)
# GitHub
resp = requests.post(
"https://api.ainative.studio/api/v1/auth/github/callback",
json={"code": oauth_code, "redirect_uri": "https://yourapp.com/callback"}
)
token = resp.json()["access_token"]
typescript
// middleware.ts
import { createMiddleware } from '@ainative/next-sdk/middleware';
export const middleware = createMiddleware({
apiKey: process.env.AINATIVE_API_KEY!,
protectedPaths: ['/dashboard', '/api/protected'],
loginPath: '/login',
});
python
# Request reset email
requests.post("https://api.ainative.studio/api/v1/auth/forgot-password",
json={"email": "user@example.com"})
# Set new password with token from email
requests.post("https://api.ainative.studio/api/v1/auth/reset-password",
json={"token": "reset_token_from_email", "new_password": "newpassword"})
EndpointMethodDescription/api/v1/auth/registerPOSTCreate account/api/v1/auth/loginPOSTEmail/password → JWT/api/v1/auth/logoutPOSTInvalidate session/api/v1/auth/refreshPOSTRefresh access token/api/v1/users/meGETCurrent user profile/api/v1/auth/verify-emailPOSTVerify email address/api/v1/auth/forgot-passwordPOSTSend reset email/api/v1/auth/reset-passwordPOSTApply new password/api/v1/auth/linkedin/callbackPOSTLinkedIn OAuth2/api/v1/auth/github/callbackPOSTGitHub OAuth2
StatusMeaning401Invalid or missing token/key403Valid auth, insufficient permissions409Email already registered
src/backend/app/api/v1/endpoints/auth.py — Auth endpoint implementationpackages/sdks/nextjs/src/middleware/ — Next.js auth middlewaredocs/guides/AUTHENTICATION.md — Full authentication guide