Hello there, I’d like to know how to get all of the workspace time off requests using the api key generated by a workspace owner or a workspace admin.
I’m just getting the requests made by user who generate the API key, I have noticed we can pass userGroups and users.
I was wondering if it is possible to get them all without sending any user or group.
Hi @Erick_Ventura
Thank you for joining the Clockify Forum.
For the API call to work, it needs either the user group id or the userId. Here is an example of getting all time off requests for 1 user:
Method: POST
URL: https://pto.api.clockify.me/v1/workspaces/{workspaceId}/requests
Headers: “X-Api-Key”: “yourapikey” & “Content-Type”: application/json
Body:
{
"end": "2024-12-31T23:59:59.999Z",
"page": 1,
"pageSize": 50,
"start": "2024-01-01T00:00:00.000Z",
"statuses": ["ALL"],
"users": [
"userID goes here"
]
}
The statuses key can have the following parameters “PENDING” “APPROVED” “REJECTED” “ALL”.
You can either use the “users” key or “userGroups” parameter.
To get the userIds, you can run:
METHOD: GET
URL: https://api.clockify.me/api/v1/workspaces/{workspaceId}/users
To get the userGroup id:
METHOD: GET
URL: https://api.clockify.me/api/v1/workspaces/{workspaceId}/user-groups
You can either put all userIds into the “users” parameter, or put all users into 1 group and input the groupId.
Hope this helps!
1 Like
Understood thanks for your answer