var newContent = {
  profileIds: ['admin'],
  firstname: 'My Name Is',
  lastname: 'Jonas'

// Using callbacks (NodeJS or Web Browser)
  .replaceUser("User ID", newContent, function (err, replacedUser) {
    // "replacedUser" is an instance of a User object
JSONObject newContent = new JSONObject()
  .put("profileIds", new JSONArray()
  .put("firstname", "My Name Is")
  .put("lastname", "Jonas");

  .replaceUser("User ID", newContent, new ResponseListener<User>() {
    public void onSuccess(User user) {


    public void onError(JSONObject error) {


use \Kuzzle\Kuzzle;
use \Kuzzle\Security\User;

$kuid = 'myUser';
$userDefinition = [
  'profileIds' => ['admin'],
  'firstname' => 'My Name Is',
  'lastname' => 'Jonas'

$kuzzle = new Kuzzle('localhost');
$security = $kuzzle->security();

try {
  $user = $security->replaceUser($kuid, $userDefinition);

  // $user instanceof User
catch (ErrorException $e) {


Replaces an existing user.

replaceUser(id, content, [options], [callback])

idstringUnique user identifier
contentJSON ObjectA plain JSON object representing the user, should contain the mandatory profileIds field
optionsstring(Optional) Optional arguments
callbackfunction(Optional) Callback handling the response


queuablebooleanMark this request as (not) queuabletrue
refreshstringIf set to wait_for, Kuzzle will wait the persistence layer indexation to return (available with Elasticsearch 5.x and above)undefined

Return value

Returns the Security object to allow chaining.

Callback response

Resolves to an User object