Skip to main content

Admin Login

Authenticates an administrator with email and password credentials. This endpoint verifies that the user has admin privileges before granting access.

Authentication

No authentication required.

Request Body

email
string
required
Administrator’s email address
password
string
required
Administrator’s password

Response

message
string
Success message
user
object
Authenticated admin user information
session
object
Supabase authentication session

Error Responses

error
string
Error message
Status Codes:
  • 401 - Unauthorized (invalid credentials)
  • 403 - Forbidden (user does not have admin privileges)
  • 404 - User not found in database
  • 500 - Internal server error

Example Request

curl -X POST https://api.vaniyk.com/api/auth/admin/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "admin@vaniyk.com",
    "password": "adminSecurePass456"
  }'

Example Success Response

{
  "message": "Admin login successful",
  "user": {
    "id": "507f1f77bcf86cd799439012",
    "email": "admin@vaniyk.com",
    "name": "Jane Admin",
    "role": "admin"
  },
  "session": {
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refresh_token": "v1.MRjoP7GqRGKK9Sh91...",
    "expires_in": 3600,
    "user": {
      "id": "d2f3a8b9-1c4e-5f6g-7h8i-9j0k1l2m3n4o",
      "email": "admin@vaniyk.com",
      "aud": "authenticated",
      "role": "authenticated"
    }
  }
}

Example Error Response (Non-Admin User)

{
  "error": "Access denied. Admin privileges required."
}

Usage Notes

  • This endpoint should be used exclusively for admin authentication flows
  • Authentication credentials are verified first, then admin role is checked
  • If a regular user tries to login through this endpoint, they will receive a 403 error even with valid credentials
  • Store the access_token securely and include it in the Authorization header for subsequent admin API requests
  • The token allows access to admin-protected endpoints throughout the API

Build docs developers (and LLMs) love