API – User Creation
- To create a user you need to send POST request to the following URI /api/v2/users/create
- The body of the request must contain a JSON object with information about the user.
- The request must contain the headings Content-Type: application/json;charset=UTF-8 and Authorization: Bearer xxxxxx.
Request example:
curl 'https://your-domain.com/api/v2/users/create'--data-binary '{"secondname":"Smith", "firstname":"John", "patronymic":"", "login":"john.smith", "email":"[email protected]", "password":"123456", "spassword":123456, "birth_date":"26.07.1988", "gender":0, "is_active":1, "city":"Kyiv", "department":"Main Office", "position":"CEO", "tags":["tag1,tag2"], "phone":"0971111111"} -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8'
Format of the object with user information
* Mandatory fields are marked with an asterisk
Field | Type | Descriprion |
---|---|---|
secondname* | String | Second name |
firstname* | String | First name |
patronymic | String | Third name |
login* | String | Login |
email* | String | |
password* | String | Password |
spassword* | String | Password confirmation |
birth_date | String | Date of birth, in the format DD.MM.YYYYY or YYYY-MM-DD, for example 26.07.1988 or 1988-07-26 |
gender | Number | Gender, 0 - male, 1 - female, if the field is not set - it is ignored |
is_active | Number | Checkbox indicates whether the user is enabled in the system, 1 - enabled, 0 - disabled |
city | String | City |
department | String | Department |
position | String | Position |
phone | String | Phone number, in international format, for example +380971234567 |
tags | String | A list of comma-separated tags |
Answer
-
In case of successful request (HTTP response code - 200), there will be reply in JSON format with information about created user:
{"id":1234,"login":"john.smith","firstname":"John","secondname":"Smith","email":"[email protected]"...}
-
In case of error (HTTP response code - 400) it returns JSON object with error information:
{"email":{"required":"Field cannot be empty","email":"Invalid email"}}