This endpoint clears the schedule a user was given individually, so the user returns to the work week defined for their location. It is the counterpart to setting a custom work week: instead of replacing the schedule with new values, you remove the override entirely.
What the call does
A DELETE request to /v2/users/{id}/work-week removes the user's custom work week. After the change, the user's schedule comes from their location's work week, which you can read with GET /v2/locations/{id}/work-week. No request body is sent. The endpoint waits for the change and answers with 204 when it completes, or 202 Accepted with an operation object when the work is still running and must be polled.
Authorization and scope
Send the API key as a bearer token in the Authorization header. The key needs the users:write scope. The key's owner, or the user named in X-On-Behalf-Of, must be an admin or a location admin who manages the target user. A key that lacks the scope fails with INSUFFICIENT_SCOPE; a key that is missing or unrecognized fails with UNAUTHORIZED.
Path and header fields
The path takes one required string, id, the resource ID of the user. Two optional headers matter. Idempotency-Key is a 1–255 character printable ASCII string that makes the write safe to retry; keys are kept for 24 hours per API key, and a repeat with the same key and same request replays the original response with an Idempotent-Replayed header. X-On-Behalf-Of names the user the write is performed for; it requires the users:act-on-behalf scope and a key owner who manages that user, and is ignored on GET requests.
Reading the response
A 204 means the custom work week is gone and the location schedule now applies. A 202 means the change is still in progress: the body carries an operation with an id, a status, and a url, and the Location header points to the same URL. Poll that URL until the status is SUCCEEDED or FAILED. A status of UNKNOWN means no result arrived within 15 minutes; the change may or may not have been applied, so read the user's work week to check. A later result can still move the status to SUCCEEDED or FAILED.
Failure distinction checklist
Use this to route a failed call to the right fix:
403 ON_BEHALF_OF_NOT_ALLOWED — the X-On-Behalf-Of user is not managed by the key owner, or the key lacks users:act-on-behalf.
403 FORBIDDEN — the acting user is not an admin or a managing location admin.
404 RESOURCE_NOT_FOUND — the user does not exist or sits outside the key's data reach.
400 INVALID_IDEMPOTENCY_KEY — the key is not 1–255 printable ASCII characters.
422 IDEMPOTENCY_KEY_REUSED — the same key was used with a different request.
409 IDEMPOTENCY_REQUEST_IN_PROGRESS — the first request with that key is still running.
429 RATE_LIMITED — slow down and retry with the same Idempotency-Key.
Example: clearing an override after a location move
Suppose a user was moved to a new location but still carries a custom work week from the old one. Send DELETE /v2/users/{id}/work-week with a fresh Idempotency-Key. If the response is 204, the user now follows the new location's schedule. If the response is 202, keep polling the operation URL until it reports SUCCEEDED, then confirm by reading the user's work week. If the operation reports UNKNOWN, read the user's work week directly rather than assuming the reset happened.
Frequently asked questions
Does this endpoint delete the user or their schedule data?
No. It removes only the user's custom work week. The user keeps their account and falls back to the work week defined for their location.
What happens if I retry with the same Idempotency-Key?
Within 24 hours, the same key with the same request replays the original response and adds an Idempotent-Replayed header. A different request with that key returns 422 IDEMPOTENCY_KEY_REUSED, and a retry while the first is still running returns 409 IDEMPOTENCY_REQUEST_IN_PROGRESS.
Why did I get 404 instead of 403?
A 404 RESOURCE_NOT_FOUND means the user does not exist or is outside the key's data reach. A 403 means the user exists but the acting user is not allowed to manage them. Check the ID first, then the role.
{
"error": {
"code": "VALIDATION_ERROR",
"name": "ValidationError",
"description": "Example post details.",
"resolution": "Fix the fields listed in details.fields and send the request again.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"details": {
"fields": [
{
"path": "startDate",
"message": "\"startDate\" is required"
}
]
}
}
}
{
"error": {
"code": "UNAUTHORIZED",
"name": "Unauthorized",
"description": "Example post details.",
"resolution": "Send a valid API key in the Authorization header as Bearer followed by the full vt_live_ key.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}
{
"error": {
"code": "INSUFFICIENT_SCOPE",
"name": "InsufficientScope",
"description": "Example post details.",
"resolution": "Add the scopes listed in details.requiredScopes to the key in the OnlyLeave dashboard.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"details": {
"requiredScopes": [
"leaves:write"
]
}
}
}
{
"error": {
"code": "RESOURCE_NOT_FOUND",
"name": "ResourceNotFound",
"description": "Example post details.",
"resolution": "Check the ID of the resource named in details.resource and that the key owner can see it.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}
{
"error": {
"code": "CONFLICT",
"name": "Conflict",
"description": "Example post details.",
"resolution": "Read the resource again and retry with up-to-date values.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}
{
"error": {
"code": "LEAVE_NEGATIVE_BALANCE",
"name": "LeaveNegativeBalance",
"description": "Example post details.",
"resolution": "Shorten the leave, use a different leave type, or ask an admin to adjust the quota.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}
{
"error": {
"code": "RATE_LIMITED",
"name": "RateLimited",
"description": "Example post details.",
"resolution": "Wait a few seconds and retry, using the same Idempotency-Key for writes.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}
{
"error": {
"code": "INTERNAL_ERROR",
"name": "InternalError",
"description": "Example post details.",
"resolution": "Retry later, and if it keeps happening, contact OnlyLeave support and quote the requestId.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}
id
Field
Type
Required
Description
Constraints
id
string
Yes
resource ID.
Idempotency-Key
Field
Type
Required
Description
Constraints
Idempotency-Key
string
No
optional key (1 to 255 printable ASCII characters) that makes a write request safe to retry. Keys are retained for 24 hours per API key. Retrying with the same key and the same request within those 24 hours replays the original response (with the Idempotent-Replayed header). Reusing the key with a different request returns 422 IDEMPOTENCY_KEY_REUSED ; retrying while the first request is still running returns 409 IDEMPOTENCY_REQUEST_IN_PROGRESS ; an invalid key returns 400 INVALID_IDEMPOTENCY_KEY .
1 <= length <= 255
X-On-Behalf-Of
Field
Type
Required
Description
Constraints
X-On-Behalf-Of
string
No
ID of the user the write is performed for. Requires the users:act-on-behalf scope, and the key owner must manage the target user; otherwise the request fails with 403 ON_BEHALF_OF_NOT_ALLOWED . Ignored on GET requests.
response
Field
Type
Required
Description
Constraints
response
object
Returned with HTTP 202 when a write operation is still running, or succeeded but its result could not be read back yet. The Location header carries the same URL as operation.url . Poll it until the status is SUCCEEDED or FAILED .
response.operation
object
Yes
response.operation.id
string
Yes
response.operation.status
string
Yes
operation status. UNKNOWN means no result arrived within 15 minutes; the change may or may not have been applied, so read the resource to check. A result that arrives later still changes it to SUCCEEDED or FAILED.