Skip to content

Create Notification Schedule



POST /api/v1/notification_schedule/add

Overview

Create a notification schedule along with its time period, effective period, and rotation order.

Before Calling and Usage Steps

First obtain valid notification targets from the Notification Target List or the Workspace Member List, and provide an HH:MM time period for the same day according to the schedule timezone. When rotation is enabled, rotationCycle must be passed, with one target per cycle in the order of notifyTargets; when rotation is disabled, all targets take effect together. Rotation is based on rotationUpdateAt. After a successful create or update, the on-call cache for the day is cleared; writes and subsequent processing may be completed in separate steps. After a timeout or 500, first check the list or details to confirm whether the data has been saved before deciding whether to retry, to avoid duplicate creation. In free or Free Plan workspaces, when using email, only email addresses of existing workspace members are supported.

Request Headers

Parameter Type Required Description
DF-API-KEY string Y OpenAPI authentication credential for the workspace.
Example: <DF-API-KEY>
How to obtain or enter: Obtain an OpenAPI Key with the required permission from API Key Management in the target workspace.

Body Request Parameters

Parameter Type Required Description
notifyTargets[*] string An account UUID, notification target UUID, or email address.
Example: notify_example
How to obtain or enter: For members, obtain the account UUID from the Workspace Member List; for notification targets, obtain the uuid from the Notification Target List; or enter a valid email address. All values must be strings.
extend.effectiveTime.start integer Effective period start in seconds; 0 or omitted means no start limit.
Example: 1785427200
How to obtain or enter: Provide the start boundary in Unix seconds.
extend.effectiveTime.end integer Effective period end in seconds; 0 or omitted means no end limit.
Example: 1788019200
How to obtain or enter: Provide the end boundary in Unix seconds; when non-zero, it must not be earlier than the start.
name string Y Non-empty name, maximum 256 characters, must be unique within this workspace.
Null allowed: False
Maximum length: 256
Empty string allowed: False
Example: 生产值班
How to obtain or enter: Check for duplicate names in this workspace using the Schedule List, then enter the name.
timezone string Schedule timezone; defaults to Asia/Shanghai if omitted.
Null allowed: False
Maximum length: 48
Example: Asia/Shanghai
How to obtain or enter: Select the IANA identifier for the actual business timezone, such as Asia/Shanghai or UTC.
start string Y HH:MM, from 00:00 to 23:59, must be earlier than end.
Null allowed: False
Maximum length: 48
Example: 09:00
How to obtain or enter: Select the daily start time according to the selected schedule timezone.
end string Y HH:MM, must be later than start; 59 seconds are added to the end minute. For periods crossing midnight, split them into separate schedules.
Null allowed: False
Maximum length: 48
Example: 18:00
How to obtain or enter: Select the end time on the same day according to the selected schedule timezone.
notifyTargets array Y Complete ordered string array; rotation follows this order; an empty array means no notification targets.
Null allowed: False
Example: ["notify_example"]
How to obtain or enter: For members, obtain the account UUID from the Workspace Member List; for notification targets, obtain the uuid from the Notification Target List; or enter a valid email address. All values must be strings.
extend json Complete extension configuration; defaults to {} if omitted.
Null allowed: False
Example: {"enableRotateNotification": false}
How to obtain or enter: Fill in as needed for rotation and the overall effective period.
extend.enableRotateNotification boolean Whether to enable rotation; default false.
Null allowed: False
Example: false
How to obtain or enter: Use false when all targets are on call together, and true to rotate a single target.
extend.rotationCycle string Must be explicitly provided when rotation is enabled. day rotates by calendar day; week switches on Monday, not after accumulating 7 days; month switches by calendar month; workDay rotates per workday only from Monday to Friday and does not take effect on weekends; weekend rotates daily only on Saturday/Sunday and does not take effect on workdays. Public holidays are not recognized. Based on rotationUpdateAt.
Null allowed: False
Allowed values: ['day', 'week', 'month', 'workDay', 'weekend']
Example: day
How to obtain or enter: Select from day, week, month, workDay, and weekend.
extend.effectiveTime json Overall effective period object; omitted means permanently effective; timestamps are in seconds, usually 10 digits, not milliseconds.
Null allowed: False
Example: {"start": 1785427200, "end": 1788019200}
How to obtain or enter: Convert the business effective period to Unix seconds; JavaScript Date.getTime() must be divided by 1000 and rounded.

Additional Parameter Notes

The time period includes the last second of the end minute; for example, 18:00 is actually effective until 18:00:59. The overall effectiveTime uses Unix seconds. The example disables rotation and uses a permanent effective period; you can add a complete rotation configuration according to the parameter table.

Request Example

curl --request POST 'https://openapi.guance.com/api/v1/notification_schedule/add' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"name":"生产值班","timezone":"Asia/Shanghai","start":"09:00","end":"18:00","notifyTargets":["notify_example"],"extend":{"enableRotateNotification":false}}'

Response

HTTP 200, application/json. The example below shows the main fields that can be read directly.

