Create a notification
Use this endpoint to create a scheduled notification for leave summaries or birthdays. The request must match exactly one frequency schema, and the acting user must be an approver or an admin. The response is either the created notification with 201 or an operation to poll with 202.
Endpoint and authorization
Send a POST request to /v2/notifications. The API key must be sent as Authorization: Bearer vt_live_<secret> and must carry the notifications:write scope. The acting user is either the key owner or the user identified by X-On-Behalf-Of. That user must be an approver or an admin and becomes the notification owner (ownerId). If you use X-On-Behalf-Of, the key also needs the users:act-on-behalf scope and the key owner must manage the target user.
Choose one frequency schema
The frequency field selects which request schema applies. Send only fields that belong to that frequency; fields from another frequency and unknown fields fail validation. Every kind requires name, timezone, hour, minute, and at least one destination. hour and minute are interpreted in the supplied timezone, not converted to UTC. locale defaults to en. locationIds, departmentIds, and labelIds default to empty arrays, which means everyone. enabled defaults to true, but DAILY and WEEKLY notifications can only be created enabled; sending enabled: false for either fails validation.
Frequency field map
Use this checklist to confirm the fields for the frequency you are sending.
Destination rules
An email destination accepts one or more email addresses in addresses. A microsoft or slack destination accepts exactly one channel ID in addresses. msGroup is accepted only for microsoft destinations. channelName is not accepted for email, and each microsoft or slack destination needs a channelName in a BIRTHDAY notification. The name field fails validation when it looks like HTML or script.
Safe retries with Idempotency-Key
Add the optional Idempotency-Key header when you want a write to be safe to retry. The value must be 1 to 255 printable ASCII characters. Each API key keeps its own record of used keys for 24 hours. Within that window, sending the same request again under the same key does not create a second notification: the original response is returned, flagged by the Idempotent-Replayed header. Three failures are reported separately. If the key is paired with a different request, the response is 422 IDEMPOTENCY_KEY_REUSED. If the first attempt is still running when you retry, the response is 409 IDEMPOTENCY_REQUEST_IN_PROGRESS. If the key itself is malformed, the response is 400 INVALID_IDEMPOTENCY_KEY.
Responses: 201 or 202
When the notification is created, the endpoint returns 201 with the notification object. If the write is still running, or succeeded but its result could not 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. A status of 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.
Error codes and what they mean
The endpoint can return 400 VALIDATION_ERROR with details.fields, 400 INVALID_REQUEST_BODY, 403 ON_BEHALF_OF_NOT_ALLOWED, 403 FORBIDDEN when the acting user may not create notifications, and the Idempotency-Key codes described above. The shared error envelope includes code, name, description, resolution, requestId, and optional details. Include requestId when contacting support.
Worked examples
The daily Slack summary example sends a DAILY notification at 09:00 Europe/Belgrade on Monday through Friday, grouped by TEAM, with sendEmpty false. The weekly email example sends a WEEKLY notification at 08:30 America/Los_Angeles on Monday, summarizing the current week for one location, grouped by LOCATION, with sendEmpty true. The birthday example sends a BIRTHDAY notification at 10:00 Europe/Belgrade to a Microsoft Teams channel with sendOnNonWorkingDays false. Use the protected code modules for the exact request and response bodies.
| Field | DAILY | WEEKLY | BIRTHDAY |
|---|---|---|---|
| frequency | Required | Required | Required |
| name | Required | Required | Required |
| timezone | Required | Required | Required |
| hour | Required | Required | Required |
| minute | Required | Required | Required |
| enabled | Optional; must be true | Optional; must be true | Optional; defaults to true |
| locale | Optional; defaults to en | Optional; defaults to en | Optional; defaults to en |
| locationIds | Optional; empty means all | Optional; empty means all | Optional; empty means all |
| departmentIds | Optional; empty means all | Optional; empty means all | Optional; empty means all |
| labelIds | Optional; empty means all | Optional; empty means all | Optional; empty means all |
| destinations | Required; at least one | Required; at least one | Required; at least one |
| groupBy | Required | Required | Not accepted |
| sendEmpty | Required | Required | Not accepted |
| sendOnDays | Required | Not accepted | Not accepted |
| firstDayOfWeek | Not accepted | Required | Not accepted |
| day | Not accepted | Required | Not accepted |
| currentWeek | Not accepted | Required | Not accepted |
| sendOnNonWorkingDays | Not accepted | Not accepted | Required |
| managersReminders | Not accepted | Not accepted | Optional |
Field acceptance is defined by the frequency schema. Sending a field that belongs to another frequency fails validation.
| Status | Code | Meaning | What to check |
|---|---|---|---|
| 400 | VALIDATION_ERROR | A query parameter, body field, or header failed validation | Inspect details.fields and fix each listed path |
| 400 | INVALID_REQUEST_BODY | The request body could not be parsed or does not match the schema | Check JSON syntax and that only the selected frequency's fields are present |
| 403 | ON_BEHALF_OF_NOT_ALLOWED | The X-On-Behalf-Of user is not permitted for this key | Confirm users:act-on-behalf scope and that the key owner manages the target user |
| 403 | FORBIDDEN | The acting user may not create notifications | Confirm the acting user is an approver or an admin |
| 409 | IDEMPOTENCY_REQUEST_IN_PROGRESS | A request with the same key is still running | Wait for the first request to finish before retrying |
| 422 | IDEMPOTENCY_KEY_REUSED | The key was reused with a different request | Use a new key or resend the original request |
| 400 | INVALID_IDEMPOTENCY_KEY | The key is not 1 to 255 printable ASCII characters | Correct the key format |
The error envelope also includes requestId; include it when contacting support.
Frequently asked questions
Who becomes the owner of the created notification?
The acting user becomes the owner and is recorded in ownerId. The acting user is either the key owner or the user specified by X-On-Behalf-Of, and must be an approver or an admin.
Can I create a DAILY or WEEKLY notification as disabled?
No. DAILY and WEEKLY notifications can only be created enabled. Sending enabled: false for either frequency fails validation. BIRTHDAY notifications default to enabled: true but accept the enabled field.
Are hour and minute converted to UTC?
No. hour and minute are local to the supplied timezone and are not converted to UTC.
What should I do when the response is 202 Accepted?
Poll the operation URL until the status is SUCCEEDED or FAILED. If the status is UNKNOWN, no result arrived within 15 minutes; read the resource to check whether the change was applied.
How many addresses can a destination contain?
An email destination accepts one or more email addresses. A microsoft or slack destination accepts exactly one channel ID. msGroup is accepted only for microsoft, and channelName is not accepted for email.
curl -X POST "$API_BASE_URL/v2/notifications" \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"name": "Daily team summary",
"frequency": "DAILY",
"timezone": "Europe/Belgrade",
"hour": 9,
"minute": 0,
"sendOnDays": [
1,
2,
3,
4,
5
],
"groupBy": "TEAM",
"sendEmpty": false,
"destinations": [
{
"platform": "slack",
"addresses": [
"C04ABCDEF12"
],
"channelName": "general"
}
]
}'{
"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": "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"
}
}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. |
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 |