Add User
To create a new user account, use the following request:
POST /users.xml
POST /users.json
XML Request Example
curl -i -X POST -d '<user><login>111111losj</login><email>MailTestApi@testmatil.com</email><first_name>TestApiName</first_name><last_name>TestAPIName</last_name><password>password_test1</password><user_group_id>1</user_group_id><bucket_id type="integer">1</bucket_id><role_ids type="array"><role_id>1</role_id></role_ids><additional_fields type="array"><additional_field><name>additional_field_name</name><value>custom_value</value></additional_field></additional_fields><time_zone>Kyiv</time_zone><locale>en</locale></user>' -u user:userpass http://onapp.test/users.xml -H 'Accept: application/xml' -H 'Content-type: application/xml'
JSON Request Example
curl -i -X POST -d '{"user":{"login":"111111losj","email":"1111111losj@test.test","first_name":"1111","last_name":"1311","password":"password_test1","user_group_id":"1","bucket_id":"1","role_ids":["1","2"], "additional_fields":[{"additional_field":{"name":"additional_field_name","value":"custom_value"}}]}}' -u user:userpass http://onapp.test/users.json -H 'Accept: application/json' -H 'Content-type: application/json'
Returns HTTP 201 on successful creation, or HTTP 422 if a user with such a login/email already exists.
Where:
email* - user's email address
login* - login of the user. It can consist of 2-40 characters, letters [A-Za-z], digits [0-9], dash [ - ], lower dash [ _ ], [@]. You can use both lower- and uppercase letters. The dash [ - ] and [@] symbols are not allowed as first characters of the login name.
password* - user's password. (min – 6 characters)
first_name - user's first name
last_name - user's last name
role – assigns a role to a user
time_zone - time zone of the user. Set by default
locale - local of the user. Set by default
status – user's status (active, suspended, etc)
bucket_id – set by default, if not selected
additional field – an array of custom fields assigned to the user, where:
- name - the name of a particular additional field
- value - the value which you want to assign to this additional field
role_ids – an array of the role IDs, assigned to the user
user_group_id – ID of the group, to which the user is attached
suspend_after_hours – time in hours, after which the user will be suspended
suspend_at – time in [YYYY][MM][DD] T[hh][mm][ss]Z format, when the user will be suspended
Page History
v. 4.0
- the login length decreased to two symbols
v. 3.1
- first_name and last_name are no longer required parameters