Field Type Description
content object Saved schedule entity and effective period display information; does not include notifyTargetsInfos.
content.id integer or null Database ID; may not yet be assigned at creation. Use uuid to operate on the resource.
content.uuid string Schedule UUID, used for query, modification, deletion, and reference by notification policies.
content.workspaceUUID string UUID of the workspace it belongs to.
content.name string Schedule name.
content.timezone string IANA timezone used by this schedule to interpret the daily time period and effective dates.
content.start string Start time of the day HH:MM.
content.end string End time of the day HH:MM; the last second of the end minute is still effective.
content.notifyTargets array<string> Member, notification target UUIDs, or email addresses saved in order.
content.notifyTargets[] string acnt_ account, notify_ notification target, or email address string.
content.extend object Extension configuration; can be {} if not configured.
content.extend.enableRotateNotification boolean Whether rotation is enabled; defaults to false.
content.extend.rotationCycle string Rotation cycle when enabled: day by day, week on Monday, month by calendar month, workDay daily on workdays only, weekend daily on weekends only. Public holidays are not recognized; may be omitted if not configured.
content.extend.effectiveTime object Overall effective period; may be omitted if not configured.
content.extend.effectiveTime.start integer Effective period start in Unix seconds; 0 or omitted means no limit.
content.extend.effectiveTime.end integer Effective period end in Unix seconds; 0 or omitted means no limit.
content.rotationUpdateAt integer Start time for rotation calculation, in Unix seconds. Reset when rotation-related configuration is changed.
content.status integer Record status; active records are 0.
content.creator string Identity of the creation call.
content.updator string Identity of the most recent update; empty string if never updated.
content.createAt integer Creation time, Unix seconds.
content.updateAt integer Update time, Unix seconds; -1 if never updated.
content.deleteAt integer Deletion time, Unix seconds; -1 if not deleted.
content.effectiveTimeInfos object Display information for the overall effective period; returned only by list, create, and modify.
content.effectiveTimeInfos.timeStr string Formatted in the schedule timezone as YYYY/MM/DD HH:MM:SS~YYYY/MM/DD HH:MM:SS. If one side is not set, it is empty; if both sides are not set, the entire string is empty.
content.effectiveTimeInfos.expired boolean Whether the current time has exceeded the effective period end; false when there is no end limit.
content.declaration object or null Workspace public declaration.
{
  "code": 200,
  "content": {
    "id": null,
    "uuid": "nsche_example",
    "workspaceUUID": "wksp_example",
    "name": "生产值班",
    "timezone": "Asia/Shanghai",
    "start": "09:00",
    "end": "18:00",
    "notifyTargets": [
      "notify_example"
    ],
    "extend": {
      "enableRotateNotification": false
    },
    "rotationUpdateAt": 1785427200,
    "status": 0,
    "creator": "wsak_example",
    "updator": "",
    "createAt": 1785427200,
    "updateAt": -1,
    "deleteAt": -1,
    "effectiveTimeInfos": {
      "timeStr": "",
      "expired": false
    },
    "declaration": {}
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

For authentication, rate limiting, and common request errors, see Common Error Definitions.

HTTP Status errorCode Trigger Condition Message or Response Description Handling
406 ft.ParameterValidationFailed Request field missing, or field value violates the declared validation conditions Parameter parsing failed Check the parameter location, field name, type, and value.
400 ft.RequestJsonFormatError Invalid request JSON syntax Request JSON format error Correct the JSON according to content.reason, line, and column.
400 ft.JsonFormatError JSON top level is not an object Partial JSON file format error Submit a single JSON object.
400 ft.InvalidStartEndTimeFromat Daily time out of range, end not later than start, etc. Invalid time period format Use valid HH:MM with start earlier than end on the same day. An unparseable end format may also result in a generic 500.
400 ft.InvalidEffectiveTime Non-zero effective period end earlier than start Invalid effective time Use Unix seconds in the same unit and adjust the end boundary.
406 ft.InvalidEmail Notification target is neither an account/notification target UUID nor a valid email address Invalid email address Use a real UUID or a valid email address string.
400 ft.UnsupportExternalEmail A free or Free Plan workspace used an email address other than a workspace member email Free Plan workspace does not support external email as a notification target Use an email address of an existing workspace member, or confirm that the workspace plan supports external email.
400 ft.scheduleSameNameExists The current workspace already has an active schedule with the same name A schedule with the same name already exists Use the list to check for duplicate names, then change the name.
400 ft.MissingCustomParameters Rotation enabled but rotationCycle not passed {} field missing Also provide a supported rotationCycle.
500 ft.InternalServerError Internal failure caused by an unknown IANA timezone, invalid actual date, non-string notification target, unparseable time, etc. Internal error Before calling, verify the timezone, actual date, HH:MM, and string array according to the parameter table; after a write operation fails, first check the details to confirm whether it has been saved, then decide whether to retry, and retain the traceId.

Feedback

Is this page helpful?