# Update avatar

`PUT /u/{username}/preferences/avatar/pick.json`

Authentication: no security requirement declared for this operation.

Parameters:

- `username` (path, string, required)
  Type: string

Request body: application/json

Type: any

- `upload_id` (optional)
  Type: integer

- `associated_account_id` (optional)
  Type: integer

- `type` (required)
  Type: string

oneOf:
  Type: any
  
  - `type` (optional)
    Type: any
    
    enum: ["uploaded","custom","gravatar","current"]

  Type: any
  
  - `type` (optional)
    Type: any
    
    enum: ["associated_account"]

  Type: any
  
  - `type` (optional)
    Type: any
    
    enum: ["system"]

Additional properties: false

Responses:

- 200: avatar updated

Content type: application/json

Type: any

- `success` (required)
  Type: string
  
  Example:
  
  ```json
  "OK"
  ```

Additional properties: false

## Examples

### cURL

```bash
curl -X PUT 'https://discourse.example.com/u/string/preferences/avatar/pick.json' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "type": "uploaded"
}'
```

### JavaScript

```javascript
const body = `{
  "type": "uploaded"
}`;

const response = await fetch('https://discourse.example.com/u/string/preferences/avatar/pick.json', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
  },
  body,
});

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

### Python

```python
import requests

body = '''{
  "type": "uploaded"
}'''

response = requests.put(
    'https://discourse.example.com/u/string/preferences/avatar/pick.json',
    data=body.encode('utf-8'),
    headers={
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
