Update a Scheduled Report
The scheduled-report PATCH endpoint changes an existing report without resending the whole object. You send only the fields you want to change; the service merges them with the stored report, validates the combined result, and then either returns the updated report or hands back an operation to poll. This guide explains the merge rules, the permission model, the headers that make retries safe, and how to read each failure code.
What the endpoint does
The endpoint is a PATCH against a single scheduled report identified by its resource ID. It requires the notifications:write scope. The acting user is either the key owner or the user named in the X-On-Behalf-Of header. The call waits for the change to complete and returns the updated report with 200, or returns 202 Accepted with an operation object to poll. At least one body field is required; an empty body is not a valid request.
Partial-merge rules: what replaces and what is kept
The service merges your body with the report's current values and re-validates the result. Anything you omit is preserved. The important distinction is between list fields and scalar fields.
List fields — receivers, locationIds, departmentIds, labelIds and leaveStatus — replace the current list when sent. Sending an empty list is not the same as omitting the field; it clears the list. Scalar fields such as name, reportType, period, timezone, sendDayOfMonth, sendHourUtc and sendMinuteUtc are merged individually.
sendHourUtc and sendMinuteUtc are interpreted in UTC. The timezone field controls the report's date display, not the send time. A report whose stored leaveStatus includes CANCELLED must be sent a new leaveStatus without it; otherwise the update fails with 400 VALIDATION_ERROR. CANCELLED is not accepted on update.
Who is allowed to update
Authorization is evaluated for whoever the request acts as, and the location coverage is compared on both sides of the edit. An admin is always allowed. A location admin is allowed only when their managed locations include every location the report covers before the change and every location it covers afterward. A new locationIds that is empty, or that names a location outside the acting user's management, produces 403 FORBIDDEN. A report that cannot be found, or that sits outside the acting user's locations, produces 404 RESOURCE_NOT_FOUND.
If you set X-On-Behalf-Of to a target user, two further requirements apply: the key needs the users:act-on-behalf scope, and the key owner must manage that target user. Failing either one produces 403 ON_BEHALF_OF_NOT_ALLOWED.
Headers and retry safety
Authorization is sent as a Bearer token. The Idempotency-Key header is optional but recommended for writes: it is a 1–255 character printable ASCII string retained for 24 hours per API key. Within that window, a repeat of the same key with the same request replays the original response and adds the Idempotent-Replayed header. Three failure modes are worth separating: a key reused with a different request returns 422 IDEMPOTENCY_KEY_REUSED; a retry that arrives while the first request is still running returns 409 IDEMPOTENCY_REQUEST_IN_PROGRESS; and a key that is not a valid 1–255 character printable ASCII string returns 400 INVALID_IDEMPOTENCY_KEY. The X-On-Behalf-Of header is ignored on GET requests.
Request body fields
The body is JSON and may contain any subset of the following fields:
- name — report name. Text that looks like HTML or script fails validation.
- reportType — one of leaveHistoryReport, leaveBalanceReport or monthlyLeaveBalanceReport.
- period — currently LAST_MONTH.
- locationIds, departmentIds, labelIds — arrays of string IDs; these replace the current list.
- receivers — array of email addresses; at least one item is required when sent.
- timezone — string.
- sendDayOfMonth — integer from 1 to 31.
- sendHourUtc — integer from 0 to 23, in UTC.
- sendMinuteUtc — integer from 0 to 59, in UTC.
- leaveStatus — array of APPROVED, DENIED or EXPIRED; only for leaveHistoryReport. CANCELLED is not accepted on update.
Worked example: replace receivers and change the send time
The captured examples show two independent changes. To replace the receivers, send a body containing only the receivers array with the new addresses. To change the schedule, send sendDayOfMonth, sendHourUtc and sendMinuteUtc together; the example uses day 5 at 06:00 UTC. Because the merge keeps everything you omit, you do not need to resend the report name, type or location lists when only the schedule changes. If the report's stored leaveStatus includes CANCELLED, add a leaveStatus array without CANCELLED in the same request.
Reading the response
A 200 response contains a data object with the full updated report: id, name, reportType, period, locationIds, departmentIds, labelIds, receivers, timezone, sendDayOfMonth, sendHourUtc, sendMinuteUtc, creatorId and, when applicable, leaveStatus and error. A 202 response contains an operation object with id, status and url. Poll the url until status is SUCCEEDED or FAILED. 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.
Failure distinction: which code means what
The error envelope carries a stable code, a short name, a description, a resolution and a requestId. The codes most relevant to this endpoint are:
- 400 VALIDATION_ERROR — a body field failed validation; details.fields lists the paths and messages. Fix those fields and resend.
- 400 INVALID_REQUEST_BODY — the body could not be parsed as the expected JSON shape.
- 403 SCHEDULED_REPORTS_NOT_AVAILABLE — the feature is not available to this key or account.
- 403 ON_BEHALF_OF_NOT_ALLOWED — the X-On-Behalf-Of target is not permitted for this key.
- 403 FORBIDDEN — the acting user is neither an admin nor a location admin, or the new locationIds is empty or includes a location they do not manage.
- 404 RESOURCE_NOT_FOUND — the report does not exist or is outside the acting user's locations.
- 409 IDEMPOTENCY_REQUEST_IN_PROGRESS — a retry arrived while the first request is still running.
- 422 IDEMPOTENCY_KEY_REUSED — the same key was used with a different request.
- 400 INVALID_IDEMPOTENCY_KEY — the key is not a valid 1–255 character printable ASCII string.
A 401 UNAUTHORIZED means the API key is missing, malformed or not recognized. A 403 INSUFFICIENT_SCOPE means the key lacks notifications:write or users:act-on-behalf; the response lists the required scopes in details.requiredScopes. A 429 RATE_LIMITED means too many requests were sent in a short time; wait and retry with the same Idempotency-Key. A 500 INTERNAL_ERROR means something went wrong on the server side; retry later and quote the requestId if it persists.
Pre-send checklist
Before sending the PATCH, confirm:
- The key has notifications:write, and users:act-on-behalf if X-On-Behalf-Of is used.
- The acting user is an admin, or a location admin who manages every location of the report before and after the change.
- The body contains at least one field.
- Any list field you send is the complete list you want, not an addition to the existing list.
- If the stored leaveStatus includes CANCELLED, the new leaveStatus omits it.
- sendHourUtc and sendMinuteUtc are in UTC, not the report's timezone.
- An Idempotency-Key is set if the request may be retried.
- You are ready to poll the operation url if the response is 202.
| Field | Type | Behavior when sent | Notes |
|---|---|---|---|
| name | string | merged | HTML-like or script-like text fails validation |
| reportType | ScheduledReportType | merged | leaveHistoryReport, leaveBalanceReport, monthlyLeaveBalanceReport |
| period | string | merged | LAST_MONTH |
| locationIds | array<string> | replaces list | empty list clears; must be manageable by acting user |
| departmentIds | array<string> | replaces list | empty list clears |
| labelIds | array<string> | replaces list | empty list clears |
| receivers | array<string> | replaces list | at least one item when sent; email format |
| timezone | string | merged | affects report dates, not send time |
| sendDayOfMonth | integer | merged | 1–31 |
| sendHourUtc | integer | merged | 0–23, UTC |
| sendMinuteUtc | integer | merged | 0–59, UTC |
| leaveStatus | array<string> | replaces list | APPROVED, DENIED, EXPIRED only; CANCELLED rejected on update |
Field types and ranges are taken from the endpoint contract. Behavior when sent reflects the documented merge rules.
| HTTP | Code | Meaning | Next step |
|---|---|---|---|
| 400 | VALIDATION_ERROR | A body field failed validation | Fix details.fields and resend |
| 400 | INVALID_REQUEST_BODY | Body is not valid JSON for this schema | Check the JSON shape |
| 400 | INVALID_IDEMPOTENCY_KEY | Key is not 1–255 printable ASCII | Use a valid key |
| 401 | UNAUTHORIZED | Key missing, malformed or unknown | Send a valid Bearer token |
| 403 | SCHEDULED_REPORTS_NOT_AVAILABLE | Feature not available | Check account access |
| 403 | ON_BEHALF_OF_NOT_ALLOWED | On-behalf-of target not permitted | Check users:act-on-behalf and management of target |
| 403 | FORBIDDEN | Acting user lacks admin/location-admin coverage | Adjust acting user or locationIds |
| 403 | INSUFFICIENT_SCOPE | Key lacks a required scope | Add scopes in details.requiredScopes |
| 404 | RESOURCE_NOT_FOUND | Report missing or outside locations | Check the report ID and location scope |
| 409 | IDEMPOTENCY_REQUEST_IN_PROGRESS | First request still running | Wait and retry with the same key |
| 422 | IDEMPOTENCY_KEY_REUSED | Same key, different request | Use a new key for a different request |
| 429 | RATE_LIMITED | Too many requests | Wait and retry with the same key |
| 500 | INTERNAL_ERROR | Server-side failure | Retry later; quote requestId |
Codes and meanings are taken from the endpoint contract and error envelope. HTTP statuses are shown as documented.
Frequently asked questions
Can I send only one field in the PATCH body?
Yes. At least one field is required, and the service merges your body with the stored report. Anything you omit is kept.
What happens if I send an empty array for receivers or locationIds?
List fields replace the current list when sent. An empty array clears the list. For receivers, at least one item is required when the field is sent.
Why does my update fail with VALIDATION_ERROR when the stored report has CANCELLED in leaveStatus?
CANCELLED is not accepted on update. If the stored leaveStatus includes CANCELLED, send a new leaveStatus array without it; otherwise the update fails with 400 VALIDATION_ERROR.
What is the difference between 403 FORBIDDEN and 404 RESOURCE_NOT_FOUND here?
403 FORBIDDEN means the acting user is neither an admin nor a location admin, or the new locationIds is empty or includes a location they do not manage. 404 RESOURCE_NOT_FOUND means the report does not exist or is outside the acting user's locations.
How do I handle a 202 response?
Poll the operation url until status is SUCCEEDED or FAILED. UNKNOWN means no result arrived within 15 minutes; the change may or may not have been applied, so read the resource to check.
Can I retry a PATCH safely?
Yes, if you use the same Idempotency-Key and the same request. The key is retained for 24 hours per API key and replays the original response with the Idempotent-Replayed header. A different request with the same key returns 422 IDEMPOTENCY_KEY_REUSED.
curl -X PATCH "$API_BASE_URL/v2/scheduled-reports/string" \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"receivers": [
"[email protected]",
"[email protected]"
]
}'{
"data": {
"id": "scheduledReport-8a47c61e-2b7f-4d5e-9c61-3f1c2b9e1d93",
"name": "Monthly balances",
"reportType": "leaveBalanceReport",
"period": "LAST_MONTH",
"locationIds": [],
"departmentIds": [],
"labelIds": [],
"receivers": [
"[email protected]"
],
"timezone": "Europe/Belgrade",
"sendDayOfMonth": 1,
"sendHourUtc": 7,
"sendMinuteUtc": 30,
"creatorId": "user-63b17e97-d38b-4586-8498-bb4f5d2e2c14"
}
}{
"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. |
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. |
body
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| body | object | Yes | the fields to change, merged with the current report and validated again. Arrays replace the current list. | 1 <= properties |
| body.name | string | No | report name. Text that looks like HTML or script fails validation. | |
| body.reportType | string | No | the kind of report | Allowed values: "leaveHistoryReport" | "leaveBalanceReport" | "monthlyLeaveBalanceReport" |
| body.period | string | No | Allowed values: "LAST_MONTH" | |
| body.locationIds | array<string> | No | ||
| body.locationIds[] | string | |||
| body.departmentIds | array<string> | No | ||
| body.departmentIds[] | string | |||
| body.labelIds | array<string> | No | ||
| body.labelIds[] | string | |||
| body.receivers | array<string> | No | 1 <= items | |
| body.receivers[] | string | Format: email | ||
| body.timezone | string | No | ||
| body.sendDayOfMonth | integer | No | 1 <= value <= 31 | |
| body.sendHourUtc | integer | No | in UTC | 0 <= value <= 23 |
| body.sendMinuteUtc | integer | No | in UTC | 0 <= value <= 59 |
| body.leaveStatus | array<string> | No | the leave statuses included, only for leaveHistoryReport. CANCELLED is not accepted on update. | |
| body.leaveStatus[] | string | "APPROVED" | "DENIED" | "EXPIRED" |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | |||
| response.data | object | Yes | ||
| response.data.id | string | Yes | scheduled report ID | |
| response.data.name | string | Yes | report name | |
| response.data.reportType | string | Yes | the kind of report | "leaveHistoryReport" | "leaveBalanceReport" | "monthlyLeaveBalanceReport" |
| response.data.period | string | No | the period the report covers; left out when it is not stored | "LAST_MONTH" |
| response.data.locationIds | array<string> | Yes | IDs of the locations included; empty means all locations | |
| response.data.locationIds[] | string | |||
| response.data.departmentIds | array<string> | Yes | IDs of the departments included; empty means all departments | |
| response.data.departmentIds[] | string | |||
| response.data.labelIds | array<string> | Yes | IDs of the labels included; empty means users with or without labels | |
| response.data.labelIds[] | string | |||
| response.data.receivers | array<string> | Yes | email addresses the report is sent to | |
| response.data.receivers[] | string | |||
| response.data.timezone | string | Yes | the time zone used for the report's dates. It does not apply to sendHourUtc and sendMinuteUtc. | |
| response.data.sendDayOfMonth | integer | Yes | the day of the month the report is sent | 1 <= value <= 31 |
| response.data.sendHourUtc | integer | Yes | the hour the report is sent, in UTC | 0 <= value <= 23 |
| response.data.sendMinuteUtc | integer | Yes | the minute the report is sent, in UTC | 0 <= value <= 59 |
| response.data.leaveStatus | array<ScheduledReportLeaveStatus> | No | the leave statuses included, only for leaveHistoryReport; left out when none are stored | |
| response.data.leaveStatus[] | string | a leave status a leaveHistoryReport includes | "APPROVED" | "DENIED" | "EXPIRED" | "CANCELLED" | |
| response.data.creatorId | string | Yes | the ID of the user who created the report | |
| response.data.error | string | No | the last error that stopped the report from being sent; left out when there is none |
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 |