Members > Change a member's role
Administrators can change any member’s role between Administrator, Standard, and Light by going…
PUT /organizations/{org_id}/users/{user_id}/role
This endpoint changes a member’s role in your Tallyfy organization. It’s available to administrators only.
Replace {org_id} with your Organization ID and {user_id} with the member’s numeric ID.
Authorization: Bearer {your_access_token}Accept: application/jsonX-Tallyfy-Client: APIClientContent-Type: application/jsonSend a JSON object with the new role. The three valid roles are admin, standard, and light.
role (string, required): Must be one of admin, standard, or light.{ "role": "light"}const accessToken = 'YOUR_PERSONAL_ACCESS_TOKEN';const orgId = 'YOUR_ORGANIZATION_ID';const userId = 12345;const apiUrl = `https://go.tallyfy.com/api/organizations/${orgId}/users/${userId}/role`;
const roleData = { role: "admin" // Valid roles: "admin", "standard", "light"};
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(roleData)}).then(response => { return response.json().then(data => { if (!response.ok) { console.error(`Failed to update role for member ${userId}:`, data); throw new Error(`HTTP error! status: ${response.status}`); } return data; });}).then(data => { console.log(`Successfully updated role for member ${userId}:`); console.log(JSON.stringify(data, null, 2));}).catch(error => { console.error(`Error updating role for member ${userId}:`, 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')user_id = 12345api_url = f'https://go.tallyfy.com/api/organizations/{org_id}/users/{user_id}/role'
headers = { 'Authorization': f'Bearer {access_token}', 'Accept': 'application/json', 'X-Tallyfy-Client': 'APIClient', 'Content-Type': 'application/json'}
role_payload = { 'role': 'light' # Valid roles: "admin", "standard", "light"}
response = Nonetry: response = requests.put(api_url, headers=headers, json=role_payload) response.raise_for_status()
updated_member = response.json() print(f'Successfully updated role for member {user_id}:') print(json.dumps(updated_member, indent=4))
except requests.exceptions.HTTPError as http_err: error_details = "" try: if response is not None: error_details = response.json() except json.JSONDecodeError: if response is not None: error_details = response.text print(f"HTTP error updating role for member {user_id}: {http_err}") print(f"Response Body: {error_details}")
except requests.exceptions.RequestException as req_err: print(f"Request failed for member {user_id}: {req_err}")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;
public class UpdateMemberRole { 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"); int userId = 12345; String newRole = "standard"; // Valid: "admin", "standard", "light" String apiUrl = String.format("https://go.tallyfy.com/api/organizations/%s/users/%d/role", orgId, userId);
String jsonPayload = String.format("{\"role\": \"%s\"}", newRole);
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("Updated role for member " + userId + " to " + newRole + ":"); System.out.println(response.body()); } else { System.err.println("Failed. Status: " + response.statusCode()); System.err.println("Response: " + response.body()); } } catch (IOException | InterruptedException e) { System.err.println("Request failed: " + e.getMessage()); Thread.currentThread().interrupt(); } }}package main
import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "os" "strconv" "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" } userId := 12345 newRole := "admin" // Valid: "admin", "standard", "light" apiUrl := fmt.Sprintf("https://go.tallyfy.com/api/organizations/%s/users/%s/role", orgId, strconv.Itoa(userId))
roleData := map[string]interface{}{ "role": newRole, }
jsonData, err := json.Marshal(roleData) 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: %v\n", 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("Request failed: %v\n", err) return } defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Printf("Error reading response: %v\n", err) return }
if resp.StatusCode != http.StatusOK { fmt.Printf("Failed. Status: %d\nBody: %s\n", resp.StatusCode, string(body)) return }
fmt.Printf("Updated role for member %d to %s:\n", userId, newRole) var prettyJSON bytes.Buffer if err := json.Indent(&prettyJSON, body, "", " "); err == nil { fmt.Println(prettyJSON.String()) } else { fmt.Println(string(body)) }}#include <iostream>#include <string>#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> UpdateTallyfyMemberRole(int userId, const utility::string_t& newRole){ utility::string_t accessToken = U("YOUR_PERSONAL_ACCESS_TOKEN"); utility::string_t orgId = U("YOUR_ORGANIZATION_ID"); utility::string_t userIdStr = utility::conversions::to_string_t(std::to_string(userId)); utility::string_t apiUrl = U("https://go.tallyfy.com/api/organizations/") + orgId + U("/users/") + userIdStr + U("/role");
value payload = value::object(); payload[U("role")] = value::string(newRole);
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(payload);
return client.request(request).then([userId, newRole](http_response response) { return response.extract_json().then([response, userId, newRole](pplx::task<value> task) { try { value const & body = task.get(); if (response.status_code() == status_codes::OK) { std::wcout << L"Updated role for member " << userId << L" to " << newRole << L":\n" << body.serialize() << std::endl; } else { std::wcerr << L"Failed. Status: " << response.status_code() << L"\nResponse: " << body.serialize() << std::endl; } } catch (const std::exception& e) { std::wcerr << L"Error: " << e.what() << std::endl; } }); });}
int main() { try { UpdateTallyfyMemberRole(12345, U("light")).wait(); } catch (const std::exception &e) { std::cerr << "Error: " << e.what() << std::endl; } return 0;}// Requires C++ REST SDK (Casablanca)using System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;using System.Text.Json;using System.Threading.Tasks;
public class TallyfyMemberRoleUpdater{ private static readonly HttpClient client = new HttpClient();
public class RolePayload { public string Role { get; set; } // "admin", "standard", or "light" }
public static async Task UpdateMemberRoleAsync(int userId, string newRole) { 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}/users/{userId}/role";
var payload = new RolePayload { Role = newRole };
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");
string jsonPayload = JsonSerializer.Serialize(payload); request.Content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.SendAsync(request); string responseBody = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode) { Console.WriteLine($"Updated role for member {userId} to {newRole}:"); 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. Status: {response.StatusCode}"); Console.WriteLine($"Response: {responseBody}"); } } catch (HttpRequestException e) { Console.WriteLine($"Request error: {e.Message}"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
// static async Task Main(string[] args) // { // await UpdateMemberRoleAsync(12345, "admin"); // }}A 200 OK response returns the member’s full profile with the updated role.
{ "data": { "id": 12345, "email": "specific.user@example.com", "first_name": "Specific", "last_name": "User", "role": "light", // ... other user properties ... }}If the member isn’t found, you’ll get a 404. An invalid role value returns 422. Missing admin permissions returns 403.
Members > Change a member's role
Code Samples > Managing members (users)
/users endpoints to invite, list…