API Request to Create a new Group
Request URL
https://yourgrupowebsiteaddress/api_request/
Request body
Field | Description/Values | Required/Optional |
---|---|---|
api_secret_key | Your Grupo API Secret Key. For API Secret Key, Click on Menu > Select Settings > Select General Settings > Find API Secret Key | Required |
add | groups | Required |
group_name | The name of the new group to be created. | Required |
description | Group Description | Optional |
group_category_id | Group Category ID | Optional |
slug | The URL-friendly slug for the group. | Optional |
secret_group | Private group which is completely hidden from non members. [yes|no] | Optional |
unleavable | Users are not allowed to leave this group [yes|no] | Optional |
pin_group | When you pin a group, it appears at the top of the list of groups. [yes|no] | Optional |
password_protect | Groups can be password protected, requiring a password to view/join the group [yes|no] | Optional |
password | Password for the Group | |
group_icon_url | The URL for the Group Icon Image | Optional |
custom_field_[id] | Replace [id] with Custom field ID. For Custom Field ID : Click on Menu > Select Modules > Select Custom Field > Click on Custom Field you Prefer to Add > Select Edit > Find “Identifier”. | Optional |
Response Body
KEY | Description/Values |
---|---|
success | This returns true on success and false on failure. |
error_message | Returns a relevant error message |
error_key | This method returns the error key associated with the error |
Example PHP Code
<?php
$grupo_web_address = 'https://yourgrupowebsiteaddress';
$post_fields=[
'api_secret_key' => 'Your_Grupo_API_Secret_Key',
'add' => 'groups',
'group_name' => 'Group Name',
'description' => 'Group Description',
'slug' => 'group_slug',
'group_category_id'=>'1',
'secret_group' => 'no',
'unleavable' => 'no',
'pin_group' => 'no',
'password_protect' => 'no',
'password' => 'password',
'group_icon_url' => 'https://group_icon_image_url',
'custom_field_10' => 'Custom Field Value',
];
$api_request_url = rtrim($grupo_web_address, '/').'/'.'api_request/';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $api_request_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $post_fields,
CURLOPT_USERAGENT=>'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0'
));
$response = curl_exec($curl);
curl_close($curl);
if (!empty($response)) {
$response = json_decode($response);
if (!empty($response)) {
if ($response->success) {
echo "Group Created Successfully.";
} else {
echo $response->error_message;
}
}
}
?>