Skip to content

Authentication

The API supports two authentication methods: API keys for programmatic access and JWT tokens for browser-based applications.

API keys are the recommended method for server-to-server integrations.

X-API-Key: idx_a1b2c3d4e5f6g7h8i9j0

API keys can be created by administrators through the admin panel or API endpoint. See the Managing API Keys guide for instructions.

For browser applications, use Keycloak OIDC tokens:

Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

The token is validated against the Keycloak public key. User roles and brokerage assignments are extracted from token claims.

Full system access

  • Manage all brokerages and agents
  • Create/revoke API keys
  • Access data management tools
  • Configure system settings
  • View all leads and tours

Check if your credentials are valid and get user information.

GET /api/auth/verify

Response:

{
"valid": true,
"user": {
"id": 123,
"email": "agent@example.com",
"role": "agent",
"brokerage_id": 1,
"agent_id": 45
}
}

Get detailed information about the authenticated user.

GET /api/admin/me

Response:

{
"authenticated": true,
"user": {
"id": 123,
"email": "broker@example.com",
"role": "broker",
"brokerage_id": 1,
"broker_id": 12,
"agent_id": null
}
}

Verify admin role is granted.

GET /api/admin/admin-test

Response (admin):

{
"message": "You have admin access!",
"user_email": "admin@example.com",
"user_role": "admin"
}

Response (non-admin):

{
"detail": "Admin role required"
}

Status: 403 Forbidden

Verify broker or admin role is granted.

GET /api/admin/broker-test

Response:

{
"message": "You have broker access!",
"user_email": "broker@example.com",
"user_role": "broker",
"brokerage_id": 1,
"broker_id": 12
}

Some endpoints don’t require authentication:

  • GET /health — Health check
  • GET /api/properties — List properties
  • GET /api/public/* — Public brokerage/agent info
  • POST /api/contact — Submit contact form
  • POST /api/newsletter/subscribe — Newsletter signup
  • POST /api/tours — Request a tour
{
"detail": "Not authenticated"
}

Status: 401 Unauthorized

{
"detail": "Invalid API key"
}

Status: 401 Unauthorized

{
"detail": "Admin role required"
}

Status: 403 Forbidden

{
"detail": "Token has expired"
}

Status: 401 Unauthorized