Update group
PUT /organizations/{org_id}/groups/{group_id}
This endpoint updates the details (name, description) and/or the membership (members, guests) of an existing group.
Replace {org_id}
with your Organization ID and {group_id}
with the ID of the group to update.
Authorization: Bearer {your_access_token}
Accept: application/json
X-Tallyfy-Client: APIClient
Content-Type: application/json
The request body requires a JSON object containing the group properties you wish to modify. You only need to include the fields you want to change.
Refer to the #definitions/createGroupInput
schema (often similar to update) in Swagger. Key fields:
name
(string): New name for the group.description
(string): New description.members
(array of integers): Replaces the current list of member IDs in the group.guests
(array of strings): Replaces the current list of guest emails in the group.
Example Body (Updating name and members):
{ "name": "Project Alpha Core Team", "members": [1001, 1008, 1010] // User 1005 removed, 1008/1010 added}
const accessToken = 'YOUR_PERSONAL_ACCESS_TOKEN';const orgId = 'YOUR_ORGANIZATION_ID';const groupId = 'GROUP_ID_TO_UPDATE';const apiUrl = `https://go.tallyfy.com/api/organizations/${orgId}/groups/${groupId}`;
const updateData = { description: "Updated team description.", // Example: Set specific members (replaces existing list) members: [1001, 1003, 1005], // Use actual member IDs guests: [] // Example: Remove all guests from this group};
const headers = new Headers();headers.append('Authorization', `Bearer ${accessToken}`);headers.append('Accept', 'application/json');headers.append('X-Tallyfy-Client', 'APIClient');headers.append('Content-Type', 'application/json');
fetch(apiUrl, { method: 'PUT', headers: headers, body: JSON.stringify(updateData)}).then(response => { return response.json().then(data => { // Attempt to parse JSON regardless of status if (!response.ok) { console.error(`Failed to update group ${groupId}:`, data); throw new Error(`HTTP error! status: ${response.status}`); } return data; // Pass successful data along });}).then(data => { console.log(`Successfully updated group ${groupId}:`); console.log(JSON.stringify(data, null, 2));}).catch(error => { console.error(`Error updating group ${groupId}:`, error.message);});
import requestsimport jsonimport os
access_token = os.environ.get('TALLYFY_ACCESS_TOKEN', 'YOUR_PERSONAL_ACCESS_TOKEN')org_id = os.environ.get('TALLYFY_ORG_ID', 'YOUR_ORGANIZATION_ID')group_id = 'GROUP_ID_TO_UPDATE'api_url = f'https://go.tallyfy.com/api/organizations/{org_id}/groups/{group_id}'
headers = { 'Authorization': f'Bearer {access_token}', 'Accept': 'application/json', 'X-Tallyfy-Client': 'APIClient', 'Content-Type': 'application/json'}
# Note: Updating members/guests replaces the entire list.# To add/remove incrementally, GET the group first, modify the lists, then PUT.update_payload = { 'name': 'Finance Approvers (Updated)', # Example: Change name 'members': [1004, 1006, 1007], # Example: Set this exact list of members 'guests': [] # Example: Ensure no guests are in the group}
response = Nonetry: response = requests.put(api_url, headers=headers, json=update_payload) response.raise_for_status() # Raises HTTPError for bad responses (4xx or 5xx)
updated_group = response.json() print(f'Successfully updated group {group_id}:') print(json.dumps(updated_group, indent=4))
except requests.exceptions.HTTPError as http_err: print(f"HTTP error occurred updating group {group_id}: {http_err}") if response is not None: print(f"Response Body: {response.text}")except requests.exceptions.RequestException as req_err: print(f"Request failed updating group {group_id}: {req_err}")except json.JSONDecodeError: print(f"Failed to decode JSON response for group update {group_id}") if response is not None: print(f"Response Text: {response.text}")except Exception as err: print(f"An unexpected error occurred: {err}")
import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.io.IOException;// Requires a JSON library like Jackson or Gson// import com.fasterxml.jackson.databind.ObjectMapper;// import java.util.Map;// import java.util.HashMap;// import java.util.List;
public class UpdateGroup { public static void main(String[] args) { String accessToken = System.getenv().getOrDefault("TALLYFY_ACCESS_TOKEN", "YOUR_PERSONAL_ACCESS_TOKEN"); String orgId = System.getenv().getOrDefault("TALLYFY_ORG_ID", "YOUR_ORGANIZATION_ID"); String groupId = "GROUP_ID_TO_UPDATE"; String apiUrl = String.format("https://go.tallyfy.com/api/organizations/%s/groups/%s", orgId, groupId);
// --- Payload Construction --- // Using a library like Jackson is recommended for real applications /* ObjectMapper mapper = new ObjectMapper(); Map<String, Object> updateData = new HashMap<>(); updateData.put("name", "Java Updated Group Name"); updateData.put("members", List.of(1001, 1002)); // Replaces existing members String jsonPayload; try { jsonPayload = mapper.writeValueAsString(updateData); } catch (Exception e) { System.err.println("Failed to serialize JSON: " + e.getMessage()); return; } */ // Simple manual JSON string for example (only update name and description): String jsonPayload = "{\"name\": \"Renamed Java Group\", \"description\": \"Updated description.\"}"; // --- End Payload Construction ---
HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(apiUrl)) .header("Authorization", "Bearer " + accessToken) .header("Accept", "application/json") .header("X-Tallyfy-Client", "APIClient") .header("Content-Type", "application/json") .PUT(HttpRequest.BodyPublishers.ofString(jsonPayload)) .build();
try { HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) { System.out.println("Successfully updated group " + groupId + ":"); System.out.println(response.body()); // TODO: Parse JSON response } else { System.err.println("Failed to update group " + groupId + ". Status: " + response.statusCode()); System.err.println("Response Body: " + response.body()); } } catch (IOException | InterruptedException e) { System.err.println("Request failed: " + e.getMessage()); Thread.currentThread().interrupt(); } catch (Exception e) { System.err.println("An unexpected error occurred: " + e.getMessage()); e.printStackTrace(); } }}
package main
import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "os" "time")
func main() { accessToken := os.Getenv("TALLYFY_ACCESS_TOKEN") if accessToken == "" { accessToken = "YOUR_PERSONAL_ACCESS_TOKEN" } orgId := os.Getenv("TALLYFY_ORG_ID") if orgId == "" { orgId = "YOUR_ORGANIZATION_ID" } groupId := "GROUP_ID_TO_UPDATE" apiUrl := fmt.Sprintf("https://go.tallyfy.com/api/organizations/%s/groups/%s", orgId, groupId)
// Note: Updating members/guests replaces the entire list. updateData := map[string]interface{}{ "name": "Go Updated Group", "members": []int{1010, 1012}, // Example: Set this exact member list "guests": []string{}, // Example: Remove all guests }
jsonData, err := json.Marshal(updateData) if err != nil { fmt.Printf("Error marshalling JSON: %v\n", err) return }
client := &http.Client{Timeout: 15 * time.Second} req, err := http.NewRequest(http.MethodPut, apiUrl, bytes.NewBuffer(jsonData)) if err != nil { fmt.Printf("Error creating request for group update %s: %v\n", groupId, err) return }
req.Header.Set("Authorization", "Bearer "+accessToken) req.Header.Set("Accept", "application/json") req.Header.Set("X-Tallyfy-Client", "APIClient") req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req) if err != nil { fmt.Printf("Error executing request for group update %s: %v\n", groupId, err) return } defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Printf("Error reading response body for group update %s: %v\n", groupId, err) return }
if resp.StatusCode != http.StatusOK { fmt.Printf("Failed to update group %s. Status: %d\nBody: %s\n", groupId, resp.StatusCode, string(body)) return }
fmt.Printf("Successfully updated group %s:\n", groupId) // Pretty print JSON response var prettyJSON bytes.Buffer if err := json.Indent(&prettyJSON, body, "", " "); err == nil { fmt.Println(prettyJSON.String()) } else { fmt.Println(string(body)) } // TODO: Unmarshal JSON from body into a struct if needed}
#include <iostream>#include <string>#include <vector>#include <cpprest/http_client.h>#include <cpprest/json.h>
using namespace web;using namespace web::http;using namespace web::http::client;using namespace web::json;
pplx::task<void> UpdateTallyfyGroup(const utility::string_t& groupId, const value& updatePayload){ utility::string_t accessToken = U("YOUR_PERSONAL_ACCESS_TOKEN"); utility::string_t orgId = U("YOUR_ORGANIZATION_ID"); utility::string_t apiUrl = U("https://go.tallyfy.com/api/organizations/") + orgId + U("/groups/") + groupId;
http_client client(apiUrl); http_request request(methods::PUT);
request.headers().add(U("Authorization"), U("Bearer ") + accessToken); request.headers().add(U("Accept"), U("application/json")); request.headers().add(U("X-Tallyfy-Client"), U("APIClient")); request.headers().set_content_type(U("application/json")); request.set_body(updatePayload);
return client.request(request).then([groupId](http_response response) { utility::string_t groupIdW = groupId; return response.extract_json().then([response, groupIdW](pplx::task<value> task) { try { value const & body = task.get(); if (response.status_code() == status_codes::OK) { std::wcout << L"Successfully updated group " << groupIdW << L":\n" << body.serialize() << std::endl; } else { std::wcerr << L"Failed to update group " << groupIdW << L". Status: " << response.status_code() << L"\nResponse: " << body.serialize() << std::endl; } } catch (const http_exception& e) { std::wcerr << L"HTTP exception during update group: " << e.what() << std::endl; } catch (const std::exception& e) { std::wcerr << L"Exception during update group response handling: " << e.what() << std::endl; } }); });}
int main() { try { value payload = value::object(); payload[U("name")] = value::string(U("C++ Updated Group Name")); value members = value::array(); members[0] = value::number(1001); members[1] = value::number(1015); payload[U("members")] = members; // Replaces existing members
UpdateTallyfyGroup(U("GROUP_ID_TO_UPDATE"), payload).wait(); // Replace with actual ID } catch (const std::exception &e) { std::cerr << "Error in main: " << e.what() << std::endl; } return 0;}// Requires C++ REST SDK (Casablanca)
using System;using System.Collections.Generic;using System.Net.Http;using System.Net.Http.Headers;using System.Text;using System.Text.Json;using System.Threading.Tasks;
public class TallyfyGroupUpdater{ private static readonly HttpClient client = new HttpClient();
// Use a similar payload class as Create, or use Dictionary<string, object> public class GroupUpdatePayload { // Include only fields you want to update. Use [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] if needed. public string Name { get; set; } public string Description { get; set; } public List<int> Members { get; set; } // Remember: This REPLACES the list public List<string> Guests { get; set; } // Remember: This REPLACES the list }
public static async Task UpdateGroupAsync(string groupId, GroupUpdatePayload payload) { var accessToken = Environment.GetEnvironmentVariable("TALLYFY_ACCESS_TOKEN") ?? "YOUR_PERSONAL_ACCESS_TOKEN"; var orgId = Environment.GetEnvironmentVariable("TALLYFY_ORG_ID") ?? "YOUR_ORGANIZATION_ID"; var apiUrl = $"https://go.tallyfy.com/api/organizations/{orgId}/groups/{groupId}";
try { using var request = new HttpRequestMessage(HttpMethod.Put, apiUrl); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); request.Headers.Add("X-Tallyfy-Client", "APIClient");
// Serialize the payload, ignoring nulls so only provided fields are sent var options = new JsonSerializerOptions { DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull }; string jsonPayload = JsonSerializer.Serialize(payload, options); request.Content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.SendAsync(request); string responseBody = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode) // Should be 200 OK { Console.WriteLine($"Successfully updated group {groupId}:"); // Pretty print the response try { using var doc = JsonDocument.Parse(responseBody); Console.WriteLine(JsonSerializer.Serialize(doc.RootElement, new JsonSerializerOptions { WriteIndented = true })); } catch (JsonException) { Console.WriteLine(responseBody); } } else { Console.WriteLine($"Failed to update group {groupId}. Status: {response.StatusCode}"); Console.WriteLine($"Response: {responseBody}"); } } catch (HttpRequestException e) { Console.WriteLine($"Request Exception updating group {groupId}: {e.Message}"); } catch (JsonException jsonEx) { Console.WriteLine($"JSON Serialization Error: {jsonEx.Message}"); } catch (Exception ex) { Console.WriteLine($"An unexpected error occurred: {ex.Message}"); } }
// Example Usage: // static async Task Main(string[] args) // { // var groupUpdate = new GroupUpdatePayload { // Description = "Core finance team for approvals.", // Members = new List<int> { 1004, 1007 } // Replace existing members // }; // await UpdateGroupAsync("GROUP_ID_TO_UPDATE", groupUpdate); // }}
A successful request returns a 200 OK
status code and a JSON object containing the full details of the group after the update.
{ "data": { "id": "GROUP_ID_TO_UPDATE", "name": "Project Alpha Core Team", // Updated name "description": "Updated team description.", // Updated description "members": [1001, 1008, 1010], // Updated members list "guests": [], // Updated guests list // ... other group properties ... "updated_at": "2024-05-21T19:00:00Z" // Reflects update time }}
If the group ID is not found, you lack permission, or the request body is invalid, an appropriate error status code (404
, 403
, 400
, 422
) will be returned.
- 2025 Tallyfy, Inc.
- Privacy Policy
- Terms of Use
- Report Issue
- Trademarks