2018-01-08 19:48:53 +01:00
|
|
|
# Create a user
|
|
|
|
|
|
|
|
Create a new user in a realm.
|
|
|
|
|
|
|
|
**Note**: The requesting user must be an administrator.
|
|
|
|
|
|
|
|
`POST {{ api_url }}/v1/users`
|
|
|
|
|
|
|
|
## Usage examples
|
|
|
|
<div class="code-section" markdown="1">
|
|
|
|
<ul class="nav">
|
|
|
|
<li data-language="python">Python</li>
|
2018-01-13 23:40:45 +01:00
|
|
|
<li data-language="javascript">JavaScript</li>
|
2018-01-22 22:49:30 +01:00
|
|
|
<li data-language="curl">curl</li>
|
2018-01-08 19:48:53 +01:00
|
|
|
</ul>
|
|
|
|
<div class="blocks">
|
|
|
|
|
|
|
|
<div data-language="curl" markdown="1">
|
|
|
|
|
|
|
|
```
|
|
|
|
curl {{ api_url }}/v1/users \
|
|
|
|
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
|
|
|
|
-d "email=newbie@zulip.com" \
|
|
|
|
-d "full_name=New User" \
|
|
|
|
-d "short_name=newbie" \
|
|
|
|
-d "password=temp"
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div data-language="python" markdown="1">
|
|
|
|
|
2018-02-16 04:09:21 +01:00
|
|
|
{generate_code_example(python)|create-user|example(admin_config=True)}
|
2018-01-08 19:48:53 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2018-01-13 23:40:45 +01:00
|
|
|
<div data-language="javascript" markdown="1">
|
|
|
|
More examples and documentation can be found [here](https://github.com/zulip/zulip-js).
|
|
|
|
```js
|
|
|
|
const zulip = require('zulip-js');
|
|
|
|
|
|
|
|
// You need a zuliprc-admin with administrator credentials
|
|
|
|
const config = {
|
|
|
|
zuliprc: 'zuliprc-admin',
|
|
|
|
};
|
|
|
|
|
|
|
|
zulip(config).then((client) => {
|
|
|
|
// Create a user
|
|
|
|
const params = {
|
|
|
|
email: 'newbie@zulip.com',
|
|
|
|
password: 'temp',
|
|
|
|
full_name: 'New User',
|
|
|
|
short_name: 'newbie'
|
|
|
|
};
|
|
|
|
client.users.create(params).then(console.log);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
</div>
|
|
|
|
|
2018-01-08 19:48:53 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2018-01-20 22:03:05 +01:00
|
|
|
## Arguments
|
|
|
|
|
|
|
|
{generate_api_arguments_table|arguments.json|create-user.md}
|
|
|
|
|
2018-01-08 19:48:53 +01:00
|
|
|
## Response
|
|
|
|
|
|
|
|
#### Example response
|
|
|
|
|
|
|
|
A typical successful JSON response may look like:
|
|
|
|
|
2018-02-16 23:38:10 +01:00
|
|
|
{generate_code_example|create-user|fixture(successful_response)}
|
2018-01-08 19:48:53 +01:00
|
|
|
|
|
|
|
A typical JSON response for when another user with the same
|
|
|
|
email address already exists in the realm:
|
|
|
|
|
2018-02-16 23:38:10 +01:00
|
|
|
{generate_code_example|create-user|fixture(email_already_used_error)}
|