Template request | Bug report | Generate Data Product
Tags: #clockify #project #create #api #rest #documentation
Author: Florent Ravenel
Description: This notebook will show how to delete an existing project using Clockify API from a specific workspace. You can only delete archived project. Active project can not be deleted.
References:
import requests
import naas
api_key
: Get your API keyworkspace_id
: ID of the workspaceproject_id
: ID of the project to be deleted
api_key = naas.secret.get("CLOCKIFY_API_KEY") or "YOUR_API_KEY"
workspace_id = "626f9e3b36c2670314c0386e" #"<WORKSPACE_ID>"
project_id = "6465128cb3aa2432050af887"
This function will delete an existing project using Clockify API.
def delete_project(api_key, workspace_id, project_id):
url = f"https://api.clockify.me/api/workspaces/{workspace_id}/projects/{project_id}"
headers = {
"X-Api-Key": api_key,
"Content-Type": "application/json"
}
response = requests.delete(url, headers=headers)
return response
response = delete_project(api_key, workspace_id, project_id)
if response.status_code == 200:
print(f"✅ Client '{project_id}' deleted from workspace")
else:
print(f"❌ Error while deleted project '{project_id}'")
response.json()