Skip to content

Authentication

The API uses session-based authentication via Better Auth.

POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "your-password"
}
{
"user": {
"id": "user_abc123",
"email": "user@example.com",
"name": "Your Name"
},
"session": {
"id": "session_xyz789",
"expiresAt": "2026-03-01T00:00:00Z"
}
}

The response includes Set-Cookie headers. Store and send these with subsequent requests.

POST /api/auth/logout

Invalidates the current session.

GET /api/auth/session

Returns current user if authenticated.

Include cookies in requests:

// JavaScript fetch
const response = await fetch('/api/admin/products', {
credentials: 'include' // Include cookies
});
Terminal window
# cURL with cookies
curl -b cookies.txt https://pintas.turbospark.my/api/admin/products

Auth endpoints are rate limited:

EndpointLimit
/api/auth/login5 attempts per 15 min
/api/auth/signup3 attempts per hour
/api/auth/forgot-password3 per hour

After limit exceeded:

{
"error": "Too many requests. Please try again later."
}
  1. Use HTTPS - Always
  2. Don’t share tokens - Keep credentials secure
  3. Logout when done - Invalidate sessions
  4. Monitor for breaches - Check for unauthorized access