zulip/templates/zerver/api/create-user.md
Eeshan Garg a0818975fb api/create-user: Test fixture for "email already in use" error.
In templates/zerver/api/create-user.md, we have a sample fixture
for when a client attempts to create a user with the same email
as an existing user. This commit adds a test for that fixture.

Note that this error payload is specific to client.create_user
and this error payload isn't generated anywhere else.
2018-02-20 14:54:12 -08:00

1.7 KiB

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

  • Python
  • JavaScript
  • 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"

{generate_code_example(python)|create-user|example(admin_config=True)}

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>

</div>

</div>

## Arguments

{generate_api_arguments_table|arguments.json|create-user.md}

## Response

#### Example response

A typical successful JSON response may look like:

{generate_code_example|create-user|fixture(successful_response)}

A typical JSON response for when another user with the same
email address already exists in the realm:

{generate_code_example|create-user|fixture(email_already_used_error)}