Update Me
Update an existing user.
HTTP Request
PATCH/api/users/me
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the user to update |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| first_name | String | No | First name of the user. |
| last_name | String | No | Last name of the user. |
| username | String | No | Username (must be unique). |
| mobile_number | String | No | Mobile phone number. |
| String | No | Email address (must be unique). | |
| gender | String | No | Gender of the user.(`male`, `female`) |
| avatar | File | No | Avatar image file to upload. |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3api = requests.Session()
4api.headers.update({'Authorization': 'Token f4e75eab6e0f663a972d145478d6fc4b81762070'})
5response = api.put(
6 'http://www.example.com/api/users/me/',
7 json={
8 'first_name': 'Alexandra',
9 'last_name': 'Thompson',
10 'username': 'alex_thompson',
11 'mobile_number': '+1-555-0124',
12 'email': 'alexandra.thompson@techcorp.com',
13 'gender': 'female',
14 'avatar': open('path/to/avatar.jpg', 'rb')
15 }
16)1curl "http://www.example.com/api/users/me/" -X PUT -H "Authorization: Token XXXXXXXXXXXXXXXXXXXXXX" -H "Content-Type: application/json" -d '{
2 "first_name": "Alexandra",
3 "last_name": "Thompson",
4 "username": "alex_thompson",
5 "mobile_number": "+1-555-0124",
6 "email": "alexandra.thompson@techcorp.com",
7 "gender": "female",
8 "avatar": open('path/to/avatar.jpg', 'rb')
9}'Status Codes
| Code | Description |
|---|---|
| 200 | User updated successfully |
| 400 | Bad request — invalid input |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the user. |
| username | String | Username of the user. |
| mobile_number | String | Mobile phone number of the user. |
| String | Email address of the user. | |
| avatar | String | URL to the user's avatar image. |
| first_name | String | First name of the user. |
| last_name | String | Last name of the user. |
| full_name | String | Full name (first + last name). |
| gender | String | Gender of the user. |
| groups | Array | Array of group IDs the user belongs to. |
| last_login | String (ISO 8601) | Timestamp of the user's last login. |
| created_at | String (ISO 8601) | Timestamp when the user was created. |
Example Response
{
"id": 42,
"username": "alex_thompson",
"mobile_number": "+1-555-0123",
"email": "alex.thompson@techcorp.com",
"avatar": "http://www.example.com/media/avatars/alex_profile.jpg",
"first_name": "Alex",
"last_name": "Thompson",
"full_name": "Alex Thompson",
"gender": "non-binary",
"groups": [1, 3, 7],
"last_login": "2025-08-06T14:23:45.123456Z",
"created_at": "2024-03-15T09:30:00.000000Z"
}
Notes
- The
avatarfield must be a valid image file (e.g., JPG, PNG). - Set null to
avatarif the user wants to remove their current avatar.