Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/Clockify/Clockify_Remove_user_from_workspace.ipynb
2973 views
Kernel: Python 3

Clockify.png

Clockify - Remove user from workspace

Give Feedback | Bug report

Tags: #clockify #workspace #remove #user #api #rest

Last update: 2023-05-16 (Created: 2023-04-05)

Description: This notebook explains how to remove a user from a workspace using the Clockify API.

Input

Import libraries

import requests import naas from pprint import pprint

Setup Variables

  • api_key: Get your API key

  • workspace_id: ID of the workspace from which the user will be removed.

  • user_id: ID of the user to be removed.

api_key = naas.secret.get("CLOCKIFY_API_KEY") or "YOUR_API_KEY" workspace_id = "626f9e3b36c2670314c0386e" #"<WORKSPACE_ID>" user_id = "<YOUR_USER_ID>"

Model

Remove user from workspace

This function removes a user from a workspace using the Clockify API.

def remove_user_from_workspace(api_key, workspace_id, user_id): url = f"https://api.clockify.me/api/v1/workspaces/{workspace_id}/users/{user_id}" headers = {"X-Api-Key": api_key} response = requests.delete(url, headers=headers) return response

Output

Display result

response = remove_user_from_workspace(api_key, workspace_id, user_id) if response.status_code == 200: print(f"✅ User '{user_id}' deleted from workspace") else: print(f"❌ Error while deleted user '{user_id}'")