Summary

The revokeSession() mutation revokes an active session in LogScale. You can revoke a single session, all sessions for a specific user, or all sessions across an organization. Use this mutation to terminate access immediately, for example, after a suspected compromise or when deprovisioning a user.

Syntax

graphql
revokeSession(
      input: RevokeSessionInput!
   ): Boolean!

The mutation takes a required input argument of type RevokeSessionInput. The revocationType field controls the scope: Session revokes a single session by its identifier, User revokes all active sessions for a specific user, and Organization revokes all sessions across an organization. The id field identifies the target โ€” a session ID, user ID, or organization ID, depending on the revocation type. The mutation returns a non-null Boolean! โ€” true confirms the revocation succeeded. The mutation returns an error rather than false if it cannot complete the operation.

Example

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

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 {
  revokeSession( input: {
     id: \"abc123\",
     revocationType: Session
  } )
}"
}
);


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": {
    "revokeSession": true
  }
}

Input Parameters

The RevokeSessionInput type requires two fields. The id field identifies the revocation target. Its value depends on the revocationType: provide a session ID when revoking a single session, a user ID when revoking all sessions for a specific user, or an organization ID when revoking all sessions across an organization. Use the sessions() query to retrieve session identifiers. The revocationType field sets the revocation scope using the SessionRevocation__Type enum.

Table: RevokeSessionInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
idStringyesย Long-Termย The unique identifier of the session.
revocationTypeSessionRevocation__Typeyesย Long-Termย The type of revocation. See SessionRevocation__Type.

Returned Values

The mutation returns a non-null Boolean!. A value of true confirms the revocation succeeded. The mutation returns an error rather than false if it cannot complete the operation.