Groups API Documentation

Table of Contents

Get All Groups

Retrieves all groups.

Endpoint: GET /all

Response:

  • 200 OK

json

{ "groups": [ { "id": "string", "name": "string", "createdAt": "timestamp", "updatedAt": "timestamp" } ] }
  • 401 Unauthorized: Invalid token
  • 500 Internal Server Error: Server error

Get Specific Group

Retrieves details of a specific group.

Endpoint: GET /get/:id

Parameters:

  • id (path parameter): Group ID

Response:

  • 200 OK

json

{ "groupData": { "data": { "group": { "id": "string", "name": "string", "createdAt": "timestamp", "updatedAt": "timestamp" }, "users": [ { "id": "string", "name": "string", "email": "string", "status": "string", "isDriver": boolean, "roles": [ { "role": "string", "userId": "string", "groupId": "string" } ] } ] } } }
  • 404 Not Found: Group not found
  • 500 Internal Server Error: Server error

Create Group

Creates a new group.

Endpoint: POST /create

Request Body:

json

{ "name": "string", "userId": "string" }

Response:

  • 201 Created

json

{ "message": "group created successfully", "group": { "id": "string", "name": "string", "creator": { "userId": "string", "groupId": "string", "roles": [ { "role": "owner", "userId": "string", "groupId": "string" } ] } } }
  • 400 Bad Request: Validation error
  • 500 Internal Server Error: Server error

Add User to Group

Adds a user to an existing group.

Endpoint: POST /add

Request Body:

json

{ "userId": "string", "groupId": "string" }

Response:

  • 201 Created

json

{ "message": "User added successfully", "groupUser": { "userId": "string", "groupId": "string", "roles": [ { "role": "member", "userId": "string", "groupId": "string" } ] } }
  • 400 Bad Request: Validation error
  • 500 Internal Server Error: Server error

Delete Group

Deletes a group.

Endpoint: POST /delete

Request Body:

json

{ "userId": "string", "groupId": "string" }

Response:

  • 200 OK

json

{ "message": "Group with ID {groupId} has been successfully deleted." }
  • 400 Bad Request: Validation error
  • 500 Internal Server Error: Server error

Leave Group

Allows a user to leave a group.

Endpoint: POST /leave

Request Body:

json

{ "userId": "string", "groupId": "string" }

Response:

  • 200 OK

json

{ "message": "User with ID {userId} has successfully left the group with ID {groupId}." }
  • 400 Bad Request: Validation error
  • 500 Internal Server Error: Server error

Create Invite Code

Creates an invite code for a group.

Endpoint: POST /invite/create

Request Body:

json

{ "groupId": "string", "userId": "string", "maxUses": number, "expiresInSeconds": number }

Response:

  • 201 Created

json

{ "code": "string" }
  • 500 Internal Server Error: Server error

Join Group with Code

Joins a group using an invite code.

Endpoint: POST /invite/join

Request Body:

json

{ "code": "string", "userId": "string" }

Response:

  • 200 OK

json

{ "message": "Successfully joined group", "groupId": "string" }
  • 500 Internal Server Error: Server error

Update Member Role

Updates a member's role in a group.

Endpoint: POST /member/role

Request Body:

json

{ "userId": "string", "groupId": "string", "role": "string" }

Response:

  • 200 OK

json

{ "message": "Role updated successfully" }
  • 400 Bad Request: Validation error
  • 500 Internal Server Error: Server error

Update Driver Status

Updates a member's driver status in a group.

Endpoint: POST /member/driver

Request Body:

json

{ "userId": "string", "groupId": "string", "isDriver": boolean }

Response:

  • 200 OK

json

{ "message": "Driver status updated successfully" }
  • 400 Bad Request: Validation error
  • 500 Internal Server Error: Server error

Rename Group

Renames a group.

Endpoint: POST /rename

Request Body:

json

{ "userId": "string", "groupId": "string", "name": "string" }

Response:

  • 200 OK

json

{ "message": "Group renamed successfully", "group": { "id": "string", "name": "string" } }
  • 400 Bad Request: Validation error
  • 500 Internal Server Error: Server error

Get Group Settings

Retrieves settings for a specific group.

Endpoint: GET /:groupId/settings

Parameters:

  • groupId (path parameter): Group ID

Response:

  • 200 OK

json

{ "settings": { "require_join_approval": boolean, "members_can_invite": boolean, "allow_volunteer_drivers": boolean, "auto_assign_drivers": boolean, "member_updates": boolean, "driver_updates": boolean, "event_reminders": boolean, "location_sharing": boolean, "group_chat": boolean, "group_visibility": boolean } }
  • 500 Internal Server Error: Server error

Update Group Settings

Updates settings for a specific group.

Endpoint: PATCH /:groupId/settings

Parameters:

  • groupId (path parameter): Group ID

Request Body:

json

{ "require_join_approval": boolean, "members_can_invite": boolean, "allow_volunteer_drivers": boolean, "auto_assign_drivers": boolean, "member_updates": boolean, "driver_updates": boolean, "event_reminders": boolean, "location_sharing": boolean, "group_chat": boolean, "group_visibility": boolean }

Response:

  • 200 OK

json

{ "settings": { "require_join_approval": boolean, "members_can_invite": boolean, "allow_volunteer_drivers": boolean, "auto_assign_drivers": boolean, "member_updates": boolean, "driver_updates": boolean, "event_reminders": boolean, "location_sharing": boolean, "group_chat": boolean, "group_visibility": boolean } }
  • 400 Bad Request: Invalid updates
  • 500 Internal Server Error: Server error

Update Member Status

Updates a member's status in a group.

Endpoint: POST /member/status

Request Body:

json

{ "userId": "string", "groupId": "string", "status": "Available" | "Busy" | "Not Available" }

Response:

  • 200 OK

json

{ "message": "User status updated successfully", "user": { "userId": "string", "groupId": "string", "status": "string" } }
  • 400 Bad Request: Validation error
  • 500 Internal Server Error: Server error

Transfer Ownership

Transfers group ownership to another member.

Endpoint: POST /transfer-ownership

Request Body:

json

{ "userId": "string", "newOwnerId": "string", "groupId": "string" }

Response:

  • 200 OK

json

{ "message": "Ownership transferred successfully", "newOwnerId": "string", "previousOwnerId": "string" }
  • 400 Bad Request: Missing required parameters
  • 500 Internal Server Error: Server error