Skip to content

Update a notification

The updateNotification operation sends a PATCH request to /v2/notifications/{id}. You supply only the fields you want to change; the server merges them with the notification's current values and validates the result as if you were creating a notification of that frequency. The call requires the notifications:write scope and an API key sent as a Bearer token. The acting user is the key owner unless you set the X-On-Behalf-Of header to another user ID.

Endpoint and authorization

Method: PATCH. Path: /v2/notifications/{id}, where id is the notification's resource ID. The Authorization header carries a Bearer token. The key must include notifications:write. If you act for another user, send X-On-Behalf-Of with that user's ID; this requires the users:act-on-behalf scope, and the key owner must manage the target user. Without that relationship the request returns 403 ON_BEHALF_OF_NOT_ALLOWED. The header is ignored on GET requests.

What a partial update changes

At least one body field is required. Everything you omit stays as it is. The merged result is validated against the rules for the notification's resulting frequency, so a field that does not belong to that frequency is ignored rather than rejected. Four kinds of fields behave differently, and it helps to know which is which before you send a request.

Field behaviour map

Use this map to predict how each group of fields behaves in a PATCH request.

Frequency rules

A notification can move between DAILY and WEEKLY, but it can never move to or from BIRTHDAY. Attempting that returns 400 NOTIFICATION_FREQUENCY_CHANGE_NOT_ALLOWED. When you switch to WEEKLY, send the fields the weekly schedule needs. When you switch to DAILY, the weekly-only fields are ignored. The enabled flag is independent of frequency: false pauses the notification and true resumes it.

Time and timezone

hour and minute are interpreted in the notification's timezone, not in UTC. hour accepts 0 through 23 and minute accepts 0 through 59. If you change the timezone without changing the hour or minute, the existing local time is reinterpreted in the new zone. To keep the same absolute send time across a timezone change, send hour and minute together with timezone.

Synchronous response vs. accepted operation

The endpoint waits for the change when it can. A completed change returns 200 with the notification in the response body. If the write is still running, or succeeded but its result could not be read back yet, the endpoint returns 202 Accepted with an operation object containing id, status, and url. Poll that URL until status becomes 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 notification to check. A result that arrives later still changes the status to SUCCEEDED or FAILED.

Retry safety with Idempotency-Key

An Idempotency-Key header of 1 to 255 printable ASCII characters lets you safely repeat a write. Each key is kept for 24 hours per API key. If you resend the identical request with the same key inside that window, the original response is replayed and marked with the Idempotent-Replayed header. Pointing the same key at a different request yields 422 IDEMPOTENCY_KEY_REUSED. A retry that arrives while the first request is still in flight yields 409 IDEMPOTENCY_REQUEST_IN_PROGRESS. A key that fails the format rules yields 400 INVALID_IDEMPOTENCY_KEY.

Who can change a notification

Ownership gates non-admin edits: a non-admin acting user may modify only notifications they own. If they target a notification owned by someone else, the API answers 404 RESOURCE_NOT_FOUND rather than 403. That choice keeps a non-admin from learning whether a notification they cannot reach exists at all.

Error codes

The endpoint returns 400 VALIDATION_ERROR with details.fields for field-level problems, 400 NOTIFICATION_FREQUENCY_CHANGE_NOT_ALLOWED for a forbidden frequency switch, 400 INVALID_REQUEST_BODY for a malformed body, 403 ON_BEHALF_OF_NOT_ALLOWED when the acting-user header is not permitted, 404 RESOURCE_NOT_FOUND when the notification is missing or outside the acting user's access, and the Idempotency-Key codes described above. A 409 CONFLICT means the request conflicts with the current state; read the notification again and retry with up-to-date values. A 429 RATE_LIMITED response means too many requests were sent in a short time; wait and retry, reusing the same Idempotency-Key for writes.

Worked example: pause, reschedule, and switch to weekly

The endpoint's request examples show three common edits. To pause a notification, send {"enabled": false}. To move the send time to 07:45 local time, send {"hour": 7, "minute": 45}. To switch a daily notification to weekly, send {"frequency": "WEEKLY", "firstDayOfWeek": 1, "day": 5, "currentWeek": false}; this sets the summary week to start on Monday and the send day to Friday, covering the next week. Each request carries only the fields being changed; the server merges them with the current notification. The response body for a successful 200 shows the full notification with its frequency-specific fields, including id, name, frequency, enabled, ownerId, timezone, hour, minute, locale, locationIds, departmentIds, labelIds, destinations, sendOnDays, groupBy, and sendEmpty.

How each field group behaves in a PATCH request
Field groupBehaviourNotes
enabledReplaces the current valuefalse pauses; true resumes
frequencyReplaces the current valueDAILY and WEEKLY can switch; BIRTHDAY cannot be entered or left
destinations, locationIds, departmentIds, labelIds, sendOnDaysReplaces the current listSend the full new list; omitted lists are kept
hour, minuteReplaces the current valueLocal to timezone, not UTC
name, timezone, locale, groupBy, sendEmpty, firstDayOfWeek, day, currentWeek, sendOnNonWorkingDays, managersRemindersReplaces the current valueValidated against the resulting frequency; fields that do not belong are ignored

This table describes merge behaviour for the updateNotification operation. It does not list every field's validation rule; see the request body reference for ranges and enums.

Frequently asked questions

When does the endpoint return 200 instead of 202?

A 200 response means the change completed and the notification is in the response body. A 202 response means the write is still running or its result could not be read back yet; the body contains an operation object with id, status, and url. Poll that URL until status is SUCCEEDED or FAILED. A status of UNKNOWN means no result arrived within 15 minutes, so read the notification to check whether the change was applied.

Can I change a birthday notification to daily or weekly?

No. A notification can switch between DAILY and WEEKLY, but it can never switch to or from BIRTHDAY. Attempting that returns 400 NOTIFICATION_FREQUENCY_CHANGE_NOT_ALLOWED. Fields that do not belong to the resulting frequency are ignored rather than rejected.

Why does a non-admin get 404 instead of 403 when updating someone else's notification?

Ownership gates non-admin edits: a non-admin acting user may modify only notifications they own. If they target a notification owned by someone else, the API answers 404 RESOURCE_NOT_FOUND rather than 403. That choice keeps a non-admin from learning whether a notification they cannot reach exists at all. The 403 ON_BEHALF_OF_NOT_ALLOWED code is separate and applies when the X-On-Behalf-Of header is not permitted.

What happens if I reuse an Idempotency-Key with a different request?

Pointing the same key at a different request yields 422 IDEMPOTENCY_KEY_REUSED. If you resend the identical request with the same key within 24 hours, the original response is replayed and marked with the Idempotent-Replayed header. A retry that arrives while the first request is still in flight yields 409 IDEMPOTENCY_REQUEST_IN_PROGRESS, and a key that fails the format rules yields 400 INVALID_IDEMPOTENCY_KEY.

Do I need to send the full list when changing destinations or sendOnDays?

Yes. destinations, locationIds, departmentIds, labelIds, and sendOnDays replace the current list when sent. If you omit a list, the existing list is kept. If you send a list, send the complete new list you want, not a partial addition.

curl -X PATCH "$API_BASE_URL/v2/notifications/string" \
  -H "Authorization: Bearer " \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": false
  }'
{
  "data": {
    "id": "notification-2b7f0e4a-1d93-4c61-8a47-3f1c2b9e4d5e",
    "name": "Daily team summary",
    "frequency": "DAILY",
    "enabled": true,
    "ownerId": "user-63b17e97-d38b-4586-8498-bb4f5d2e2c14",
    "timezone": "Europe/Belgrade",
    "hour": 9,
    "minute": 0,
    "locale": "en",
    "locationIds": [],
    "departmentIds": [],
    "labelIds": [],
    "destinations": [
      {
        "platform": "slack",
        "addresses": [
          "C04ABCDEF12"
        ],
        "channelName": "general"
      }
    ],
    "sendOnDays": [
      1,
      2,
      3,
      4,
      5
    ],
    "groupBy": "TEAM",
    "sendEmpty": false
  }
}
{
  "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