Skip to main content

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

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the user to update

Request Body

FieldTypeRequiredDescription
first_nameStringNoFirst name of the user.
last_nameStringNoLast name of the user.
usernameStringNoUsername (must be unique).
mobile_numberStringNoMobile phone number.
emailStringNoEmail address (must be unique).
genderStringNoGender of the user.(`male`, `female`)
avatarFileNoAvatar image file to upload.

Example Requests

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)

Status Codes

CodeDescription
200User updated successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the user.
usernameStringUsername of the user.
mobile_numberStringMobile phone number of the user.
emailStringEmail address of the user.
avatarStringURL to the user's avatar image.
first_nameStringFirst name of the user.
last_nameStringLast name of the user.
full_nameStringFull name (first + last name).
genderStringGender of the user.
groupsArrayArray of group IDs the user belongs to.
last_loginString (ISO 8601)Timestamp of the user's last login.
created_atString (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 avatar field must be a valid image file (e.g., JPG, PNG).
    • Set null to avatar if the user wants to remove their current avatar.