# Delete sso with api

**URL:** https://meta.discourse.org/t/delete-sso-with-api/170768
**Category:** SSO
**Created:** [November 20, 2020, 4:31pm UTC](https://meta.discourse.org/t/delete-sso-with-api/170768 "2020-11-20T16:31:07Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [November 20, 2020, 5:37pm UTC](https://meta.discourse.org/t/delete-sso-with-api/170768/3 "2020-11-20T17:37:10Z")

</div>

> [@Marcos\_Alexandre](#):
>
> I am using the discourse and I am changing the external\_id, how can I clear the old records of this without losing my user and posts.

The `external_id` that is passed from the SSO provider is expected to never change. If it’s possible, you should avoid changing your user’s `external_id` values.

> [@pfaffman](#):
>
> Maybe just delete all of the SSO records once from the rails console and let them reconnect by the email address?

As long as you are not setting the SSO parameter `require_activation` to `true`, you can delete all SSO records as Jay mentioned. To do this, enter your site’s console and run:

```plaintext
SingleSignOnRecord.destroy_all

```

Before doing this, you need to be sure that you are not setting `require_activation` to `true` in the SSO payload. If this parameter is being set, _users will not be found based on their email address the next time they login to the site._ Instead of that happening, they will get an error when they try to login.

If the `require_activation` parameter is not being set to `true`, users will be found based on their email address the next time they login to Discourse. A new SSO record will be created for them at this time. If any user’s email addresses are out of sync between your SSO provider site and Discourse, they will run into issues the next time they login to Discourse. You can find some details about fixing those issues here: [Debug and fixing common DiscourseConnect issues](https://meta.discourse.org/t/debugging-and-fixing-common-sso-issues/103496/1).

If you are going to run the command I posted above, be sure to create a backup of your site’s database before running the command. If anything goes wrong, you can restore the backup file.

---

_[View the full topic](https://meta.discourse.org/t/delete-sso-with-api/170768)._
