# Is there api for user sign out?

**URL:** <https://devforum.okta.com/t/is-there-api-for-user-sign-out/18352>\
**Category:** OAuth/OIDC\
**Tags:** api\
**Created:** [December 2, 2021, 9:07pm UTC](https://devforum.okta.com/t/is-there-api-for-user-sign-out/18352 "2021-12-02T21:07:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonking](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@leonking](https://devforum.okta.com/u/leonking)\
**Post date:** [December 2, 2021, 9:07pm UTC](https://devforum.okta.com/t/is-there-api-for-user-sign-out/18352/1 "2021-12-02T21:07:38Z")

</div>

I found how to deacivate/delete user with api but I need to sign out the deleted user out after delete. Wonder whether there is also api for this? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![sigama](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/sigama/32/5811_2.png) [@sigama](https://devforum.okta.com/u/sigama)\
**Post date:** [December 2, 2021, 9:16pm UTC](https://devforum.okta.com/t/is-there-api-for-user-sign-out/18352/2 "2021-12-02T21:16:11Z")

</div>

@leonking is this for signing out of Okta or a specific app e.g. OIDC app? Also, you can use the following APIs to close a user’s session i.e. sign them out:

See [Close Session](https://developer.okta.com/docs/reference/api/sessions/#close-session) in the Sessions API reference for more information on removing a specific session.

See [Clear User Sessions](https://developer.okta.com/docs/reference/api/users/#clear-user-sessions) in the Users API reference for more information on removing all of a user’s sessions.

---

<div class="post-metadata">

**Author:** ![leonking](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@leonking](https://devforum.okta.com/u/leonking)\
**Post date:** [December 5, 2021, 4:56am UTC](https://devforum.okta.com/t/is-there-api-for-user-sign-out/18352/3 "2021-12-05T04:56:24Z")

</div>

Thanks @sigama and I will take a look later!  
When I deactivate/delete a user and I got CORS problem and I tried a lot but still could not get it resolved. Can you help please?  
My delete fetch like this:  
fetch(‘[https://xxxx.okta.com/api/v1/users/](https://xxxx.okta.com/api/v1/users/)’ + useID,{  
method: ‘DELETE’,  
headers:{‘Content-type’:‘application/json’,  
‘Accept’: ‘application/json’,  
‘cache-control’:‘no-cache’,  
‘Access-Control-Allow-Origin’:’\*’,  
‘Authorization’:‘SSWS \*\*\*\*\*’  
},  
body: {}  
}).then(res=\>{  
if(res){  
}  
}).catch(error =\> {  
});

The error msg is below:  
Access to fetch at ‘[https://dev-xxxx.okta.com/api/v1/users/00u2xn8gjtbbFZgbO5d9](https://dev-xxxx.okta.com/api/v1/users/00u2xn8gjtbbFZgbO5d9)’ from origin ‘[http://localhost:3000](http://localhost:3000)’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource…  
BTW, I can do deactivate user with postman and do not know why I can’t from UI?

---

<div class="post-metadata">

**Author:** ![warren](https://avatars.discourse-cdn.com/v4/letter/w/97f17d/32.png) [@warren](https://devforum.okta.com/u/warren)\
**Post date:** [December 8, 2021, 4:09am UTC](https://devforum.okta.com/t/is-there-api-for-user-sign-out/18352/4 "2021-12-08T04:09:44Z")

</div>

The `/api/v1/users/${user_id}` endpoint is not CORS enabled.  
[https://developer.okta.com/docs/reference/api/users/#deactivate-user](https://developer.okta.com/docs/reference/api/users/#deactivate-user)

Are you looking for `/api/v1/sessions/me` endpoint instead for logging the user out, which is CORS enabled?  
[https://developer.okta.com/docs/reference/api/sessions/#close-current-session](https://developer.okta.com/docs/reference/api/sessions/#close-current-session)

---

<div class="post-metadata">

**Author:** ![leonking](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@leonking](https://devforum.okta.com/u/leonking)\
**Post date:** [December 9, 2021, 3:12pm UTC](https://devforum.okta.com/t/is-there-api-for-user-sign-out/18352/5 "2021-12-09T15:12:24Z")

</div>

Thanks! @warren  
I have a question even if the 1st one (method: ‘DELETE’) is not CORS enabled but looks like it still do the work by an alternative way like below. Is this the right way to deal with “not CORS enabled” or is there other way to delete user from okta? The 2nd one is just killing the session not delete user, I guess. Thanks!  
…  
}).catch(error =\> {  
if(error == ‘TypeError: Failed to fetch’) {  
console.log(“delete ok”);  
}

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [February 8, 2024, 9:11pm UTC](https://devforum.okta.com/t/is-there-api-for-user-sign-out/18352/8 "2024-02-08T21:11:56Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
