Skip to main content

Getting a token

Authenticate by posting your credentials to the /auth/login endpoint:
curl -X POST https://safua.ai/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "password": "yourpassword"}'
Response:
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "bearer",
  "expires_in": 3600
}

Using your token

Include the token in the Authorization header on every request:
curl https://safua.ai/api/v1/users/me \
  -H "Authorization: Bearer YOUR_TOKEN"

Token expiry and refresh

Access tokens expire after 1 hour. Refresh using:
curl -X POST https://safua.ai/api/v1/auth/refresh \
  -H "Authorization: Bearer YOUR_EXPIRED_TOKEN"

Register a new account

curl -X POST https://safua.ai/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "you@example.com",
    "password": "securepassword",
    "full_name": "Your Name"
  }'
Never expose your token in client-side code or commit it to version control.