Skip to content

Delete a label

The label deletion endpoint removes a label from the account. Because labels are shared across users, deletion affects every user who currently has that label. The call takes no request body and either completes immediately with 204 or returns 202 with an operation you can poll. This page maps the endpoint, the two headers that change behavior, and the documented failure codes so you can wire the call into a script or integration with predictable handling.

Endpoint and method

The call is a DELETE against /v2/labels/{id}. The only path parameter is id, a required string identifying the label to remove. There is no request body. The endpoint is part of the Labels group alongside list, create, get, and update operations.

Before sending, confirm three things: the API key carries the labels:write scope, the key owner is allowed to act on the label, and — if you are acting for another user — the key also carries users:act-on-behalf and the key owner manages that target user. Missing any of these produces a documented 403 rather than a silent no-op.

Authorization and scope

Send the API key as a bearer token in the Authorization header. The scope required for this endpoint is labels:write. The acting user is either the key owner or, when the X-On-Behalf-Of header is supplied, the user named in that header. Scopes and role limits are covered in the Authentication and Scopes sections of the API documentation; the endpoint itself does not create or modify keys.

Optional headers that change behavior

Two optional headers are relevant.

Idempotency-Key makes a write safe to retry. It accepts 1 to 255 printable ASCII characters, and each key is remembered for 24 hours per API key. If you resend the same request with the same key inside that window, you get the original response back, tagged with an Idempotent-Replayed header. Three failure shapes exist: pointing the same key at a different request yields 422 IDEMPOTENCY_KEY_REUSED; sending a retry while the original is still executing yields 409 IDEMPOTENCY_REQUEST_IN_PROGRESS; and a key that fails the character or length rules yields 400 INVALID_IDEMPOTENCY_KEY.

X-On-Behalf-Of names the user the write is performed for. Two conditions must hold: the key must carry the users:act-on-behalf scope, and the key owner must manage the target user. If either is missing, the request fails with 403 ON_BEHALF_OF_NOT_ALLOWED. The header has no effect on GET requests, so it only matters for writes like this one.

Success outcomes: 204 or 202 with an operation

A completed deletion returns 204 with an empty body. When the write is still running, or has succeeded but its result cannot be read back yet, the endpoint returns 202 with an operation object. The Location header carries the same URL as operation.url. Poll that URL until the status is SUCCEEDED or FAILED. The operation status values are PENDING, SUCCEEDED, FAILED, and UNKNOWN. 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 the status to SUCCEEDED or FAILED.

Use this decision table when handling the response:

Documented error codes and what they mean

The endpoint lists 403 ON_BEHALF_OF_NOT_ALLOWED, 403 FORBIDDEN, 404 RESOURCE_NOT_FOUND (the label does not exist), and the Idempotency-Key codes. The error envelope is consistent across endpoints: error.code is a stable machine-readable value, error.name is a short human-readable name, error.description explains what went wrong, error.resolution explains how to fix it, error.requestId is the ID to quote when contacting support, and error.details carries optional code-specific information.

Distinguish the two 403s. ON_BEHALF_OF_NOT_ALLOWED means the on-behalf-of path was attempted but the key lacks users:act-on-behalf or the key owner does not manage the target user. FORBIDDEN is the general authorization failure for the acting user. A 404 RESOURCE_NOT_FOUND means the label ID is wrong or outside the data this key can access — check the ID and that the key owner can see the label. Idempotency failures are separate: 422 IDEMPOTENCY_KEY_REUSED means the key was used with a different request, 409 IDEMPOTENCY_REQUEST_IN_PROGRESS means the first request is still running, and 400 INVALID_IDEMPOTENCY_KEY means the key itself is invalid.

Pre-flight checklist

Before calling the endpoint, verify each item:

  • The API key includes labels:write.
  • The key is sent as Authorization: Bearer <token>.
  • The label ID in the path is correct and visible to the key owner.
  • If acting for another user, X-On-Behalf-Of is set, users:act-on-behalf is present, and the key owner manages that user.
  • If the call will be retried, an Idempotency-Key of 1 to 255 printable ASCII characters is generated and reused for identical retries only.
  • The client handles both 204 (empty body) and 202 (operation object with id, status, url).
  • The client polls operation.url until SUCCEEDED or FAILED, and treats UNKNOWN as a read-back check rather than a success.
Response decision table
StatusBodyMeaningNext step
204EmptyDeletion completedProceed; no polling needed
202operation object (id, status, url)Write still running or result not yet readablePoll operation.url until SUCCEEDED or FAILED
403 ON_BEHALF_OF_NOT_ALLOWEDError envelopeOn-behalf-of path not permittedAdd users:act-on-behalf or confirm key owner manages target user
403 FORBIDDENError envelopeActing user may not perform the actionCheck key owner role and label access
404 RESOURCE_NOT_FOUNDError envelopeLabel does not exist or is outside key accessVerify the label ID and key owner visibility
422 IDEMPOTENCY_KEY_REUSEDError envelopeIdempotency-Key reused with a different requestUse a fresh key for a different request
409 IDEMPOTENCY_REQUEST_IN_PROGRESSError envelopeFirst request with this key is still runningWait for the first request to finish
400 INVALID_IDEMPOTENCY_KEYError envelopeIdempotency-Key is invalidUse 1 to 255 printable ASCII characters

Statuses and codes are as documented for this endpoint; the 422, 409, and 400 idempotency codes are described in the Idempotency-Key header documentation.

Frequently asked questions

Does deleting a label affect users who currently have it?

Yes. Every user who has this label loses it when the deletion completes. Plan the change with that in mind, especially if the label is used in reports or filters.

What is the difference between 204 and 202 on this endpoint?

204 means the deletion has completed and the body is empty. 202 means the write is still running or its result cannot be read back yet; the body contains an operation object with id, status, and url. Poll operation.url until the status is SUCCEEDED or FAILED. UNKNOWN means no result arrived within 15 minutes, so read the resource to check whether the change was applied.

How do I retry a deletion safely?

Attach an Idempotency-Key made of 1 to 255 printable ASCII characters, and keep that key tied to one specific request. Each key lives for 24 hours per API key. If an identical request arrives again within that window, the stored response is returned instead of the work being repeated, and the reply carries the Idempotent-Replayed header. A key that shows up attached to different request content is rejected with 422 IDEMPOTENCY_KEY_REUSED. A retry that lands while the first attempt is still executing is rejected with 409 IDEMPOTENCY_REQUEST_IN_PROGRESS.

Why did I get 403 ON_BEHALF_OF_NOT_ALLOWED?

The X-On-Behalf-Of header requires the users:act-on-behalf scope, and the key owner must manage the target user. If either condition is missing, the request fails with 403 ON_BEHALF_OF_NOT_ALLOWED. This is distinct from a general 403 FORBIDDEN, which indicates the acting user may not perform the action.

Does the endpoint accept a request body?

No. The call takes no request body. The only path parameter is id, and the only headers that change behavior are Idempotency-Key and X-On-Behalf-Of.

curl -X DELETE "$API_BASE_URL/v2/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

FieldTypeRequiredDescriptionConstraints
idstringYesresource ID.

Idempotency-Key

FieldTypeRequiredDescriptionConstraints
Idempotency-KeystringNooptional 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

FieldTypeRequiredDescriptionConstraints
X-On-Behalf-OfstringNoID 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

FieldTypeRequiredDescriptionConstraints
responseobjectReturned 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.operationobjectYes
response.operation.idstringYes
response.operation.statusstringYesoperation 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.urlstringYes

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo