# Update my user information

`PUT /api/v1/users/me`

Authentication (security requirement alternatives):

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

- 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
; scopes: user

Request body: application/json (required)

Type: UpdateMe

Schema: [UpdateMe](https://sourcey-peertube.pages.dev/api-rest-reference/models/updateme.md)

- `password` (optional)
  Reference: [password](https://sourcey-peertube.pages.dev/api-rest-reference/models/password.md); Type: password, password
  
  minLength: 6
  
  maxLength: 50

- `currentPassword` (optional)
  Reference: [password](https://sourcey-peertube.pages.dev/api-rest-reference/models/password.md); Type: password, password
  
  minLength: 6
  
  maxLength: 50

- `email` (optional)
  Type: email
  
  new email used for login and service communications
  
  allOf:
    Type: email, email
    
    The user email

- `displayName` (optional)
  Type: string
  
  new name of the user in its representations
  
  minLength: 3
  
  maxLength: 120

- `nsfwPolicy` (optional)
  Type: string
  
  new NSFW display policy
  
  enum: ["true","false","both"]

- `nsfwFlagsDisplayed` (optional)
  Reference: [NSFWFlag](https://sourcey-peertube.pages.dev/api-rest-reference/models/nsfwflag.md); Type: NSFWFlag
  
  
  NSFW flags (can be combined using bitwise or operator)
  - `0` NONE
  - `1` VIOLENT
  - `2` EXPLICIT_SEX
  
  
  enum: [0,1,2,4]

- `nsfwFlagsHidden` (optional)
  Reference: [NSFWFlag](https://sourcey-peertube.pages.dev/api-rest-reference/models/nsfwflag.md); Type: NSFWFlag
  
  
  NSFW flags (can be combined using bitwise or operator)
  - `0` NONE
  - `1` VIOLENT
  - `2` EXPLICIT_SEX
  
  
  enum: [0,1,2,4]

- `nsfwFlagsWarned` (optional)
  Reference: [NSFWFlag](https://sourcey-peertube.pages.dev/api-rest-reference/models/nsfwflag.md); Type: NSFWFlag
  
  
  NSFW flags (can be combined using bitwise or operator)
  - `0` NONE
  - `1` VIOLENT
  - `2` EXPLICIT_SEX
  
  
  enum: [0,1,2,4]

- `nsfwFlagsBlurred` (optional)
  Reference: [NSFWFlag](https://sourcey-peertube.pages.dev/api-rest-reference/models/nsfwflag.md); Type: NSFWFlag
  
  
  NSFW flags (can be combined using bitwise or operator)
  - `0` NONE
  - `1` VIOLENT
  - `2` EXPLICIT_SEX
  
  
  enum: [0,1,2,4]

- `aiUsagesHidden` (optional)
  Type: Array<VideoAIUsageSet>
  
  **PeerTube >= 9.0** Videos with these AI usages are hidden from video lists
  
  Items:
    Reference: [VideoAIUsageSet](https://sourcey-peertube.pages.dev/api-rest-reference/models/videoaiusageset.md); Type: VideoAIUsageSet
    
    **PeerTube >= 9.0** Use of AI in the video, declared by the video creator:
      - `1` Not specified
      - `2` No AI-generated content: nothing seen or heard in the video has been generated by AI
      - `3` Contains AI-generated content: some parts of the video have been generated by AI
      - `4` AI-generated: the whole video, or most of it, has been generated by AI
    
    
    enum: [1,2,3,4]

- `p2pEnabled` (optional)
  Type: boolean
  
  whether to enable P2P in the player or not

- `autoPlayVideo` (optional)
  Type: boolean
  
  new preference regarding playing videos automatically

- `autoPlayNextVideo` (optional)
  Type: boolean
  
  new preference regarding playing following videos automatically

- `autoPlayNextVideoPlaylist` (optional)
  Type: boolean
  
  new preference regarding playing following playlist videos automatically

- `videosHistoryEnabled` (optional)
  Type: boolean
  
  whether to keep track of watched history or not

- `videoLanguages` (optional)
  Type: Array<string>
  
  list of languages to filter videos down to
  
  Items:
    Type: string

- `videoCategories` (optional)
  Type: Array<integer>; nullable
  
  list of categories to filter videos down to (`null` means all categories)
  
  Items:
    Type: integer

- `videoLive` (optional)
  Type: string
  
  filter videos down to lives (`true`), VODs (`false`) or display both
  
  enum: ["true","false","both"]

- `language` (optional)
  Type: string
  
  default language for this user

- `theme` (optional)
  Type: string

- `noInstanceConfigWarningModal` (optional)
  Type: boolean

- `noAccountSetupWarningModal` (optional)
  Type: boolean

- `noWelcomeModal` (optional)
  Type: boolean

Responses:

- 204: successful operation

## Examples

### cURL

```bash
curl -X PUT 'https://peertube2.cpy.re/api/v1/users/me' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "password": "********",
  "currentPassword": "********",
  "displayName": "string",
  "nsfwPolicy": "true",
  "nsfwFlagsDisplayed": 0,
  "nsfwFlagsHidden": 0,
  "nsfwFlagsWarned": 0,
  "nsfwFlagsBlurred": 0,
  "aiUsagesHidden": [
    1
  ],
  "p2pEnabled": true,
  "autoPlayVideo": true,
  "autoPlayNextVideo": true,
  "autoPlayNextVideoPlaylist": true,
  "videosHistoryEnabled": true,
  "videoLanguages": [
    "string"
  ],
  "videoCategories": [
    0
  ],
  "videoLive": "true",
  "language": "string",
  "theme": "string",
  "noInstanceConfigWarningModal": true,
  "noAccountSetupWarningModal": true,
  "noWelcomeModal": true
}'
```

### JavaScript

```javascript
const body = `{
  "password": "********",
  "currentPassword": "********",
  "displayName": "string",
  "nsfwPolicy": "true",
  "nsfwFlagsDisplayed": 0,
  "nsfwFlagsHidden": 0,
  "nsfwFlagsWarned": 0,
  "nsfwFlagsBlurred": 0,
  "aiUsagesHidden": [
    1
  ],
  "p2pEnabled": true,
  "autoPlayVideo": true,
  "autoPlayNextVideo": true,
  "autoPlayNextVideoPlaylist": true,
  "videosHistoryEnabled": true,
  "videoLanguages": [
    "string"
  ],
  "videoCategories": [
    0
  ],
  "videoLive": "true",
  "language": "string",
  "theme": "string",
  "noInstanceConfigWarningModal": true,
  "noAccountSetupWarningModal": true,
  "noWelcomeModal": true
}`;

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

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

### Python

```python
import requests

body = '''{
  "password": "********",
  "currentPassword": "********",
  "displayName": "string",
  "nsfwPolicy": "true",
  "nsfwFlagsDisplayed": 0,
  "nsfwFlagsHidden": 0,
  "nsfwFlagsWarned": 0,
  "nsfwFlagsBlurred": 0,
  "aiUsagesHidden": [
    1
  ],
  "p2pEnabled": true,
  "autoPlayVideo": true,
  "autoPlayNextVideo": true,
  "autoPlayNextVideoPlaylist": true,
  "videosHistoryEnabled": true,
  "videoLanguages": [
    "string"
  ],
  "videoCategories": [
    0
  ],
  "videoLive": "true",
  "language": "string",
  "theme": "string",
  "noInstanceConfigWarningModal": true,
  "noAccountSetupWarningModal": true,
  "noWelcomeModal": true
}'''

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