Remove a label from a user
This endpoint detaches one label from one user. It is a DELETE request with no body. The call is made either as the API key owner or, when the X-On-Behalf-Of header is present, as the user named there. A successful synchronous call returns 204 No Content; a deferred call returns 202 Accepted with an operation object to poll.
Endpoint at a glance
Method: DELETE. Path: /v2/users/{id}/labels/{labelId}. Required scope: labels:write. Request body: none. Success: 204 No Content, or 202 Accepted with an operation to poll. The server URL shown in the reference is $API_BASE_URL. The complete request and response contract, including the exact cURL example, is delivered in the protected code and schema modules referenced below.
Decide who is acting before you send
There are two valid acting identities. If you omit X-On-Behalf-Of, the write is performed as the API key owner. If you include X-On-Behalf-Of, the write is performed for the user ID in that header, but only when the key carries the users:act-on-behalf scope and the key owner manages the target user. Otherwise the request fails with 403 ON_BEHALF_OF_NOT_ALLOWED. The header is ignored on GET requests, so it has no effect on read calls. Use this short checklist: (1) Is the removal for the key owner? Omit the header. (2) Is it for another user? Confirm the users:act-on-behalf scope and that the key owner manages that user. (3) Is the key owner a location admin or approver? That role limit applies to the acting user and can produce 403 FORBIDDEN.
Path and header fields
The path has two required string parameters: id (the user's resource ID) and labelId (the label's ID). The header has two optional parameters. Idempotency-Key is a string of 1 to 255 printable ASCII characters; keys are retained for 24 hours per API key. X-On-Behalf-Of is a string containing the target user's ID. The exact field definitions, requiredness and length limits are in the protected schema modules listed below.
Read the success response correctly
A 204 response means the label was removed and there is no response body. A 202 response means the write is still running, or it succeeded but the result could not be read back yet. The 202 body contains an operation object with id, status and url. The Location header carries the same URL as operation.url. Poll that URL until 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 labels to check. A result that arrives later still changes the status to SUCCEEDED or FAILED. The exact 202 JSON shape is in the protected response module.
Distinguish the common failures
403 FORBIDDEN means the acting user may not perform the action. 403 ON_BEHALF_OF_NOT_ALLOWED means the X-On-Behalf-Of request was rejected because the scope is missing or the key owner does not manage the target user. 404 RESOURCE_NOT_FOUND has two possible meanings here: the user does not exist, or the label is not assigned to that user. The error envelope includes a requestId; include it when contacting support. The Idempotency-Key errors are separate: 422 IDEMPOTENCY_KEY_REUSED when the key was used with a different request, 409 IDEMPOTENCY_REQUEST_IN_PROGRESS while the first request is still running, and 400 INVALID_IDEMPOTENCY_KEY for an invalid key. The exact error envelopes are in the protected modules.
Retry safely with an idempotency key
Attach an Idempotency-Key on the first attempt whenever a retry is plausible. For 24 hours, a repeat of the identical request under the same key returns the stored original response and marks it with Idempotent-Replayed. If the key is paired with a different request, the API answers 422 IDEMPOTENCY_KEY_REUSED. A retry that arrives while the first attempt is still executing gets 409 IDEMPOTENCY_REQUEST_IN_PROGRESS. A key that fails the format rules gets 400 INVALID_IDEMPOTENCY_KEY. Keys are tracked per API key, so two different keys never share a replay history.
Request example
The exact cURL example is delivered in the protected request module. It uses the DELETE method on /v2/users/string/labels/string with an Authorization: Bearer header. Language variants for JavaScript, Python, Go, Java and C# are delivered in the protected SDK variant module. Replace the placeholder path values with real user and label IDs.
Frequently asked questions
Does this endpoint need a request body?
No. The request has no body. The only inputs are the two path parameters and the optional headers.
What does 404 RESOURCE_NOT_FOUND mean here?
It means either the user does not exist or the label is not assigned to that user. Check both the user ID and the label assignment before retrying.
When should I use X-On-Behalf-Of?
Reach for this header when someone other than the key owner should be treated as the person the removal happens for. Two conditions must both hold: the key carries users:act-on-behalf, and the key owner has management authority over that target user. If either condition is missing, the call is refused with 403 ON_BEHALF_OF_NOT_ALLOWED. Read requests ignore the header entirely.
How do I handle a 202 response?
Read the operation object in the body and poll operation.url until status is SUCCEEDED or FAILED. If status is UNKNOWN, read the user's labels to check whether the change was applied.
Can I retry a failed request safely?
Yes, if you sent an Idempotency-Key with the original request. Within 24 hours, the same key and the same request replay the original response. A different request with the same key returns 422 IDEMPOTENCY_KEY_REUSED.
curl -X DELETE "$API_BASE_URL/v2/users/string/labels/string" \
-H "Authorization: Bearer "{
"operation": {
"id": "pa_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93",
"status": "PENDING",
"url": "/v2/operations/pa_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93"
}
}{
"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. |
labelId
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| labelId | string | Yes | label 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. | Allowed values: "PENDING" | "SUCCEEDED" | "FAILED" | "UNKNOWN" |
| response.operation.url | string | Yes |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |