Okta.Sdk.Api.UserSessionsApi

October 22, 2025 ยท View on GitHub

All URIs are relative to https://subdomain.okta.com

MethodHTTP requestDescription
EndUserSessionsPOST /api/v1/users/me/lifecycle/delete_sessionsEnd a current user session
RevokeUserSessionsDELETE /api/v1/users/{userId}/sessionsRevoke all user sessions

EndUserSessions

void EndUserSessions (KeepCurrent keepCurrent = null)

End a current user session

Ends Okta sessions for the currently signed in user. By default, the current session remains active. Use this method in a browser-based app. > Note: This operation requires a session cookie for the user. The API token isn't allowed for this operation.

Example

using System.Collections.Generic;
using System.Diagnostics;
using Okta.Sdk.Api;
using Okta.Sdk.Client;
using Okta.Sdk.Model;

namespace Example
{
    public class EndUserSessionsExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.OktaDomain = "https://subdomain.okta.com";
            // Configure API key authorization: apiToken
            config.Token ="YOUR_API_KEY";
            // Configure OAuth2 access token for authorization: oauth2
            config.AccessToken = "YOUR_ACCESS_TOKEN";

            var apiInstance = new UserSessionsApi(config);
            var keepCurrent = new KeepCurrent(); // KeepCurrent |  (optional) 

            try
            {
                // End a current user session
                apiInstance.EndUserSessions(keepCurrent);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling UserSessionsApi.EndUserSessions: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Parameters

NameTypeDescriptionNotes
keepCurrentKeepCurrent[optional]

Return type

void (empty response body)

Authorization

apiToken, oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200OK-
403Forbidden-
404Not Found-
429Too Many Requests-

[Back to top] [Back to API list] [Back to Model list] [Back to README]

RevokeUserSessions

void RevokeUserSessions (string userId, bool? oauthTokens = null, bool? forgetDevices = null)

Revoke all user sessions

Revokes all active identity provider sessions of the user. This forces the user to authenticate on the next operation. Optionally revokes OpenID Connect and OAuth refresh and access tokens issued to the user. You can also clear the user's remembered factors for all devices using the forgetDevices parameter. See forgetDevices. > Note: This operation doesn't clear the sessions created for web or native apps.

Example

using System.Collections.Generic;
using System.Diagnostics;
using Okta.Sdk.Api;
using Okta.Sdk.Client;
using Okta.Sdk.Model;

namespace Example
{
    public class RevokeUserSessionsExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.OktaDomain = "https://subdomain.okta.com";
            // Configure API key authorization: apiToken
            config.Token ="YOUR_API_KEY";
            // Configure OAuth2 access token for authorization: oauth2
            config.AccessToken = "YOUR_ACCESS_TOKEN";

            var apiInstance = new UserSessionsApi(config);
            var userId = 00ub0oNGTSWTBKOLGLNR;  // string | ID of an existing Okta user
            var oauthTokens = false;  // bool? | Revokes issued OpenID Connect and OAuth refresh and access tokens (optional)  (default to false)
            var forgetDevices = true;  // bool? | Clears the user's remembered factors for all devices. > **Note:** This parameter defaults to false in Classic Engine. (optional)  (default to true)

            try
            {
                // Revoke all user sessions
                apiInstance.RevokeUserSessions(userId, oauthTokens, forgetDevices);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling UserSessionsApi.RevokeUserSessions: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Parameters

NameTypeDescriptionNotes
userIdstringID of an existing Okta user
oauthTokensbool?Revokes issued OpenID Connect and OAuth refresh and access tokens[optional] [default to false]
forgetDevicesbool?Clears the user's remembered factors for all devices. > Note: This parameter defaults to false in Classic Engine.[optional] [default to true]

Return type

void (empty response body)

Authorization

apiToken, oauth2

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
204No Content-
403Forbidden-
404Not Found-
429Too Many Requests-

[Back to top] [Back to API list] [Back to Model list] [Back to README]