# Unable to delete user session via the management API

**URL:** <https://community.auth0.com/t/unable-to-delete-user-session-via-the-management-api/150873>\
**Category:** Get Help\
**Tags:** sessions, logout\
**Created:** [November 2, 2024, 2:18am UTC](https://community.auth0.com/t/unable-to-delete-user-session-via-the-management-api/150873 "2024-11-02T02:18:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prudy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prudy/32/60023_2.png) [@prudy](https://community.auth0.com/u/prudy)\
**Post date:** [November 2, 2024, 2:18am UTC](https://community.auth0.com/t/unable-to-delete-user-session-via-the-management-api/150873/1 "2024-11-02T02:18:47Z")

</div>

Hello,

I am attempting to logout a user by deleting the auth0 session via the API. I’ve been able to successfully obtain a token with the client credentials grant on a machine-to-machine request at `https://MY_CUSTOM_DOMAIN.com/oauth/token`.

My first question is: Why can’t I used my custom domain for the audience, and must use the application domain?

Secondly…

After grabbing the Bearer token I am able to successfully list a users sessions at:  
`GET /api/v2/users/{user-id}/sessions`

However, I am unable to then DELETE a users sessions at  
`DELETE /api/v2/users/{user-id}/sessions`

I get:

```auto
{
    "statusCode": 404,
    "error": "Not Found",
    "message": "Not Found"
}

```

I know my endpoints and user ids are correct.

What could I be doing wrong?

---

<div class="post-metadata">

**Author:** ![marybeth.hunter](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marybeth.hunter/32/61955_2.png) [@marybeth.hunter](https://community.auth0.com/u/marybeth.hunter)\
**Post date:** [November 6, 2024, 5:03pm UTC](https://community.auth0.com/t/unable-to-delete-user-session-via-the-management-api/150873/3 "2024-11-06T17:03:32Z")

</div>

Hi @prudy!

To obtain a Management API access token, you must use the `identifier` value of the Management API in your tenant (`https:/TENANT_NAME.us.auth0.com/api/v2/`) as the `audience` parameter.

Your custom domain is primarily intended for use on authentication pages. Custom domains let you unify the login experience with your own brand, as your users will see a URL that displays your brand as `login.YOUR_CUSTOM_DOMAIN.com` instead of `YOUR_DOMAIN.auth0.com`.

Relevant documentation that may prove helpful:

- [Custom Domains](https://auth0.com/docs/customize/custom-domains)
- [Get Management API Access Tokens for Production](https://auth0.com/docs/secure/tokens/access-tokens/management-api-access-tokens/get-management-api-access-tokens-for-production)

Regarding the 404 error on the `DELETE /api/v2/users/{user_id}/sessions` [endpoint](https://auth0.com/docs/api/management/v2/users/delete-sessions-for-user), please see the below:

A 404 error on that endpoint indicates that the user was not found.

Could you kindly do one or both of the following things:

- Private message me your tenant name and the `user_id` you’re trying to delete the sessions of so I can take a closer look internally
- Use either the `DELETE /api/v2/sessions/{id}` [endpoint](https://auth0.com/docs/api/management/v2/sessions/delete-session) or the `POST /api/v2/sessions/{id}/revoke` [endpoint](https://auth0.com/docs/api/management/v2/sessions/revoke-session) to delete/revoke the desired session by the `session_id`

I look forward to your reply!

Best,

Mary Beth

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 20, 2024, 5:04pm UTC](https://community.auth0.com/t/unable-to-delete-user-session-via-the-management-api/150873/4 "2024-11-20T17:04:29Z")

</div>

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