# Change notification preferences

`PUT /api/v1/notification-preferences`

Change the quiet hours, the delivery mode and the zone.

Quiet hours hold a notification back rather than dropping it: something due at three in the morning goes out when the quiet is over.

Asking for a daily summary without an hour to send it at is refused with 422, and so is a time of day that is not one, or a zone the application does not know.

## Body parameters

- `quiet_hours_are_enabled` (boolean, optional): Whether there are hours during which nothing may be delivered. It cannot be null.
- `quiet_hours_start` (string, optional): The local time from which nothing may go out, as HH:MM. Needed when quiet hours are on.
- `quiet_hours_end` (string, optional): The local time from which delivery may resume, as HH:MM. Needed when quiet hours are on.
- `delivery_mode` (string, optional): Either immediate or digest. It cannot be null.
- `digest_time` (string, optional): The local time the daily summary is sent, as HH:MM. Needed when the mode is digest.
- `digest_weekdays` (array, optional): Which days the summary is sent, as numbers from 0 for Sunday to 6 for Saturday. Null sends it every day.
- `timezone` (string, optional): The zone quiet hours and the summary hour are read in. Unlike other fields, null keeps whatever is saved rather than clearing it.

## Returns

The preferences as they now stand.

- `data` (object): The preference.
- `data.type` (string): Always notification_preference. It names the kind of record, so a caller holding several kinds can tell them apart without looking at where they came from.
- `data.id` (string): The id of this record, as a string even when it reads as a number. It is what every endpoint naming this record takes.
- `data.attributes` (object): Everything the record holds.
- `data.attributes.quiet_hours_are_enabled` (boolean): Whether there are hours during which nothing may be delivered.
- `data.attributes.quiet_hours_start` (string): The local time from which nothing may go out, as HH:MM, or null when quiet hours are off.
- `data.attributes.quiet_hours_end` (string): The local time from which delivery may resume, as HH:MM, or null when quiet hours are off.
- `data.attributes.delivery_mode` (string): Whether each notification goes out on its own, with immediate, or is folded into one summary a day, with digest.
- `data.attributes.digest_time` (string): The local time the daily summary is sent, as HH:MM, or null when nothing is folded.
- `data.attributes.digest_weekdays` (array): Which days the summary is sent, as numbers from 0 for Sunday to 6 for Saturday, or null for every day.
- `data.attributes.timezone` (string): The zone quiet hours and the summary hour are read in, up to 64 characters.
- `data.links` (object): Where to find this record.
- `data.links.self` (string): The absolute address this record is read from.

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://my.monicahq.com/api/v1/notification-preferences \
  -X PUT \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://my.monicahq.com/api/v1/notification-preferences', {
  method: 'PUT',
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->put('https://my.monicahq.com/api/v1/notification-preferences');
```

## Response

`200`

```json
{
    "data": {
        "type": "notification_preference",
        "id": "17",
        "attributes": {
            "quiet_hours_are_enabled": true,
            "quiet_hours_start": "22:00",
            "quiet_hours_end": "08:00",
            "delivery_mode": "immediate",
            "digest_time": null,
            "digest_weekdays": null,
            "timezone": "America/New_York"
        },
        "links": {
            "self": "https://my.monicahq.com/api/v1/notification-preferences"
        }
    }
}
```
