Skip to main content

Groups API

Create and manage user groups and group memberships. Groups organize users into teams that can own projects and receive shared resources.

Create Group

Create a new group. The authenticated user becomes the group_owner automatically.

Request

POST /api/groups

Auth: requireAuth, buildAbilities

Content-Type: application/json

{
"name": "Research Team",
"description": "Video analysis research group",
"slug": "research-team"
}

Request Body

FieldTypeRequiredDescription
namestringYesGroup display name (minimum 1 character)
descriptionstringNoGroup description
slugstringYesURL-friendly identifier (lowercase alphanumeric and hyphens, pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$)

Response

Status: 201 Created

{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Research Team",
"description": "Video analysis research group",
"slug": "research-team",
"createdBy": "660e8400-e29b-41d4-a716-446655440001",
"createdAt": "2026-02-23T10:00:00.000Z",
"updatedAt": "2026-02-23T10:00:00.000Z",
"members": [
{
"id": "770e8400-e29b-41d4-a716-446655440002",
"userId": "660e8400-e29b-41d4-a716-446655440001",
"groupId": "550e8400-e29b-41d4-a716-446655440000",
"role": "group_owner",
"joinedAt": "2026-02-23T10:00:00.000Z",
"user": {
"id": "660e8400-e29b-41d4-a716-446655440001",
"username": "jdoe",
"displayName": "Jane Doe",
"email": "jdoe@example.com"
}
}
]
}

Status Codes

CodeDescription
201Group created
400Invalid request body
401Not authenticated
409Slug already exists

List Groups

List all groups the authenticated user belongs to.

Request

GET /api/groups

Auth: requireAuth

Response

Status: 200 OK

[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Research Team",
"description": "Video analysis research group",
"slug": "research-team",
"createdBy": "660e8400-e29b-41d4-a716-446655440001",
"createdAt": "2026-02-23T10:00:00.000Z",
"updatedAt": "2026-02-23T10:00:00.000Z",
"memberCount": 5,
"userRole": "group_owner"
}
]

Response Fields

FieldTypeDescription
memberCountnumberTotal number of members in the group
userRolestringThe authenticated user's role in the group

Status Codes

CodeDescription
200Groups listed
401Not authenticated

Get Group

Get details for a single group, including the full member list.

Request

GET /api/groups/:groupId

Auth: requireAuth

Parameters

ParameterTypeDescription
groupIdUUIDGroup identifier

Response

Status: 200 OK

Returns the group object with a members array. Each member includes the associated user's id, username, displayName, and email.

Status Codes

CodeDescription
200Group returned
401Not authenticated
403Not a member of the group
404Group not found

Update Group

Update a group's name or description. Requires group_admin or group_owner role.

Request

PUT /api/groups/:groupId

Auth: requireAuth, buildAbilities

Content-Type: application/json

{
"name": "Updated Team Name",
"description": "Updated description"
}

Parameters

ParameterTypeDescription
groupIdUUIDGroup identifier

Request Body

FieldTypeRequiredDescription
namestringNoNew group name (minimum 1 character)
descriptionstringNoNew description

Response

Status: 200 OK

Returns the updated group object with members.

Status Codes

CodeDescription
200Group updated
400Invalid request body
401Not authenticated
403Insufficient role (requires group_admin or group_owner)
404Group not found

Delete Group

Delete a group and cascade-delete all memberships. Requires group_owner role or system_admin.

Request

DELETE /api/groups/:groupId

Auth: requireAuth, buildAbilities

Parameters

ParameterTypeDescription
groupIdUUIDGroup identifier

Response

Status: 200 OK

{
"success": true
}

Status Codes

CodeDescription
200Group deleted
401Not authenticated
403Not the group owner or system admin
404Group not found

Add Member

Add a user to a group. Requires group_admin or group_owner role.

Request

POST /api/groups/:groupId/members

Auth: requireAuth, buildAbilities

Content-Type: application/json

{
"userId": "880e8400-e29b-41d4-a716-446655440003",
"role": "group_member"
}

Parameters

ParameterTypeDescription
groupIdUUIDGroup identifier

Request Body

FieldTypeRequiredDescription
userIdUUIDYesID of the user to add
rolestringYesOne of: group_admin, group_member

Response

Status: 201 Created

Returns the created membership object with user details.

Status Codes

CodeDescription
201Member added
400Invalid request body
401Not authenticated
403Insufficient role
404Group or user not found
409User is already a member

List Members

List all members of a group. Requires group membership.

Request

GET /api/groups/:groupId/members

Auth: requireAuth

Parameters

ParameterTypeDescription
groupIdUUIDGroup identifier

Response

Status: 200 OK

