Skip to main content

Create or Update Group

This endpoint allows you to create a new group or update an existing group's information.

Endpoint Details

  • URL: /api/group
  • Method: POST
  • Authentication: Required (creator role)

Request Parameters

Request Body

ParameterTypeRequiredDescription
idintegerNoGroup ID (include to update an existing group, omit to create a new one)
namestringYesName of the group
descriptionstringNoDescription of the group
visibilitystringYesPrivacy setting of the group (public, private, hidden)
coverImagestringNoFilename of the group's cover image
purchaseLinkstringNoOptional link for purchasing access to the group
adminIdsarrayNoArray of user IDs to be assigned as group admins

Example Request

{
"name": "New Group",
"description": "This is a description of the new group",
"visibility": "private",
"adminIds": [23, 25]
}

Response

Success Response

  • Code: 200 OK
  • Content: The created or updated group object

Example Response

{
"id": 135,
"name": "New Group",
"description": "This is a description of the new group",
"slug": "new-group",
"visibility": "private",
"purchaseLink": null,
"createdAt": "2022-05-18T10:30:45.000Z",
"updatedAt": "2022-05-18T10:30:45.000Z",
"PlatformId": 36,
"groupCreatorId": 9846
}

Error Response

  • Code: 400 Bad Request
  • Content: { error: "Error message" }

Notes

  • When updating a group, only include the fields you want to change.
  • The adminIds array will replace all existing admins with the new list.
  • The group slug is automatically generated from the name.
  • Only users with creator privileges can create or update groups.

Code Examples

JavaScript

const createOrUpdateGroup = async groupData => {
try {
const response = await fetch("https://api.tribesocial.io/api/group", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_TOKEN_HERE",
"Content-Type": "application/json"
},
body: JSON.stringify(groupData)
});

if (!response.ok) {
throw new Error("Failed to create/update group");
}

const group = await response.json();
return group;
} catch (error) {
console.error("Error creating/updating group:", error);
throw error;
}
};

// Example usage for creating a new group
const newGroup = {
name: "New Group",
description: "This is a description of the new group",
visibility: "private",
adminIds: [23, 25]
};

// Example usage for updating an existing group
const updatedGroup = {
id: 135,
name: "Updated Group Name",
visibility: "public"
};