# UserDepartment object div strong 🔨 In Development — This section is still being developed and may change. The UserDepartment object represents the many-to-many relationship between users and departments within an organization. Users can belong to multiple departments, and departments can have multiple users. ## Properties ### Identity **`id`** string required Unique user-department relationship identifier. Format: `udept_` followed by 12 alphanumeric characters. ### Relationships **`user_id`** string required Reference to the [User](/docs/api-reference/objects/user-object) assigned to the department. **`department_id`** string required Reference to the [Department](/docs/api-reference/objects/department-object) the user belongs to. **`organization_id`** string required Reference to the [Organization](/docs/api-reference/objects/organization-object) (for query optimization and data integrity). **`assigned_by`** string | null optional Reference to the [User](/docs/api-reference/objects/user-object) who assigned this user to the department. ### Assignment Details **`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. ## Constraints - 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 ## Usage 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** ```json { "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** ```json { "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** ```json [ { "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" } ] ```