Summary

The removeUserById() mutation removes a user account from LogScale using the user's unique system identifier. Use this mutation when you have the user's ID but not their username. To remove a user by username instead, use the removeUser() mutation.

Syntax

graphql
removeUserById(
      input: RemoveUserByIdInput!
   ): RemoveUserByIdMutation!

The mutation takes a single required input object. Provide the unique system identifier of the user account to remove in the id argument. Use the users() query to retrieve user IDs before calling this mutation. See the Input Parameters section for details.

The mutation returns a non-null RemoveUserByIdMutation object. Request the user field to confirm the removed user's identity and access the account data as it existed at the time of removal. The user field is always populated.

Example

Raw
graphql
mutation {
  removeUserById(input:
     { id: "abc123" } 
  )
  { user { id, firstName } }
}
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 {
  removeUserById(input:
     { id: \"abc123\" } 
  )
  { user { id, firstName } }
}"
}
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 {
  removeUserById(input:
     { id: \"abc123\" } 
  )
  { user { id, firstName } }
}"
}
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 { ^
  removeUserById(input: ^
     { id: \"abc123\" }  ^
  ) ^
  { user { id, firstName } } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  removeUserById(input:
     { id: \"abc123\" } 
  )
  { user { id, firstName } }
}"
}'
    "$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 {
  removeUserById(input:
     { id: \"abc123\" } 
  )
  { user { id, firstName } }
}";
$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 {
  removeUserById(input:
     { id: \"abc123\" } 
  )
  { user { id, firstName } }
}"
}'''

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 {
  removeUserById(input:
     { id: \"abc123\" } 
  )
  { user { id, firstName } }
}"
}
);


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": {
    "removeUserById": {
      "user": {
        "id": "abc123",
        "firstName": "Bob"
      }
    }
  }
}

Input Parameters

The input requires a single argument: the unique system-assigned identifier of the user to remove. User IDs are opaque strings assigned by LogScale — they are not usernames or email addresses. Use the users() query to retrieve user IDs before calling this mutation.

Table: RemoveUserByIdInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
idStringyes Long-Term The unique identifier of the user to be removed.

Returned Values

The mutation returns a RemoveUserByIdMutation object with two fields. The user field is non-null and returns the removed account's complete User record, including profile details, permissions, group memberships, and asset access information as they existed at the time of removal. Request fields from user to confirm the deletion, record the account data for auditing, or trigger downstream cleanup operations. The clientMutationId field is an optional string available since version 1.106 for relay-style clients that need to correlate mutation requests with responses.

Table: RemoveUserByIdMutation Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
userUseryes Long-Term The user to remove from the mutation. See User.