Summary

The updateUserById() mutation updates a user account in LogScale using the user's unique identifier. You can update properties such as the username, email address, and root access status. To update a user by username instead of by identifier, use updateUser().

Syntax

graphql
updateUserById(
      input: UpdateUserByIdInput!
   ): UpdateUserByIdMutation!

The mutation takes a single required input argument of type UpdateUserByIdInput!. Provide the user's unique identifier and the fields you want to update. Use users() to retrieve user identifiers.

The mutation returns a non-null UpdateUserByIdMutation! object.

Input parameters

Provide the unique identifier of the user account and the fields you want to update. Updatable fields include the username, email address, and root access status. Use users() to retrieve user identifiers before calling this mutation.

Table: UpdateUserByIdInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
companyString  Long-Term The name of the company or organization entity by which the user is affiliated.
countryCodeString  Long-Term The two-letter ISO 3166-1 Alpha-2 code for the country of residence (e.g., us).
emailString  Long-Term The email address of the user for contacting regarding the account.
firstNameString  Long-Term The first name of the user.
fullNameString  Long-Term The full name of the user.
isRootBoolean  Long-Term Whether the user being updated has root access.
lastNameString  Long-Term The last name or family name of the user.
pictureString  Long-Term The name of an image file containing a photograph of the user.
stateCodeString  Long-Term The two-letter, ISO 3166-2 country sub-division code for the state of residence (e.g., ny).
userIdStringyes Long-Term The unique identifier of the user to update.
usernameString  Long-Term The username for the account to update.

Example

Raw
graphql
mutation {
  updateUserById( input:
       { userId: "abc123",
         isRoot: true        
      } )
  { user { username } }
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  updateUserById( input:
       { userId: \"abc123\",
         isRoot: true        
      } )
  { user { username } }
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  updateUserById( input:
       { userId: \"abc123\",
         isRoot: true        
      } )
  { user { username } }
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "mutation { ^
  updateUserById( input: ^
       { userId: \"abc123\", ^
         isRoot: true         ^
      } ) ^
  { user { username } } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  updateUserById( input:
       { userId: \"abc123\",
         isRoot: true        
      } )
  { user { username } }
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $query = "mutation {
  updateUserById( input:
       { userId: \"abc123\",
         isRoot: true        
      } )
  { user { username } }
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "mutation {
  updateUserById( input:
       { userId: \"abc123\",
         isRoot: true        
      } )
  { user { username } }
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "mutation {
  updateUserById( input:
       { userId: \"abc123\",
         isRoot: true        
      } )
  { user { username } }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL',
  path: 'graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "updateUserById": {
      "user": {
        "username": "bob"
      }
    }
  }
}

Returned values

The returned UpdateUserByIdMutation! object provides fields for the updated user account. Available sub-fields include standard user properties such as the username and email address, as well as root access status, permissions, group memberships, and asset access. The following table lists the available sub-fields.

Table: UpdateUserByIdMutation Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
userUseryes Long-Term The user to update based on the unique identifier of the user. See User.

The UpdateUserByIdMutation type includes a user field that returns the full User datatype. The following table describes the fields available on that sub-type.

Table: User Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
allowedOrganizationActionsOrganizationActionyes Long-Term Returns the actions the user is allowed to perform in the organization. See OrganizationAction .
allowedSystemActionsSystemActionyes Long-Term Returns the actions the user is allowed to perform in the system. See SystemAction Table.
assetIdString,yes   Id of the asset
assetTypeAssetPermissionsAssetType,yes   The type of the asset.
assetTypesAssetPermissionsAssetType],yes   List of asset types
companyString  Long-Term The name of the company for the user account.
countryCodeString  Long-Term The two-letter ISO 3166-1 Alpha-2 code for the country of residence (e.g., us).
createdAtDateTimeyes Long-Term The data and time the account was created.
displayNameStringyes Long-Term The value of the fullName if used, otherwise the username.
emailString  Long-Term The user account's email address for communications from LogScale.
externalUsernameString  Long-Term Readable username for when user stems from Falcon Stability: Long-term
firstNameString  Long-Term The user's actual first name (e.g., Bob). Don't use with fullName.
fullNameString  Long-Term The user's full name (e.g., Bob Smith). Don't use if using other name parameters.
groupSearchDomainRolesGroupSearchDomainRoleyes Long-Term The group search domain roles. See GroupSearchDomainRole.
groupsGroupyes Long-Term The groups of which the user is a member. See Group.
idStringyes Long-Term The identifier or token for the user.
isOrgRootBooleanyes Long-Term Whether the organization is granted organization ownership.
isRootBooleanyes Long-Term Whether the user account is granted root access.
lastNameString  Long-Term The user's actual last name or family name (e.g., Smith). Don't use with fullName.
limitInt,    The amount of results to return.
orderByOrderBy,    Choose the order in which the results are returned.
permissionsAssetAction]):AssetPermissionSearchResultSetyes Short-Term Permissions of the user. See UserPermissions.
phoneNumberString  Long-Term The telephone number for LogScale to use for telephone text messages.
pictureString  Long-Term File name of an image file for the account.
searchDomainIdString):[AssetActionsBySourceyes Short-Term Search domain id
searchDomainIdsString],yes   List of search domain id's to search within. Null or empty list is interpreted as all search domains
searchDomainRoles(searchDomainId: String)SearchDomainRoleyes Long-Term The search domain roles assigned to the user. See SearchDomainRole.
searchDomainRolesByName(searchDomainName: String!)SearchDomainRole  Deprecateddeprecated in 1.195

The search domain roles for the user, by name. See SearchDomainRole.

This field is deprecated because when multiple roles per view is enabled, it will return only the first of possibly multiple roles matching the name for the view. Use instead searchDomainRoles or searchDomainRolesBySearchDomainName.

searchDomainRolesBySearchDomainName(searchDomainName: String!)SearchDomainRoleyes Long-Term The search domain roles assigned to the user by search domain name. See SearchDomainRole.
searchFilterString,    Filter results based on this string
skipInt,searchInRoles:Boolean):GroupResultSetTypeyes Short-Term The number of results to skip or the offset to use. For instance if implementing pagination, set skip = limit * (page - 1)
sortBySortBy,    The sort by options for assets. Asset name is default
stateCodeString  Long-Term The two-letter, ISO 3166-2 country sub-division code for the state of residence (e.g., ny).
usernameStringyes Long-Term The user name for the account.
viewNameString):[UserPermissionsyes Long-Term Exact name of the repo to find permissions for.