Skip to content

Agents API

The Agents API provides endpoints for listing, creating, and managing real estate agent profiles.

Get a paginated list of agents.

GET /api/admin/agents
Auth Required
ParameterTypeDescription
pageintegerPage number (default: 1)
page_sizeintegerItems per page (default: 20, max: 100)
brokerage_idintegerFilter by brokerage
statusstringFilter by status (active, inactive)
searchstringSearch by name or email
Terminal window
curl -H "X-API-Key: idx_your_key" \
"https://api.your-domain.com/api/admin/agents?brokerage_id=1&status=active"
{
"items": [
{
"id": 45,
"broker_id": 1,
"name": "Jane Smith",
"slug": "jane-smith",
"email": "jane@example.com",
"phone": "208-555-0123",
"bio": "Specializing in residential properties...",
"photo_url": "/uploads/agents/jane-smith.jpg",
"status": "active",
"created_at": "2024-01-15T10:30:00Z"
}
],
"total": 25,
"page": 1,
"page_size": 20,
"total_pages": 2
}

Retrieve a specific agent’s details.

GET /api/admin/agents/{agent_id}
Auth Required
ParameterTypeDescription
agent_idintegerAgent’s unique ID
{
"id": 45,
"broker_id": 1,
"brokerage": {
"id": 1,
"name": "Sample Realty Co.",
"slug": "sample-realty"
},
"name": "Jane Smith",
"slug": "jane-smith",
"email": "jane@example.com",
"phone": "208-555-0123",
"bio": "With over 10 years of experience in the Magic Valley...",
"photo_url": "/uploads/agents/jane-smith.jpg",
"status": "active",
"specialties": ["Residential", "First-Time Buyers", "Relocation"],
"social_links": {
"facebook": "https://facebook.com/janesmith",
"instagram": "https://instagram.com/janesmithrealty"
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-12-20T14:22:00Z"
}

Create a new agent profile.

POST /api/admin/agents
Broker/Admin Only
{
"brokerage_id": 1,
"name": "John Doe",
"slug": "john-doe",
"email": "john@example.com",
"phone": "208-555-0456",
"bio": "New agent specializing in...",
"status": "active"
}
FieldTypeRequiredDescription
brokerage_idintegerYesParent brokerage ID
namestringYesAgent’s full name
slugstringYesURL-friendly identifier
emailstringYesContact email
phonestringNoContact phone
biostringNoAgent biography
statusstringNoactive or inactive (default: active)
{
"id": 46,
"broker_id": 1,
"name": "John Doe",
"slug": "john-doe",
"email": "john@example.com",
"status": "active",
"created_at": "2024-12-28T10:00:00Z"
}

Update an existing agent’s profile.

PUT /api/admin/agents/{agent_id}
Broker/Admin Only
{
"bio": "Updated biography text...",
"phone": "208-555-9999",
"status": "active"
}

All fields are optional. Only provided fields are updated.

Returns the updated agent object.

Soft-delete an agent (sets disabled_at).

DELETE /api/admin/agents/{agent_id}
Admin Only
{
"message": "Agent deleted successfully",
"id": 46
}

Semantic search for agents by expertise and bio.

GET /api/admin/search/agents?q=first+time+buyers
Auth Required
ParameterTypeDescription
qstringSearch query
limitintegerMax results (default: 10)
{
"query": "first time buyers",
"results": [
{
"id": 45,
"name": "Jane Smith",
"brokerage": "Sample Realty Co.",
"bio": "Specializing in helping first-time buyers...",
"similarity": 0.87
}
],
"total": 5
}

These endpoints are publicly accessible without authentication.

GET /api/public/agents
ParameterTypeDescription
brokerage_idintegerFilter by brokerage
GET /api/public/agents/{slug}

Returns public-facing agent information suitable for website display.

Upload and optimize an agent’s profile photo.

POST /api/upload/agent-photo
Auth Required

Multipart form data:

FieldTypeDescription
filefileImage file (JPEG, PNG, WebP)
agent_idintegerAgent to update
{
"success": true,
"photo_url": "/uploads/agents/jane-smith.jpg",
"thumbnail_url": "/uploads/agents/jane-smith-thumb.jpg"
}
{
"detail": "Agent not found"
}

Status: 404 Not Found

{
"detail": "Agent with slug 'john-doe' already exists"
}

Status: 400 Bad Request

{
"detail": "Cannot create agent for another brokerage"
}

Status: 403 Forbidden