Skip to content

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:

  1. The key has notifications:write, and users:act-on-behalf if X-On-Behalf-Of is used.
  2. The acting user is an admin, or a location admin who manages every location of the report before and after the change.
  3. The body contains at least one field.
  4. Any list field you send is the complete list you want, not an addition to the existing list.
  5. If the stored leaveStatus includes CANCELLED, the new leaveStatus omits it.
  6. sendHourUtc and sendMinuteUtc are in UTC, not the report's timezone.
  7. An Idempotency-Key is set if the request may be retried.
  8. You are ready to poll the operation url if the response is 202.
Field behavior on PATCH
FieldTypeBehavior when sentNotes
namestringmergedHTML-like or script-like text fails validation
reportTypeScheduledReportTypemergedleaveHistoryReport, leaveBalanceReport, monthlyLeaveBalanceReport
periodstringmergedLAST_MONTH
locationIdsarray<string>replaces listempty list clears; must be manageable by acting user
departmentIdsarray<string>replaces listempty list clears
labelIdsarray<string>replaces listempty list clears
receiversarray<string>replaces listat least one item when sent; email format
timezonestringmergedaffects report dates, not send time
sendDayOfMonthintegermerged1–31
sendHourUtcintegermerged0–23, UTC
sendMinuteUtcintegermerged0–59, UTC
leaveStatusarray<string>replaces listAPPROVED, 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.

Error code map for this endpoint
HTTPCodeMeaningNext step
400VALIDATION_ERRORA body field failed validationFix details.fields and resend
400INVALID_REQUEST_BODYBody is not valid JSON for this schemaCheck the JSON shape
400INVALID_IDEMPOTENCY_KEYKey is not 1–255 printable ASCIIUse a valid key
401UNAUTHORIZEDKey missing, malformed or unknownSend a valid Bearer token
403SCHEDULED_REPORTS_NOT_AVAILABLEFeature not availableCheck account access
403ON_BEHALF_OF_NOT_ALLOWEDOn-behalf-of target not permittedCheck users:act-on-behalf and management of target
403FORBIDDENActing user lacks admin/location-admin coverageAdjust acting user or locationIds
403INSUFFICIENT_SCOPEKey lacks a required scopeAdd scopes in details.requiredScopes
404RESOURCE_NOT_FOUNDReport missing or outside locationsCheck the report ID and location scope
409IDEMPOTENCY_REQUEST_IN_PROGRESSFirst request still runningWait and retry with the same key
422IDEMPOTENCY_KEY_REUSEDSame key, different requestUse a new key for a different request
429RATE_LIMITEDToo many requestsWait and retry with the same key
500INTERNAL_ERRORServer-side failureRetry 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

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.

body

FieldTypeRequiredDescriptionConstraints
bodyobjectYesthe fields to change, merged with the current report and validated again. Arrays replace the current list.1 <= properties
body.namestringNoreport name. Text that looks like HTML or script fails validation.
body.reportTypestringNothe kind of reportAllowed values: "leaveHistoryReport" | "leaveBalanceReport" | "monthlyLeaveBalanceReport"
body.periodstringNoAllowed values: "LAST_MONTH"
body.locationIdsarray<string>No
body.locationIds[]string
body.departmentIdsarray<string>No
body.departmentIds[]string
body.labelIdsarray<string>No
body.labelIds[]string
body.receiversarray<string>No1 <= items
body.receivers[]stringFormat: email
body.timezonestringNo
body.sendDayOfMonthintegerNo1 <= value <= 31
body.sendHourUtcintegerNoin UTC0 <= value <= 23
body.sendMinuteUtcintegerNoin UTC0 <= value <= 59
body.leaveStatusarray<string>Nothe leave statuses included, only for leaveHistoryReport. CANCELLED is not accepted on update.
body.leaveStatus[]string"APPROVED" | "DENIED" | "EXPIRED"

response

FieldTypeRequiredDescriptionConstraints
responseobject
response.dataobjectYes
response.data.idstringYesscheduled report ID
response.data.namestringYesreport name
response.data.reportTypestringYesthe kind of report"leaveHistoryReport" | "leaveBalanceReport" | "monthlyLeaveBalanceReport"
response.data.periodstringNothe period the report covers; left out when it is not stored"LAST_MONTH"
response.data.locationIdsarray<string>YesIDs of the locations included; empty means all locations
response.data.locationIds[]string
response.data.departmentIdsarray<string>YesIDs of the departments included; empty means all departments
response.data.departmentIds[]string
response.data.labelIdsarray<string>YesIDs of the labels included; empty means users with or without labels
response.data.labelIds[]string
response.data.receiversarray<string>Yesemail addresses the report is sent to
response.data.receivers[]stringemail
response.data.timezonestringYesthe time zone used for the report's dates. It does not apply to sendHourUtc and sendMinuteUtc.
response.data.sendDayOfMonthintegerYesthe day of the month the report is sent1 <= value <= 31
response.data.sendHourUtcintegerYesthe hour the report is sent, in UTC0 <= value <= 23
response.data.sendMinuteUtcintegerYesthe minute the report is sent, in UTC0 <= value <= 59
response.data.leaveStatusarray<ScheduledReportLeaveStatus>Nothe leave statuses included, only for leaveHistoryReport; left out when none are stored
response.data.leaveStatus[]stringa leave status a leaveHistoryReport includes"APPROVED" | "DENIED" | "EXPIRED" | "CANCELLED"
response.data.creatorIdstringYesthe ID of the user who created the report
response.data.errorstringNothe last error that stopped the report from being sent; left out when there is none

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