# My Notifications

Notifications following new videos, follows or reports. They allow you to keep track of the interactions and overall important information that concerns you. You MAY set per-notification type delivery preference, to receive the info either by mail, by in-browser notification or both.


## List my notifications

`GET /api/v1/users/me/notifications`

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": []
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started


Parameters:

- `typeOneOf` (query, Array<NotificationType>, optional) - only list notifications of these types
  Type: Array<NotificationType>
  
  Items:
    Reference: [NotificationType](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationtype.md); Type: NotificationType
    
    Notification type. One of the following values:
    
      - `1` NEW_VIDEO_FROM_SUBSCRIPTION
    
      - `2` NEW_COMMENT_ON_MY_VIDEO
    
      - `3` NEW_ABUSE_FOR_MODERATORS
    
      - `4` BLACKLIST_ON_MY_VIDEO
    
      - `5` UNBLACKLIST_ON_MY_VIDEO
    
      - `6` MY_VIDEO_PUBLISHED
    
      - `7` MY_VIDEO_IMPORT_SUCCESS
    
      - `8` MY_VIDEO_IMPORT_ERROR
    
      - `9` NEW_USER_REGISTRATION
    
      - `10` NEW_FOLLOW
    
      - `11` COMMENT_MENTION
    
      - `12` VIDEO_AUTO_BLACKLIST_FOR_MODERATORS
    
      - `13` NEW_INSTANCE_FOLLOWER
    
      - `14` AUTO_INSTANCE_FOLLOWING
    
      - `15` ABUSE_STATE_CHANGE
    
      - `16` ABUSE_NEW_MESSAGE
    
      - `17` NEW_PLUGIN_VERSION
    
      - `18` NEW_PEERTUBE_VERSION
    
      - `19` MY_VIDEO_STUDIO_EDITION_FINISHED
    
      - `20` NEW_USER_REGISTRATION_REQUEST
    
      - `21` NEW_LIVE_FROM_SUBSCRIPTION
    
      - `22` MY_VIDEO_TRANSCRIPTION_GENERATED
    
      - `23` INVITED_TO_COLLABORATE_TO_CHANNEL
    
      - `24` ACCEPTED_TO_COLLABORATE_TO_CHANNEL
    
      - `25` REFUSED_TO_COLLABORATE_TO_CHANNEL
    
      - `26` VIDEO_OWNERSHIP_CHANGED_REQUEST
    
      - `27` VIDEO_OWNERSHIP_CHANGED_ACCEPTED
    
      - `28` VIDEO_OWNERSHIP_CHANGED_REJECTED
    
      - `29` CHANNEL_OWNERSHIP_CHANGED_REQUEST
    
      - `30` CHANNEL_OWNERSHIP_CHANGED_ACCEPTED
    
      - `31` CHANNEL_OWNERSHIP_CHANGED_REJECTED
    
      - `32` AUTOMATIC_BLOCKLIST_UPDATE
    
      - `33` MY_VIDEO_STUDIO_EDITION_ERROR
    
      - `34` MY_VIDEO_DUPLICATION_ERROR
    
    
    enum: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34]

- `unread` (query, boolean, optional) - only list unread notifications
  Type: boolean

- `start` (query, integer, optional) - Offset used to paginate results
  Type: integer
  
  minimum: 0

- `count` (query, integer, optional) - Number of items to return
  Type: integer
  
  default: 15
  
  minimum: 1
  
  maximum: 100

- `sort` (query, string, optional) - Sort column
  Type: string
  
  Example:
  
  ```json
  "-createdAt"
  ```

Responses:

- 200: successful operation

Content type: application/json

Type: NotificationListResponse

Schema: [NotificationListResponse](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationlistresponse.md)

- `total` (optional)
  Type: integer
  
  Example:
  
  ```json
  1
  ```

- `data` (optional)
  Type: Array<Notification>
  
  maxItems: 100
  
  Items:
    Reference: [Notification](https://docs.joinpeertube.org/api-rest-reference/api/models/notification.md); Type: Notification

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/users/me/notifications?count=15' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/users/me/notifications?count=15', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://peertube2.cpy.re/api/v1/users/me/notifications?count=15',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Mark notifications as read by their id

`POST /api/v1/users/me/notifications/read`

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": []
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started


Request body: application/json

Type: object

- `ids` (required)
  Type: Array<integer>
  
  ids of the notifications to mark as read
  
  Items:
    Type: integer

Responses:

- 204: successful operation

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/users/me/notifications/read' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "ids": [
    0
  ]
}'
```

### JavaScript

```javascript
const body = `{
  "ids": [
    0
  ]
}`;

