Is there a way to deactivate "Session-Based Permission Sets" through Apex?

We can activate it by creating a new instance of "SessionPermSetActivation" record in Apex, but I am unable to find a similar API to deactivate. "SessionPermSetActivation" doesn't support DELETE call.


1 Answer 1


Given that Process Builder actions can deactivate “ Session-Based Permission Sets”...

An apex-approach could callout to Actions REST api to asyncronously run an InvocableProcess, and that InvocableProcess can be configured to run the process builder action as shown in these articles:

https://github.com/DouglasCAyers/sfdc-process-invocable https://douglascayers.com/2016/10/31/how-to-invoke-process-builder-from-flow/


Edit: 2020-December-30, i see that

This article:

"Create a Flow That Can Activate or Deactivate a Session-Based Permission Set" https://help.salesforce.com/articleView?id=perm_sets_session_activate_flow.htm&type=5

Claims that:

You can create a session-based permission set and then create a flow that users can run to activate or deactivate the permission set themselves.

  • Thanks, Peter. Wondering if there is an easier way to do the same. Dec 28, 2020 at 19:59
  • I read that those session based perm sets expire after logout. As such, an alternate apex approach may be to delete the appropriate “AuthSession” objects from apex to effectively log the user out which would deactivate the session based perm. I dont advise it because it would be bad ux to log someone out. Alternatively maybe ask support if they can grant you delete perm on the obj you cited? And of course If you decide you dont need apex then simply use Process Builder Dec 28, 2020 at 21:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .