Skip to content

Delete a scheduled report

This endpoint removes one scheduled report. It takes no request body: the report is identified by the path parameter, and the caller must hold the notifications:write scope. The response is either an immediate 204 No Content or a 202 Accepted carrying an operation you poll until it finishes.

Request contract

The method is DELETE and the path is /v2/scheduled-reports/{id}. The only path parameter is id, a required string holding the resource ID. Authorization is sent as a Bearer token in the Authorization header. Two optional headers modify the call: Idempotency-Key and X-On-Behalf-Of. The exact request shape, headers and generated client variants are supplied in the protected contract modules referenced below.

Who is allowed to delete

The acting user is either the API key owner or the user named in X-On-Behalf-Of. That acting user must be an admin, or a location admin who manages every location the report covers. If the acting user is neither, the request fails with 403 FORBIDDEN. Delegating the write through X-On-Behalf-Of is itself gated: the key needs the users:act-on-behalf scope, and the key owner must have authority over the target user. When either condition is missing, the call stops with 403 ON_BEHALF_OF_NOT_ALLOWED. When the scheduled reports feature is not available, the endpoint returns 403 SCHEDULED_REPORTS_NOT_AVAILABLE.

Retrying safely with Idempotency-Key

Idempotency-Key is optional and accepts 1 to 255 printable ASCII characters. Keys are kept for 24 hours per API key. Repeating the same request with the same key inside that window replays the original response and adds the Idempotent-Replayed header. Reusing a key for a different request returns 422 IDEMPOTENCY_KEY_REUSED. Retrying while the first request is still running returns 409 IDEMPOTENCY_REQUEST_IN_PROGRESS. A malformed key returns 400 INVALID_IDEMPOTENCY_KEY.

Reading the response: 204 versus 202

A 204 response means the deletion completed and there is no body to read. A 202 response means the write is still running, or it succeeded but its result could not yet be read back; the body contains an operation object with id, status and url, and the Location header carries the same URL. Poll that URL until status is SUCCEEDED or FAILED. A status of UNKNOWN means no result arrived within 15 minutes, so the change may or may not have been applied; read the resource to check. A result that arrives later still moves the status to SUCCEEDED or FAILED.

Telling failures apart

403 and 404 point to different problems. A 403 FORBIDDEN means the acting user lacks the required admin or location-admin role. A 404 RESOURCE_NOT_FOUND means the report does not exist or sits outside the acting user's locations. The 400, 401, 409, 422, 429 and 500 responses use the shared error envelope, where error.code is a stable machine-readable value and error.requestId should be quoted when contacting support. The error catalog also lists the Idempotency-Key codes described above.

Worked example: handling a 202 operation

Suppose the call returns 202 with an operation whose status is PENDING. Do not treat that as a completed deletion. Store the operation id and url, then poll the url. If polling eventually returns SUCCEEDED, the report is gone. If it returns FAILED, the operation carries the catalog error code the write failed with. If it returns UNKNOWN, re-read the report to determine whether the deletion actually took effect before retrying.

Pre-flight checklist

  1. Confirm the key has notifications:write. 2. If acting for another user, confirm users:act-on-behalf and that the key owner manages that user. 3. Confirm the acting user is an admin or manages every location of the report. 4. Decide whether to send an Idempotency-Key for safe retries. 5. On 202, poll the operation url until SUCCEEDED or FAILED; on UNKNOWN, re-read the resource.
Field and control map
FieldLocationRequiredNotes
idpathyesresource ID (string)
AuthorizationheaderyesBearer <token>
Idempotency-Keyheaderno1–255 printable ASCII; retained 24h per API key
X-On-Behalf-Ofheadernorequires users:act-on-behalf; ignored on GET

Header and path rules are taken from the supplied contract modules; the table is a reader aid, not a substitute for those modules.

Frequently asked questions

Does deleting a scheduled report require a request body?

No. The report is identified by the id path parameter, and no body is sent.

What happens if the acting user is not an admin?

The request returns 403 FORBIDDEN. The acting user must be an admin or a location admin who manages every location of the report.

How do I know the deletion finished after a 202 response?

Poll the operation url from the response body or Location header until status is SUCCEEDED or FAILED. UNKNOWN means no result arrived within 15 minutes; re-read the resource to check.

Why does a retry return 422 IDEMPOTENCY_KEY_REUSED?

The same Idempotency-Key was used with a different request. Use a fresh key for a different request, or the same key only for an identical retry.

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