API Stability Preview

The assignUserRolesInSearchDomain() GraphQL mutation field is used to assigns roles for the user in the search domain. It allows assigning multiple roles for the same view and is thus dependent on the MultipleViewRoleBindings feature being enabled. This is a preview and subject to change.

Syntax

Below is the syntax for the assignUserRolesInSearchDomain() mutation field:

graphql
assignUserRolesInSearchDomain(
       input: AssignUserRolesInSearchDomainInput!
    ): [User!]!

Below is an example of how this mutation field might be used:

Raw
graphql
mutation {
  assignUserRolesInSearchDomain(input: 
            {searchDomainId: "aK9GKAsTnMXfRxT8Fpecx3fX", 
             roleAssignments: [{userId: "DScDf7IpfDeykSYW1B7AU48p" 
                                roleIds: ["wZ5KEIUY7kRFYDxlQZCHB72VZnFGsmIB"] } ] } )
       { id, 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 {
  assignUserRolesInSearchDomain(input: 
            {searchDomainId: \"aK9GKAsTnMXfRxT8Fpecx3fX\", 
             roleAssignments: [{userId: \"DScDf7IpfDeykSYW1B7AU48p\" 
                                roleIds: [\"wZ5KEIUY7kRFYDxlQZCHB72VZnFGsmIB\"] } ] } )
       { id, 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 {
  assignUserRolesInSearchDomain(input: 
            {searchDomainId: \"aK9GKAsTnMXfRxT8Fpecx3fX\", 
             roleAssignments: [{userId: \"DScDf7IpfDeykSYW1B7AU48p\" 
                                roleIds: [\"wZ5KEIUY7kRFYDxlQZCHB72VZnFGsmIB\"] } ] } )
       { id, 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 { ^
  assignUserRolesInSearchDomain(input:  ^
            {searchDomainId: \"aK9GKAsTnMXfRxT8Fpecx3fX\",  ^
             roleAssignments: [{userId: \"DScDf7IpfDeykSYW1B7AU48p\"  ^
                                roleIds: [\"wZ5KEIUY7kRFYDxlQZCHB72VZnFGsmIB\"] } ] } ) ^
       { id, username } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  assignUserRolesInSearchDomain(input: 
            {searchDomainId: \"aK9GKAsTnMXfRxT8Fpecx3fX\", 
             roleAssignments: [{userId: \"DScDf7IpfDeykSYW1B7AU48p\" 
                                roleIds: [\"wZ5KEIUY7kRFYDxlQZCHB72VZnFGsmIB\"] } ] } )
       { id, username }
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $INGEST_TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $json = '{"query" : "mutation {
  assignUserRolesInSearchDomain(input: 
            {searchDomainId: \"aK9GKAsTnMXfRxT8Fpecx3fX\", 
             roleAssignments: [{userId: \"DScDf7IpfDeykSYW1B7AU48p\" 
                                roleIds: [\"wZ5KEIUY7kRFYDxlQZCHB72VZnFGsmIB\"] } ] } )
       { id, username }
}"
}';
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 {
  assignUserRolesInSearchDomain(input: 
            {searchDomainId: \"aK9GKAsTnMXfRxT8Fpecx3fX\", 
             roleAssignments: [{userId: \"DScDf7IpfDeykSYW1B7AU48p\" 
                                roleIds: [\"wZ5KEIUY7kRFYDxlQZCHB72VZnFGsmIB\"] } ] } )
       { id, 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 {
  assignUserRolesInSearchDomain(input: 
            {searchDomainId: \"aK9GKAsTnMXfRxT8Fpecx3fX\", 
             roleAssignments: [{userId: \"DScDf7IpfDeykSYW1B7AU48p\" 
                                roleIds: [\"wZ5KEIUY7kRFYDxlQZCHB72VZnFGsmIB\"] } ] } )
       { id, username }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL/graphql',
  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();

Given Datatypes

For AssignUserRolesInSearchDomainInput, there are a few parameters. Below is a list of them:

Table: AssignUserRolesInSearchDomainInput

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Sep 17, 2024
roleAssignments[UserRoleAssignmentInput]yes PreviewThe user roles to assign in search domain. See UserRoleAssignmentInput.
searchDomainIdstringyes PreviewThe unique identifier of the search domain.

Returned Datatypes

The return datatype, User has several parameters. Below is a list of them:

Table: User

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Mar 25, 2025
allowedAssetActionsBySourcemultipleyes Preview

Get allowed asset actions for the user on a specific asset and explain how these actions have been granted.

The multiple datatype consists of (assetId: string!, assetType: AssetPermissionsAssetType!, searchDomainId: string): [AssetActionsBySource]!.

See AssetPermissionsAssetType, and AssetActionsBySource.

allowedOrganizationActions[OrganizationAction]yes Long-TermReturns the actions the user is allowed to perform in the organization. See OrganizationAction.
allowedSystemActions[SystemAction]yes Long-TermReturns the actions the user is allowed to perform in the system. See SystemAction Table.
companystring  Long-TermThe name of the company for the user account.
countryCodestring  Long-TermThe two-letter ISO 3166-1 Alpha-2 code for the country of residence (e.g., us).
createdAtdatetimeyes Long-TermThe data and time the account was created.
displayNamestringyes Long-TermThe value of the fullName if used, otherwise the username.
emailstring  Long-TermThe user account's email address for communications from LogScale.
firstNamestring  Long-TermThe user's actual first name (e.g., Bob). Don't use with fullName.
fullNamestring  Long-TermThe user's full name (e.g., Bob Smith). Don't use if using other name parameters.
groups[Group]yes Long-TermThe groups of which the user is a member. See Group.
groupSearchDomainRoles[GroupSearchDomainRole]yes Long-TermThe group search domain roles. See GroupSearchDomainRole.
groupsV2multiple  Preview

The groups of which the user is a member. This is a preview and subject to change.

The multiple datatype consists of (search: string, typeFilter: [PermissionType], limit: integer, skip: integer, searchInRoles: boolean): GroupResultSetType.

See PermissionType, and GroupResultSetType.

idstringyes Long-TermThe identifier or token for the user.
isOrgRootbooleanyes Long-TermWhether the organization is granted root access.
isRootbooleanyes Long-TermWhether the user account is granted root access.
lastNamestring  Long-TermThe user's actual last name or family name (e.g., Smith). Don't use with fullName.
permissionsmultipleyes Long-TermPermissions of the user. The multiple datatype consists of (viewName: string): [UserPermissions]. See UserPermissions.
permissionsPagemultipleyes DeprecatedA page of user permissions. The multiple datatype consists of (search: string, pageNumber: integer, pageSize: integer): UserPermissionsPage. See UserPermissionsPage. This field is no longer used. It will be removed at the earliest in version 1.208.
phoneNumberstring  Long-TermThe telephone number for LogScale to use for telephone text messages.
picturestring  Long-TermFile name of an image file for the account.
searchAssetPermissionsmultiple  Preview

Search for asset permissions for the user. This is a preview and subject to change.

The multiple datatype consists of (searchFilter: string, skip: integer, limit: integer, orderBy: OrderBy, sortBy: SortBy, assetTypes: [AssetPermissionsAssetType], searchDomainIds: [string], permissions: [AssetAction], searchDomainIds: [string], permissions: [AssetAction!]): AssetPermissionSearchResultSet.

See AssetPermissionsAssetType, AssetPermissionInputEnum, and AssetPermissionSearchResultSet.

searchDomainRolesmultiple  Long-TermThe search domain roles assigned to the user. The multiple datatype consists of (searchDomainId: string): [SearchDomainRole]. See SearchDomainRole.
searchDomainRolesByNamemultipleyes Deprecated

The search domain roles for the user, by name. The multiple datatype consists of (searchDomainName: string): SearchDomainRole. See SearchDomainRole.

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

searchDomainRolesBySearchDomainNamemultiple  Long-TermThe search domain roles assigned to the user by search domain name. The multiple datatype consists of (searchDomainName: string): [SearchDomainRole]. See SearchDomainRole.
stateCodestring  Long-TermThe two-letter, ISO 3166-2 country sub-division code for the state of residence (e.g., ny).
rolesV2multiple  Preview

The roles assigned to the user through a group. This is a preview and subject to change.

The multiple datatype consists of (search: string, typeFilter: [PermissionType], limit: integer, skip: integer, searchInGroups: boolean): RolesResultSetType.

See PermissionType, and RolesResultSetType.

usernamestringyes Long-TermThe user name for the account.
userOrGroupSearchDomainRolesmultipleyes Long-TermThe user or group search domain roles. The multiple datatype consists of (search: string, skip: integer, limit: integer, totalSearchDomains: integer): UserOrGroupSearchDomainRoleResultSet. See UserOrGroupSearchDomainRoleResultSet.