/ Platform API
Platform API
    Chat Platform API v3
    Chat Platform API
    Chat Platform API
    Version 3

    Update push notification preferences

    Copy link

    You can update a user's push notification preferences. A push notification is a message that is immediately delivered to a user's device when the device is either idle or running the client app in the background.

    Note: Push notifications are only available for group channels.


    DND evaluation priority

    Copy link

    When evaluating whether to suppress a notification, the server checks in the following priority order:

    1. Snooze: If snooze is active, notifications are paused regardless of other settings.
    2. Day-of-week DND schedules: If dnd_schedules is non-empty, the server checks the current time against the configured windows.
    3. Legacy DND: If dnd_schedules is empty, the legacy do_not_disturb and start_hour/end_hour fields are used.

    Day-of-week DND schedules and legacy DND are mutually exclusive — setting dnd_schedules automatically disables legacy DND.

    Cross-midnight windows

    Copy link

    If a DND window spans midnight — for example, Monday 22:00 to Tuesday 06:00 — the server automatically splits it into two separate day entries in the response. The request can contain the original cross-midnight window; the split only applies to the response.

    For example, a request with monday start_hour: 22, end_hour: 6 is returned as monday 22:00–23:59 and tuesday 00:00–06:00.


    HTTP request

    Copy link
    PUT https://api-{application_id}.sendbird.com/v3/users/{user_id}/push_preference
    

    Parameters

    Copy link

    The following table lists the parameters that this action supports.

    Required
    NameTypeDescription

    user_id

    string

    Specifies the unique ID of a user.


    Request body

    Copy link

    The following table lists the properties of an HTTP request that this action supports.

    Optional
    Property nameTypeDescription

    push_trigger_option

    string

    The type of notification trigger applies to group channels when a user is disconnected from Sendbird server. Valid values are the following:
    - all (default): Indicates that a user receives notifications for all new messages.
    - mention_only: Indicates that a user only receives notifications for mentioned messages.
    - off: Indicates that a user doesn't receive any notifications.

    do_not_disturb

    boolean

    Indicates whether to repeatedly pause notifications for a set period of time on a daily basis. (Default: false)

    start_hour

    int

    The start hour for pausing notifications when do_not_disturb is set to true.

    start_min

    int

    The start minute for pausing notifications when do_not_disturb is set to true.

    end_hour

    int

    The end hour for pausing notifications when do_not_disturb is set to true.

    end_min

    int

    The end minute for pausing notifications when do_not_disturb is set to true.

    snooze_enabled

    boolean

    Indicates whether to snooze notifications for a set period of time. (Default: false)

    snooze_start_ts

    long

    The timestamp when snoozing notifications starts in Unix milliseconds.

    snooze_end_ts

    long

    The timestamp when snoozing notifications ends in Unix milliseconds.

    push_blocked_bot_ids

    array of strings

    Specifies an array of one or more unique IDs of bots whose notifications a user paused. This property is effective only when block_push_from_bots is set to true.

    block_push_from_bots

    boolean

    Determines whether to block notifications from all bots within the application. If the unique IDs of bots are specified in push_blocked_bot_ids, the notifications from the bots specified in the property are paused. (Default: false)

    timezone

    string

    The timezone applied when setting preferences for notifications. Valid values include UTC, Asia/Seoul, Europe/London, etc. (Default: UTC)

    push_sound

    string

    The name of a sound file played when a notification is delivered to a client app.

    dnd_schedules

    array of objects

    Specifies an array of day-of-week DND schedule objects. Each object defines the day and one or more time windows during which notifications are paused. If this property is set, legacy DND is automatically disabled.

    dnd_schedules[].day_of_week

    string

    Specifies the day of the week. Acceptable values are monday, tuesday, wednesday, thursday, friday, saturday, and sunday.

    dnd_schedules[].time_windows

    array of objects

    Specifies an array of time window objects for the given day. Multiple windows per day are allowed as long as they do not overlap.

    dnd_schedules[].time_windows[].start_hour

    int

    Specifies the start hour of the DND window in 24-hour format. Acceptable values are 0 to 23. If start_hour is later than end_hour, the window is treated as a cross-midnight window and the server splits it into two day entries in the response. See Cross-midnight windows.

    dnd_schedules[].time_windows[].start_min

    int

    Specifies the start minute of the DND window. Acceptable values are 0 to 59.

    dnd_schedules[].time_windows[].end_hour

    int

    Specifies the end hour of the DND window in 24-hour format. Acceptable values are 0 to 23. If start_hour is later than end_hour, the window is treated as a cross-midnight window and the server splits it into two day entries in the response. See Cross-midnight windows.

    dnd_schedules[].time_windows[].end_min

    int

    Specifies the end minute of the DND window. Acceptable values are 0 to 59.

    JSONJSON
    {
        "do_not_disturb": true,
        "start_hour": 17,
        "start_min": 30,
        "end_hour": 22,
        "end_min": 00,
        "snooze_enabled": true,
        "snooze_start_ts": 1523523600000,
        "snooze_end_ts": 1523525400000,
        "timezone": "Asia/Seoul",
        "push_sound": "bell_ring.swf"
    }
    

    Responses

    Copy link

    If successful, this action returns the push notification preferences of a user in the response body.

    {
        "push_trigger_option": "all",
        "do_not_disturb": false,
        "start_hour": 0,
        "start_min": 0,
        "end_hour": 0,
        "end_min": 0,
        "snooze_enabled": false,
        "snooze_start_ts": 0,
        "snooze_end_ts": 0,
        "timezone": "Asia/Seoul",
        "push_sound": "default",
        "dnd_schedules": [
            {
                "day_of_week": "monday",
                "time_windows": [
                    {"start_hour": 22, "start_min": 0, "end_hour": 23, "end_min": 59}
                ]
            },
            {
                "day_of_week": "tuesday",
                "time_windows": [
                    {"start_hour": 0, "start_min": 0, "end_hour": 7, "end_min": 0}
                ]
            },
            {
                "day_of_week": "wednesday",
                "time_windows": [
                    {"start_hour": 12, "start_min": 0, "end_hour": 13, "end_min": 0}
                ]
            },
            {
                "day_of_week": "saturday",
                "time_windows": [
                    {"start_hour": 0, "start_min": 0, "end_hour": 23, "end_min": 59}
                ]
            }
        ]
    }
    

    List of response properties

    Copy link
    Property nameTypeDescription

    push_trigger_option

    string

    The type of notification trigger that applies to group channels when the user is disconnected from the Sendbird server. Valid values are the following:
    - all: Indicates that the user receives notifications for all new messages.
    - mention_only: Indicates that the user only receives notifications for mentioned messages.
    - off: Indicates that the user doesn't receive any notifications. (Default: all)

    do_not_disturb

    boolean

    Indicates whether to repeatedly pause notifications for a set period of time on a daily basis. (Default: false)

    start_hour

    int

    The start hour for pausing notifications when do_not_disturb is set to true.

    start_min

    int

    The start minute for pausing notifications when do_not_disturb is set to true.

    end_hour

    int

    The end hour for pausing notifications when do_not_disturb is set to true.

    end_min

    int

    The end minute for pausing notifications when do_not_disturb is set to true.

    snooze_enabled

    boolean

    Indicates whether to snooze notifications for a set period of time. (Default: false)

    snooze_start_ts

    long

    The timestamp when snoozing notifications starts, in Unix milliseconds.

    snooze_end_ts

    long

    The timestamp when snoozing notifications ends, in Unix milliseconds.

    timezone

    string

    The timezone applied when setting preferences for notifications. Valid values include UTC, Asia/Seoul, Europe/London, etc. (Default: UTC)

    push_sound

    string

    The name of the sound file played when a notification is delivered to a client app.

    dnd_schedules

    array of objects

    An array of day-of-week DND schedule objects. Each object contains a day and its time windows. If empty, the legacy DND setting applies instead.

    dnd_schedules[].day_of_week

    string

    The day of the week. Valid values are monday, tuesday, wednesday, thursday, friday, saturday, and sunday.

    dnd_schedules[].time_windows

    array of objects

    An array of time window objects for the given day. Cross-midnight windows are split into separate day entries.

    dnd_schedules[].time_windows[].start_hour

    int

    The start hour of the DND window in 24-hour format.

    dnd_schedules[].time_windows[].start_min

    int

    The start minute of the DND window.

    dnd_schedules[].time_windows[].end_hour

    int

    The end hour of the DND window in 24-hour format.

    dnd_schedules[].time_windows[].end_min

    int

    The end minute of the DND window.

    In the case of an error, an error object like below is returned. See the error codes section for more details.

    {
        "message": "\"User\" not found.",
        "code": 400201,
        "error": true
    }
    
    {
        "message": "time_windows must not overlap for day_of_week: {day}",
        "code": 400111,
        "error": true
    }