Skip to main content
POST
/
v1
/
sessions
/
revoke
C#
// POST /v1/sessions/revoke
const stytch = require('stytch');

const client = new stytch.Client({
  project_id: '${projectId}',
  secret: '${secret}',
});

const params = {
  session_token: "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
};

client.Sessions.Revoke(params)
  .then(resp => { console.log(resp) })
  .catch(err => { console.log(err) });
// POST /v1/sessions/revoke
package main

import (
"context"
"log"

"github.com/stytchauth/stytch-go/v18/stytch/consumer/sessions"
"github.com/stytchauth/stytch-go/v18/stytch/consumer/stytchapi"
)

func main() {
client, err := stytchapi.NewClient(
"${projectId}",
"${secret}",
)
if err != nil {
log.Fatalf("error instantiating client: %v", err)
}

params := &sessions.RevokeParams{
SessionToken: "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
}

resp, err := client.Sessions.Revoke(context.Background(), params)
if err != nil {
log.Fatalf("error in method call: %v", err)
}

log.Println(resp)
}
// POST /v1/sessions/revoke
package com.example;

import com.stytch.java.common.StytchResult;
import com.stytch.java.consumer.models.sessions.RevokeRequest;
import com.stytch.java.consumer.StytchClient;

public class Main {
public static void main(String[] args) {
StytchClient.configure("${projectId}", "${secret}");

RevokeRequest params = new RevokeRequest();
params.setSessionToken("mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q");

Object result = StytchClient.getSessions().revoke(params);
if (result instanceof StytchResult.Success) {
System.out.println(((StytchResult.Success) result).getValue());
} else {
System.out.println(((StytchResult.Error) result).getException());
}
}
}
// POST /v1/sessions/revoke
package com.example

import com.stytch.java.consumer.StytchClient
import com.stytch.java.consumer.models.sessions.RevokeRequest

fun main() {
StytchClient.configure(
projectId = "${projectId}",
secret = "${secret}",
)

when (
val result =
StytchClient.sessions.revoke(
RevokeRequest(
sessionToken = "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
),
)
) {
is StytchResult.Success -> println(result.value)
is StytchResult.Error -> println(result.exception)
}
}
// POST /v1/sessions/revoke
const stytch = require('stytch');

const client = new stytch.Client({
project_id: '${projectId}',
secret: '${secret}',
});

const params = {
session_token: "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
};

client.sessions.revoke(params)
.then(resp => { console.log(resp) })
.catch(err => { console.log(err) });
$response = $client->sessions->revoke([
'session_token' => 'mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q',
]);
# POST /v1/sessions/revoke
from stytch import Client

client = Client(
project_id="${projectId}",
secret="${secret}",
)

resp = client.sessions.revoke(
session_token="mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
)

print(resp)
# frozen_string_literal: true

# POST /v1/sessions/revoke
require 'stytch'

client = Stytch::Client.new(
project_id: "${projectId}",
secret: "${secret}"
)

resp = client.sessions.revoke(
session_token: "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q"

)

puts resp
// POST /v1/sessions/revoke
use stytch::consumer::client::Client;
use stytch::consumer::sessions::RevokeRequest;

fn main() {
let client = Client::new("${projectId}", "${secret}").unwrap();
let resp = client.sessions.revoke(
RevokeRequest{
session_token: Some(String::from("mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q")),
..Default::default()
}
).await;
println!("The response is {:?}", resp);
}
# POST /v1/sessions/revoke
curl --request POST \
--url https://test.stytch.com/v1/sessions/revoke \
-u '${projectId}:${secret}' \
-H 'Content-Type: application/json' \
-d '{
"session_token": "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q"
}'
{
  "request_id": "<string>",
  "status_code": 123
}
{
"status_code": 401,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "unauthorized_credentials",
"error_message": "Unauthorized credentials.",
"error_url": "https://stytch.com/docs/api/errors/401"
}
{
"status_code": 429,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "too_many_requests",
"error_message": "Too many requests have been made.",
"error_url": "https://stytch.com/docs/api/errors/429"
}
{
"status_code": 500,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "internal_server_error",
"error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
"error_url": "https://stytch.com/docs/api/errors/500"
}
Revoke a Session, immediately invalidating its session token. You can revoke a session in three ways: using its ID, its session token, or one of its JWTs. This endpoint requires exactly one of those to be included in the request. It will return an error if multiple are present.

Authorizations

Authorization
string
header
required

Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.

Body

application/json

Request type

session_id
string

The session_id to revoke.

session_token
string

The session token to revoke.

session_jwt
string

A JWT for the session to revoke.

Response

Successful response

request_id
string
required

Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.

status_code
integer<int32>
required

The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.