const response = await fetch('https://peertube2.cpy.re/api/v1/users/me/notifications/read', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "ids": [
    0
  ]
}'''

response = requests.post(
    'https://peertube2.cpy.re/api/v1/users/me/notifications/read',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```


## Mark all my notification as read

`POST /api/v1/users/me/notifications/read-all`

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": []
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started


Responses:

- 204: successful operation

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/users/me/notifications/read-all' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/users/me/notifications/read-all', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.post(
    'https://peertube2.cpy.re/api/v1/users/me/notifications/read-all',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Update my notification settings

`PUT /api/v1/users/me/notification-settings`

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": []
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started


Request body: application/json

Type: UserNotificationSettings

Schema: [UserNotificationSettings](https://docs.joinpeertube.org/api-rest-reference/api/models/usernotificationsettings.md)

- `abuseAsModerator` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `videoAutoBlacklistAsModerator` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `newUserRegistration` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `newVideoFromSubscription` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `blacklistOnMyVideo` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `myVideoPublished` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `myVideoImportFinished` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `commentMention` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `newCommentOnMyVideo` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `newFollow` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `newInstanceFollower` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `autoInstanceFollowing` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `abuseStateChange` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `abuseNewMessage` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `newPeerTubeVersion` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `newPluginVersion` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `myVideoStudioEditionFinished` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

- `myVideoTranscriptionGenerated` (optional)
  Reference: [NotificationSettingValue](https://docs.joinpeertube.org/api-rest-reference/api/models/notificationsettingvalue.md); Type: NotificationSettingValue
  
  Notification type. One of the following values, or a sum of multiple values:
  - `0` NONE
  - `1` WEB
  - `2` EMAIL
  

Responses:

- 204: successful operation

## Examples

### cURL

```bash
curl -X PUT 'https://peertube2.cpy.re/api/v1/users/me/notification-settings' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "abuseAsModerator": 0,
  "videoAutoBlacklistAsModerator": 0,
  "newUserRegistration": 0,
  "newVideoFromSubscription": 0,
  "blacklistOnMyVideo": 0,
  "myVideoPublished": 0,
  "myVideoImportFinished": 0,
  "commentMention": 0,
  "newCommentOnMyVideo": 0,
  "newFollow": 0,
  "newInstanceFollower": 0,
  "autoInstanceFollowing": 0,
  "abuseStateChange": 0,
  "abuseNewMessage": 0,
  "newPeerTubeVersion": 0,
  "newPluginVersion": 0,
  "myVideoStudioEditionFinished": 0,
  "myVideoTranscriptionGenerated": 0
}'
```

### JavaScript

```javascript
const body = `{
  "abuseAsModerator": 0,
  "videoAutoBlacklistAsModerator": 0,
  "newUserRegistration": 0,
  "newVideoFromSubscription": 0,
  "blacklistOnMyVideo": 0,
  "myVideoPublished": 0,
  "myVideoImportFinished": 0,
  "commentMention": 0,
  "newCommentOnMyVideo": 0,
  "newFollow": 0,
  "newInstanceFollower": 0,
  "autoInstanceFollowing": 0,
  "abuseStateChange": 0,
  "abuseNewMessage": 0,
  "newPeerTubeVersion": 0,
  "newPluginVersion": 0,
  "myVideoStudioEditionFinished": 0,
  "myVideoTranscriptionGenerated": 0
}`;

const response = await fetch('https://peertube2.cpy.re/api/v1/users/me/notification-settings', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "abuseAsModerator": 0,
  "videoAutoBlacklistAsModerator": 0,
  "newUserRegistration": 0,
  "newVideoFromSubscription": 0,
  "blacklistOnMyVideo": 0,
  "myVideoPublished": 0,
  "myVideoImportFinished": 0,
  "commentMention": 0,
  "newCommentOnMyVideo": 0,
  "newFollow": 0,
  "newInstanceFollower": 0,
  "autoInstanceFollowing": 0,
  "abuseStateChange": 0,
  "abuseNewMessage": 0,
  "newPeerTubeVersion": 0,
  "newPluginVersion": 0,
  "myVideoStudioEditionFinished": 0,
  "myVideoTranscriptionGenerated": 0
}'''

response = requests.put(
    'https://peertube2.cpy.re/api/v1/users/me/notification-settings',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