[
{
"id": "770e8400-e29b-41d4-a716-446655440002",
"userId": "660e8400-e29b-41d4-a716-446655440001",
"groupId": "550e8400-e29b-41d4-a716-446655440000",
"role": "group_owner",
"joinedAt": "2026-02-23T10:00:00.000Z",
"user": {
"id": "660e8400-e29b-41d4-a716-446655440001",
"username": "jdoe",
"displayName": "Jane Doe",
"email": "jdoe@example.com"
}
}
]

Status Codes

CodeDescription
200Members listed
401Not authenticated
403Not a member of the group
404Group not found

Change Member Role

Change a member's role within a group. Requires group_admin or group_owner role. Cannot change the role of a group_owner.

Request

PUT /api/groups/:groupId/members/:userId

Auth: requireAuth, buildAbilities

Content-Type: application/json

{
"role": "group_admin"
}

Parameters

ParameterTypeDescription
groupIdUUIDGroup identifier
userIdUUIDID of the member to update

Request Body

FieldTypeRequiredDescription
rolestringYesOne of: group_admin, group_member

Response

Status: 200 OK

Returns the updated membership object with user details.

Status Codes

CodeDescription
200Role updated
400Invalid role
401Not authenticated
403Insufficient role, or target is a group_owner
404Membership not found

Remove Member

Remove a member from a group. Requires group_admin or group_owner role, unless the member is removing themselves. Cannot remove the last group_owner.

Request

DELETE /api/groups/:groupId/members/:userId

Auth: requireAuth, buildAbilities

Parameters

ParameterTypeDescription
groupIdUUIDGroup identifier
userIdUUIDID of the member to remove

Response

Status: 200 OK

{
"success": true
}

Status Codes

CodeDescription
200Member removed
400Cannot remove last group_owner
401Not authenticated
403Insufficient role
404Membership not found

Admin: List All Groups

List all groups in the system. Requires system_admin role.

Request

GET /api/admin/groups

Auth: requireAdmin

Response

Status: 200 OK

[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Research Team",
"description": "Video analysis research group",
"slug": "research-team",
"createdBy": "660e8400-e29b-41d4-a716-446655440001",
"createdAt": "2026-02-23T10:00:00.000Z",
"updatedAt": "2026-02-23T10:00:00.000Z",
"_count": {
"members": 5
}
}
]

Status Codes

CodeDescription
200Groups listed
401Not authenticated
403Not a system admin

Admin: Create Group

Create a group on behalf of any user. The specified user becomes the group_owner. Requires system_admin role.

Request

POST /api/admin/groups

Auth: requireAdmin

Content-Type: application/json

{
"name": "New Team",
"description": "Created by admin",
"slug": "new-team",
"createdBy": "660e8400-e29b-41d4-a716-446655440001"
}

Request Body

FieldTypeRequiredDescription
namestringYesGroup name
descriptionstringNoGroup description
slugstringYesURL-friendly identifier
createdByUUIDYesUser ID who becomes the group_owner

Response

Status: 201 Created

Returns the created group with members.

Status Codes

CodeDescription
201Group created
400Invalid request body
401Not authenticated
403Not a system admin
404Creator user not found
409Slug already exists

Admin: Update Group

Update any group. Requires system_admin role.

Request

PUT /api/admin/groups/:groupId

Auth: requireAdmin

Content-Type: application/json

{
"name": "Updated Name"
}

Parameters

ParameterTypeDescription
groupIdUUIDGroup identifier

Request Body

FieldTypeRequiredDescription
namestringNoNew group name
descriptionstringNoNew description

Response

Status: 200 OK

Returns the updated group with members.

Status Codes

CodeDescription
200Group updated
400Invalid request body
401Not authenticated
403Not a system admin
404Group not found

Admin: Delete Group

Delete any group. Requires system_admin role.

Request

DELETE /api/admin/groups/:groupId

Auth: requireAdmin

Parameters

ParameterTypeDescription
groupIdUUIDGroup identifier

Response

Status: 200 OK

{
"success": true
}

Status Codes

CodeDescription
200Group deleted
401Not authenticated
403Not a system admin
404Group not found

Admin: Add Member to Group

Add any user to any group with any role, including group_owner. Requires system_admin role.

Request

POST /api/admin/groups/:groupId/members

Auth: requireAdmin

Content-Type: application/json

{
"userId": "880e8400-e29b-41d4-a716-446655440003",
"role": "group_owner"
}

Parameters

ParameterTypeDescription
groupIdUUIDGroup identifier

Request Body

FieldTypeRequiredDescription
userIdUUIDYesID of the user to add
rolestringYesOne of: group_owner, group_admin, group_member

Response

Status: 201 Created

Returns the created membership object with user details.

Status Codes

CodeDescription
201Member added
400Invalid request body
401Not authenticated
403Not a system admin
404Group or user not found
409User is already a member