Skip to main content

Create User

Create a new user.

HTTP Request

POST/api/users/
NOTE: NOT USING THE TRAILING SLASH AT THE END OF THE URL RESULTS TO A 500 SERVER ERROR

Authorization

Authorization

  • Required: Yes
  • Permission: Staff with UserPermission or Admin
  • Permission Code: 1221
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Request Body

FieldTypeRequiredDescription
usernameStringYesUnique username for the user.
passwordStringNoPassword for the user account.
mobile_numberStringNoMobile phone number of the user.
emailStringNoEmail address of the user (nullable).
is_email_verifiedBooleanNoIf the email number is a verified one (default=false)
avatarFileNoUser profile avatar image
first_nameStringNoFirst name of the user.
last_nameStringNoLast name of the user.
genderStringNoGender of the user (`male`, `female`, `other`) (Default Male)
invited_byIntegerNoid of the inviting user (nullable)
is_staffBooleanNoWhether user has staff privileges (default: false).
is_adminBooleanNoWhether user has admin privileges (default: false).
is_activeBooleanNoWhether user account is active (default: true).
groupsArrayNoList of group IDs the user belongs to.
permissionsArrayNoList permissions IDs the the user have

Example Requests

1import requests
2
3api = requests.Session()
4api.headers.update({'Authorization': 'Token f4e75eab6e0f663a972d145478d6fc4b81762070'})
5response = api.post(
6  'http://www.example.com/api/users/',
7  json={
8      'username': 'michael_chen',
9      'password': 'SecurePass123!',
10      'mobile_number': '09113235256',
11      'email': 'michael.chen@techcorp.com',
12      'first_name': 'Michael',
13      'last_name': 'Chen',
14      'gender': 'male',
15      'is_staff': True,
16      'is_admin': False,
17      'is_active': True,
18      'groups': [1, 3]
19  }
20)

Response Fields

FieldTypeDescription
idIntegerUnique ID of the user (unique)
usernameStringUsername of the user (unique)
mobile_numberStringMobile phone number of the user(unique, nullable)
emailStringEmail address of the user(unique, nullable)
is_email_verifiedBooleanShows if the email has been verified
avatarStringURL to the user's avatar image (nullable).
first_nameStringFirst name of the user(nullable)
last_nameStringLast name of the user(nullable)
full_nameStringFull name (nullable).
genderStringGender of the user.(male/female/other)
invited_byObject(InvitingUser)User who has invited current user
invite_codeStringRelated invite code of the user (nullable)
invitees_countIntegerNumber of users invited by the current user(nullable)
is_activeBooleanWhether user account is active.
is_staffBooleanWhether user has staff privileges.
is_adminBooleanWhether user has admin privileges.
is_profile_completedBooleanWhether user profile data are complete or not
last_loginString (ISO 8601)Timestamp of last login (null for new users).
created_atString (ISO 8601)Timestamp when user was created.
updated_atString (ISO 8601)Timestamp when user was last updated.
is_onlineBooleanWhether user is currently online.
inviteesObject(InvitedUsers)List of invited users
groups_dataArray[Object]Array of group objects with detailed info.
permissions_dataArray[Ojbect(Permission)]Array of permissions objects the user have

Group Data Structure

FieldTypeDescription
idIntegerUnique ID of the group
nameStringName of the group

InvitedUsers/InvitingUser object Structure

FieldTypeDescription
idIntegerUnique ID of the inviting/invited user
usernameStringUsername of the inviting/invited user
fullnamdStringFullname of the inviting/invited user

Permission Data Structure

FieldTypeDescription
idIntegerUnique ID of the permission
codeIntegerUnique code of the permission
nameStringName of the permission

Example Response

{
{
"id": 3,
"username": "Eve68",
"mobile_number": "09521206685",
"email": "Roosevelt.Nader8@yahoo.com",
"is_email_verified": false,
"avatar": null,
"first_name": "پارسا",
"last_name": "حسینی‌نژاد",
"full_name": "پارسا حسینی‌نژاد",
"gender": "male",
"invited_by": null,
"invite_code": null,
"invitees_count": 0,
"is_active": true,
"is_staff": true,
"is_admin": true,
"is_online": true,
"is_profile_completed": true,
"last_login": "2026-02-21T07:28:51.981082Z",
"created_at": "2026-02-21T07:28:52.460757Z",
"updated_at": "2026-02-21T07:28:52.460765Z",
"invitees": [],
"groups_data": [],
"permissions_data": [
{
"id": 1,
"code": 1001,
"name": "general_settings_read"
},
{
"id": 2,
"code": 1002,
"name": "general_settings_update"
},
{
"id": 3,
"code": 1006,
"name": "cache_settings_read"
}
]
}
}

Notes

    • Not using the trailing slash / at the end of the url results to a 500 server error
    • Users must either have admin or staff privileges, so one of them should be set to true
    • The full_name field is automatically generated from first_name and last_name.
    • The groups field should contain valid group IDs that already exist in the system.
    • email and is_email_verified are unique together, meaning multiple users may use a duplicate email for themselves, hence only one of them can verify the email.
    • permissions field should contain valid permission IDs that already exist in the system.