Skip to content
Last updated

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 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.

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