Skip to content

Remove member

Endpoint

DELETE /organizations/{org_id}/users/{user_id}

This endpoint removes a member from the organization. This is typically a “soft delete” – the user account may still exist globally but is removed from this specific organization. Their assigned tasks might become unassigned or require reassignment.

Request

Replace {org_id} with your Organization ID and {user_id} with the numeric ID of the member to remove.

Headers

  • Authorization: Bearer {your_access_token}
  • Accept: application/json
  • X-Tallyfy-Client: APIClient

Query Parameters (Optional)

The Swagger definition indicates optional parameters for handling reassignment of the removed member’s tasks:

  • with_reassignment (boolean): Set to true if you want to reassign items.
  • to (integer): If with_reassignment=true, provide the User ID of the member to whom tasks, etc., should be reassigned.

Example: ?with_reassignment=true&to=1002

Body

No request body is needed for this DELETE request.

Code Samples

const accessToken = 'YOUR_PERSONAL_ACCESS_TOKEN';
const orgId = 'YOUR_ORGANIZATION_ID';
const userId = 12345; // ID of the member to remove
const reassignToUserId = 1002; // Optional: ID of member to reassign tasks to
// Construct query string if reassigning
const params = new URLSearchParams();
// if (reassignToUserId) {
// params.append('with_reassignment', 'true');
// params.append('to', reassignToUserId.toString());
// }
const queryStr = params.toString();
const apiUrl = `https://go.tallyfy.com/api/organizations/${orgId}/users/${userId}${queryStr ? '?' + queryStr : ''}`;
const headers = new Headers();
headers.append('Authorization', `Bearer ${accessToken}`);
headers.append('Accept', 'application/json');
headers.append('X-Tallyfy-Client', 'APIClient');
fetch(apiUrl, {
method: 'DELETE',
headers: headers
})
.then(response => {
if (!response.ok) { // Expect 200 OK on success usually
// Error handling...
return response.json().then(errData => { throw new Error(/*...*/); }).catch(() => { throw new Error(/*...*/); });
}
console.log(`Successfully removed member ${userId}. Status: ${response.status}`);
// API might return the details of the removed user
return response.json();
})
.then(data => {
if (data) {
console.log('Removed member details:');
console.log(JSON.stringify(data, null, 2));
}
})
.catch(error => {
console.error(`Error removing member ${userId}:`, error);
});

Response

A successful request typically returns a 200 OK status code. The response body might contain the details of the removed user, possibly with updated status fields (e.g., active: false, disabled_at timestamp).

{
"data": {
"id": 12345,
"email": "removed.user@example.com",
"first_name": "Removed",
"last_name": "User",
"active": false,
"status": "disabled", // Or similar status
"disabled_at": "2024-05-21T15:00:00Z",
"disabled_by": 1001, // ID of admin who performed the action
// ... other properties ...
}
}

If the user ID is not found or you lack permission, a 404 or 403 error will be returned.