id string required
Unique user-department relationship identifier. Format: udept_ followed by 12 alphanumeric characters.
user_id string required
Reference to the User assigned to the department.
department_id string required
Reference to the Department the user belongs to.
organization_id string required
Reference to the Organization (for query optimization and data integrity).
assigned_by string | null optional
Reference to the User who assigned this user to the department.
role string | null optional
Role within the department (e.g., member, lead, manager). This is separate from organization-level roles.
assigned_at string required
Timestamp when the user was assigned to the department. Format: ISO 8601 datetime string.
- A user can only be assigned to a department once (unique constraint on
user_id+department_id) - Users must be members of the organization before being assigned to departments
- Department assignments are automatically removed when users leave the organization
UserDepartment relationships enable:
- Multi-department membership: Users can work across multiple teams
- Department-specific roles: Different responsibilities in different departments
- Access control: Grant permissions based on department membership
- Team analytics: Track department composition and changes over time
Department Member
{
"id": "udept_a1b2c3d4e5f6",
"user_id": "uid_john_doe_123456",
"department_id": "dep_eng_abc123456",
"organization_id": "ORG_A1B2C3D4E5F6G7H8",
"assigned_by": "uid_admin_user_789",
"role": "member",
"assigned_at": "2025-01-10T09:00:00Z"
}Department Lead
{
"id": "udept_b2c3d4e5f6g7",
"user_id": "uid_jane_smith_789012",
"department_id": "dep_eng_abc123456",
"organization_id": "ORG_A1B2C3D4E5F6G7H8",
"assigned_by": "uid_cto_user_456",
"role": "lead",
"assigned_at": "2025-01-10T09:00:00Z"
}Multi-department Assignment
[
{
"id": "udept_c3d4e5f6g7h8",
"user_id": "uid_alex_dev_345678",
"department_id": "dep_eng_abc123456",
"organization_id": "ORG_A1B2C3D4E5F6G7H8",
"assigned_by": "uid_admin_user_789",
"role": "member",
"assigned_at": "2025-01-10T09:00:00Z"
},
{
"id": "udept_d4e5f6g7h8i9",
"user_id": "uid_alex_dev_345678",
"department_id": "dep_ds_xyz789012",
"organization_id": "ORG_A1B2C3D4E5F6G7H8",
"assigned_by": "uid_admin_user_789",
"role": "member",
"assigned_at": "2025-01-12T14:30:00Z"
}
]