# Can you revoke an Okta Session from a backend API?

**URL:** <https://devforum.okta.com/t/can-you-revoke-an-okta-session-from-a-backend-api/24546>\
**Category:** API\
**Tags:** java\
**Created:** [June 12, 2023, 2:12pm UTC](https://devforum.okta.com/t/can-you-revoke-an-okta-session-from-a-backend-api/24546 "2023-06-12T14:12:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmd](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@mmd](https://devforum.okta.com/u/mmd)\
**Post date:** [June 12, 2023, 2:12pm UTC](https://devforum.okta.com/t/can-you-revoke-an-okta-session-from-a-backend-api/24546/1 "2023-06-12T14:12:38Z")

</div>

Naive question:

I have a front-end UI that uses the [okta-auth-js](https://github.com/okta/okta-auth-js) SDK. Is there any way I can make an API request to my backend server, which uses the [okta-java-sdk](https://developer.okta.com/okta-sdk-java/) to close the session via SessionApi.revokeSession(sessionId)? I’m not sure how to get the sessionId in my backend server since it’s an HTTP only cookie and I created the session from my front-end using the auth-js sdk.

Interestingly, I manually copied to HTTP session cookie from my browser into Postman and called DELETE sessions/${sessionId} and it gave a 204, but my user was still logged in. Why would that be the case?

In general, how could I close the Okta session from the backend and have it log my user out in the front end?

---

<div class="post-metadata">

**Author:** ![phi1ipp](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@phi1ipp](https://devforum.okta.com/u/phi1ipp)\
**Post date:** [June 13, 2023, 10:32am UTC](https://devforum.okta.com/t/can-you-revoke-an-okta-session-from-a-backend-api/24546/2 "2023-06-13T10:32:21Z")

</div>

if you run in your browser `GET /api/v1/sessions/me` documented [here](https://developer.okta.com/docs/reference/api/sessions/#get-current-session) and then pass your session id to your backend, then your backend can terminate it

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [June 13, 2023, 3:50pm UTC](https://devforum.okta.com/t/can-you-revoke-an-okta-session-from-a-backend-api/24546/3 "2023-06-13T15:50:16Z")

</div>

Use of the Sessions API has a caveat in that it is more limited in Okta Identity Engine, more information here: [Understand how sessions work after the upgrade | Okta Developer](https://developer.okta.com/docs/guides/oie-upgrade-sessions-api/main/)

---

<div class="post-metadata">

**Author:** ![phi1ipp](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@phi1ipp](https://devforum.okta.com/u/phi1ipp)\
**Post date:** [June 13, 2023, 4:07pm UTC](https://devforum.okta.com/t/can-you-revoke-an-okta-session-from-a-backend-api/24546/4 "2023-06-13T16:07:23Z")

</div>

Yup, thx for the heads up @andrea , totally forgot about this thing!

---

<div class="post-metadata">

**Author:** ![mmd](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@mmd](https://devforum.okta.com/u/mmd)\
**Post date:** [August 2, 2023, 12:21pm UTC](https://devforum.okta.com/t/can-you-revoke-an-okta-session-from-a-backend-api/24546/5 "2023-08-02T12:21:42Z")

</div>

Just checked back in on this and noticed that the **[My Session Management endpoints](https://developer.okta.com/docs/api/openapi/okta-management/management/tag/Session/)** link that appears on the docs page you sent ([Understand how sessions work after the upgrade | Okta Developer](https://developer.okta.com/docs/guides/oie-upgrade-sessions-api/main/)) opens to the old api//v1/sessions/{sessionId} endpoints, not the latest api/v1/sessions/me endpoint(s) as it is implying it should. I can’t find mention of the sessions/me endpoint in that API doc page.

---

<div class="post-metadata">

**Author:** ![mrjohnsmith](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@mrjohnsmith](https://devforum.okta.com/u/mrjohnsmith)\
**Post date:** [September 20, 2023, 12:51pm UTC](https://devforum.okta.com/t/can-you-revoke-an-okta-session-from-a-backend-api/24546/6 "2023-09-20T12:51:07Z")

</div>

Here is answer of your question what I know, lee me know if this will help you or not.

To close an Okta session from the backend and log the user out in the frontend, initiate communication between them. Frontend sends a request to the backend with session identifier. Backend then uses Okta’s SessionApi.revokeSession(sessionId) to revoke the session, and your frontend should clear its own session and update the UI accordingly.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [September 20, 2023, 3:33pm UTC](https://devforum.okta.com/t/can-you-revoke-an-okta-session-from-a-backend-api/24546/7 "2023-09-20T15:33:19Z")

</div>

For anyone who stumbles upon this later, our docs have been corrected and the /sessions/me endpoint is listed in our Sessions API docs, e.g. [Close Current Session | Okta Developer](https://developer.okta.com/docs/api/openapi/okta-management/management/tag/Session/#tag/Session/operation/closeCurrentSession)

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 15, 2024, 5:30pm UTC](https://devforum.okta.com/t/can-you-revoke-an-okta-session-from-a-backend-api/24546/8 "2024-02-15T17:30:51Z")

</div>


