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
|
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{start_tabs}
|
|
|
|
{tab|python}
|
2018-01-08 19:48:53 +01:00
|
|
|
|
2018-06-21 01:47:22 +02:00
|
|
|
{generate_code_example(python)|/users:post|example(admin_config=True)}
|
2018-01-08 19:48:53 +01:00
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{tab|js}
|
2018-01-08 19:48:53 +01:00
|
|
|
|
2018-01-13 23:40:45 +01:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{tab|curl}
|
|
|
|
|
|
|
|
```
|
|
|
|
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"
|
|
|
|
|
|
|
|
```
|
2018-01-08 19:48:53 +01:00
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{end_tabs}
|
2018-01-08 19:48:53 +01:00
|
|
|
|
2018-01-20 22:03:05 +01:00
|
|
|
## Arguments
|
|
|
|
|
2018-06-21 01:47:22 +02:00
|
|
|
{generate_api_arguments_table|zulip.yaml|/users:post}
|
2018-01-20 22:03:05 +01:00
|
|
|
|
2018-01-08 19:48:53 +01:00
|
|
|
## Response
|
|
|
|
|
|
|
|
#### Example response
|
|
|
|
|
|
|
|
A typical successful JSON response may look like:
|
|
|
|
|
2018-06-21 01:47:22 +02:00
|
|
|
{generate_code_example|/users:post|fixture(200)}
|
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-06-21 01:47:22 +02:00
|
|
|
{generate_code_example|/users:post|fixture(400)}
|