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']}")
# In ReZEN, the user ID is the agent ID used for owner-agent setup.
agent_id = client.users.get_agent_id_for_current_user()
print(f"Agent ID: {agent_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:
Show table
| 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:
Show table
| 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:
Show table
| Name | Type | Description | Default |
|---|---|---|---|
user_id | str | UUID of the user to retrieve | required |
Returns:
Show table
| Type | Description |
|---|---|
Dict[str, Any] | Dictionary containing user's agent information |
Raises:
Show table
| 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:
Show table
| Name | Type | Description | Default |
|---|---|---|---|
yenta_ids | Union[str, List[str]] | A single Yenta user ID (UUID) or a list of Yenta user IDs. | required |
Returns:
Show table
| Type | Description |
|---|---|
List[str] | List of Keymaker user IDs corresponding to the provided Yenta IDs. |
Raises:
Show table
| Type | Description |
|---|---|
ValidationError | If yenta_ids is empty or invalid |
RezenError | If the API request fails |
ValueError | If the API response payload is not recognized. |
Agent ID for Transactions
For owner-agent operations in transactions, you typically do not need to call get_keymaker_ids(). In ReZEN, the authenticated user's id is the agent ID used in owner-agent payloads.
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: In ReZEN, user ID = agent ID for owner-agent payloads
agent_id: str = str(user['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 IDs Response¶
get_keymaker_ids() returns a list of UUID strings:
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()
agent_id: str = str(user["id"])
owner_info = {
"agent_id": agent_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)
# In ReZEN, a user's ID is the agent ID used in transaction payloads.
agent_id = str(member["id"])
print(f"Team member: {member['firstName']} {member['lastName']}")
print(f"Agent ID: {agent_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}")
# If you need Keymaker IDs for other systems, `get_keymaker_ids()` returns a list:
# keymaker_ids = client.users.get_keymaker_ids(user_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¶
-
Use user data to set up owner agents in transactions
-
Access more detailed team information
-
Search for agents beyond current user