Users API¶
Access user information, team membership, and office details.
Overview¶
Users API Features
- Current User Info: Get authenticated user's profile and details
- User Lookup: Find users by ID
- Team Information: Access user's team and office membership
- Keymaker IDs: Retrieve associated agent IDs for users
- Office Details: Get user's office information
New API Addition
The Users API was added to support owner agent functionality in transactions.
Quick Start¶
from rezen import RezenClient
client = RezenClient()
# Get current authenticated user
current_user = client.users.get_current_user()
print(f"User: {current_user['firstName']} {current_user['lastName']}")
print(f"Team ID: {current_user['team']['id']}")
print(f"Office ID: {current_user['office']['id']}")
# Get keymaker IDs for transaction owner setup
keymaker_ids = client.users.get_keymaker_ids(current_user['id'])
print(f"Agent ID: {keymaker_ids['id']}")
Core Methods¶
Get Current User¶
Get current authenticated user information from Yenta.
This returns more detailed user information than the keymaker endpoint, including team and office details.
Returns:
Type | Description |
---|---|
Dict[str, Any] | Dictionary containing current user's agent information including: |
Dict[str, Any] |
|
Dict[str, Any] |
|
Dict[str, Any] |
|
Dict[str, Any] |
|
Dict[str, Any] |
|
Raises:
Type | Description |
---|---|
AuthenticationError | If not authenticated |
RezenError | If the API request fails |
Current User Information
from typing import Dict, Any
from rezen import RezenClient
client: RezenClient = RezenClient()
# Get current authenticated user details
user: Dict[str, Any] = client.users.get_current_user()
print(f"Name: {user['firstName']} {user['lastName']}")
print(f"Email: {user['email']}")
print(f"User ID: {user['id']}")
# Access team information
if 'team' in user:
print(f"Team: {user['team']['name']}")
print(f"Team ID: {user['team']['id']}")
# Access office information
if 'office' in user:
print(f"Office: {user['office']['name']}")
print(f"Office ID: {user['office']['id']}")
Get User by ID¶
Get user information by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id | str | UUID of the user to retrieve | required |
Returns:
Type | Description |
---|---|
Dict[str, Any] | Dictionary containing user's agent information |
Raises:
Type | Description |
---|---|
NotFoundError | If user not found |
RezenError | If the API request fails |
Get Keymaker IDs¶
Get keymaker IDs for the given Yenta IDs.
Note: For owner agent setup in transactions, you typically don't need this method. The user ID from get_current_user() can be used directly as the agent ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
yenta_ids | List[str] | List of Yenta user IDs (UUIDs) | required |
Returns:
Type | Description |
---|---|
Dict[str, Any] | Dictionary containing keymaker IDs or list of keymaker IDs |
Raises:
Type | Description |
---|---|
ValidationError | If yenta_ids is empty or invalid |
RezenError | If the API request fails |
Agent ID for Transactions
The get_keymaker_ids()
method returns the agent ID needed for owner agent operations in transactions.
Working with Owner Agents¶
Owner Agent Integration
The Users API is essential for setting up owner agents in transactions. Here's the complete workflow:
Get Required IDs for Owner Agent¶
from typing import Dict, Any
from rezen import RezenClient
client: RezenClient = RezenClient()
# Step 1: Get current user info
user: Dict[str, Any] = client.users.get_current_user()
team_id: str = user['team']['id']
office_id: str = user['office']['id']
# Step 2: Get agent ID from keymaker
keymaker: Dict[str, Any] = client.users.get_keymaker_ids(user['id'])
agent_id: str = keymaker['id']
# Step 3: Use in transaction owner agent setup
owner_data: Dict[str, Any] = {
"ownerAgent": {
"agentId": agent_id,
"role": "BUYERS_AGENT" # or "SELLERS_AGENT"
},
"officeId": office_id,
"teamId": team_id
}
# Apply to transaction (after required setup steps)
client.transaction_builder.update_owner_agent_info(builder_id, owner_data)
Convenience Method¶
Simplified Approach
The Transaction Builder provides a convenience method that handles all the Users API calls for you:
# Instead of manual steps above, use:
client.transaction_builder.set_current_user_as_owner_agent(
builder_id,
role="BUYERS_AGENT"
)
Response Structures¶
User Object¶
{
"id": "user-uuid",
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"phone": "+1234567890",
"team": {
"id": "team-uuid",
"name": "Team Excellence",
"status": "ACTIVE"
},
"office": {
"id": "office-uuid",
"name": "Main Office",
"address": "123 Main St",
"city": "Salt Lake City",
"state": "UT"
},
"role": "AGENT",
"status": "ACTIVE"
}
Keymaker Response¶
{
"id": "agent-uuid", # This is the agent ID for transactions
"userId": "user-uuid",
"agentStatus": "ACTIVE",
"licenseNumber": "123456",
"licenseState": "UT"
}
Common Use Cases¶
User Information Workflows
from typing import Dict, Any
from rezen import RezenClient
client: RezenClient = RezenClient()
# Get all required info for owner agent
user: Dict[str, Any] = client.users.get_current_user()
keymaker: Dict[str, Any] = client.users.get_keymaker_ids(user['id'])
owner_info = {
"agent_id": keymaker['id'],
"team_id": user['team']['id'],
"office_id": user['office']['id'],
"user_name": f"{user['firstName']} {user['lastName']}"
}
print("Owner agent info collected:")
print(f" Agent: {owner_info['user_name']}")
print(f" Agent ID: {owner_info['agent_id']}")
print(f" Team ID: {owner_info['team_id']}")
print(f" Office ID: {owner_info['office_id']}")
# Get team member details
team_member_id = "member-user-uuid"
member = client.users.get_user_by_id(team_member_id)
# Get their agent ID if needed
member_keymaker = client.users.get_keymaker_ids(team_member_id)
print(f"Team member: {member['firstName']} {member['lastName']}")
print(f"Agent ID: {member_keymaker['id']}")
Error Handling¶
Common Errors
from rezen import RezenClient
from rezen.exceptions import NotFoundError, UnauthorizedError
client = RezenClient()
try:
user = client.users.get_current_user()
except UnauthorizedError:
print("Invalid or missing API key")
except Exception as e:
print(f"Error getting user info: {e}")
# Handle missing keymaker data
try:
keymaker = client.users.get_keymaker_ids(user_id)
except NotFoundError:
print("User does not have associated agent ID")
Integration with Transaction Builder¶
Critical Sequence for Owner Agents
When using Users API data for owner agents, you MUST follow this sequence:
- Create transaction (
create_transaction_builder
) - Add location info (
update_location_info
) - Add price/date info (
update_price_and_date_info
) - Add buyers/sellers (
add_buyer
/add_seller
) - THEN add owner agent using Users API data
See Transaction Builder - Owner Agents for complete details.
Next Steps¶
-
:material-hammer-wrench: Transaction Builder
Use user data to set up owner agents in transactions
-
:material-account-group: Teams API
Access more detailed team information
-
:material-account-tie: Agents API
Search for agents beyond current user