Update a user

This endpoint is only available to organization administrators.

Administrative endpoint to update the details of another user in the organization.

PATCH https://nieuwhw.zulip.yocto.eu/api/v1/users/{user_id}

Supports everything an administrator can do to edit details of another user's account, including editing full name, role, and custom profile fields.

Usage examples

#!/usr/bin/env python

import zulip

# The user for this zuliprc file must be an organization administrator
client = zulip.Client(config_file="~/zuliprc-admin")

# Change a user's full name.
user_id = 10
result = client.update_user_by_id(user_id, full_name="New Name")
# Change value of the custom profile field with ID 9.
user_id = 8
result = client.update_user_by_id(user_id, profile_data=[{"id": 9, "value": "some data"}])
print(result)

curl -sSX PATCH https://nieuwhw.zulip.yocto.eu/api/v1/users/12 \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY \
    --data-urlencode full_name=NewName \
    --data-urlencode role=400 \
    --data-urlencode 'profile_data=[{"id": 4, "value": "vim"}, {"id": 5, "value": "1909-04-05"}]'

Parameters

user_id integer required in path

Example: 12

The target user's ID.


full_name string optional

Example: "NewName"

The user's full name.

Changes: Removed unnecessary JSON-encoding of this parameter in Zulip 5.0 (feature level 106).


role integer optional

Example: 400

New role for the user. Roles are encoded as:

  • Organization owner: 100
  • Organization administrator: 200
  • Organization moderator: 300
  • Member: 400
  • Guest: 600

Only organization owners can add or remove the owner role.

The owner role cannot be removed from the only organization owner.

Changes: New in Zulip 3.0 (feature level 8), replacing the previous pair of is_admin and is_guest boolean parameters. Organization moderator role added in Zulip 4.0 (feature level 60).


profile_data (object)[] optional

Example: [{"id": 4, "value": "vim"}, {"id": 5, "value": "1909-04-05"}]

A dictionary containing the to be updated custom profile field data for the user.


Response

Example response

A typical successful JSON response may look like:

{
    "msg": "",
    "result": "success"
}

A typical unsuccessful JSON response:

{
    "code": "BAD_REQUEST",
    "msg": "Guests cannot be organization administrators",
    "result": "error"
}