> ## Documentation Index
> Fetch the complete documentation index at: https://www.seam.co/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Reconnecting an Account

> Learn why an account may become disconnected and how to reconnect it.

An account can become disconnected for many reasons, including the following:

* A user resets their password or clicks **Sign Out of All Devices**, invalidating any access tokens Seam may be using to authenticate to the third-party API.
* The third-party service invalidates access tokens due to excessive usage or as part of a system update.
* An access token used internally by Seam expires.

## Detect a Disconnection

To test your application's recovery flow in a sandbox workspace, use the [Simulate Disconnecting a Connected Account](https://www.seam.co/docs/api/connected_accounts/simulate/disconnect.md) endpoint. See the API reference for the request parameters.

When an account becomes disconnected, Seam emits a `connected_account.disconnected` [event](https://www.seam.co/docs/api/events/object.md). Subscribing to this event through a [webhook](https://www.seam.co/docs/developer-tools/webhooks.md) is the recommended way to detect a disconnection, because it tells you the moment the account needs attention instead of on your next poll.

> [!WARNING]
>
> Do not rely on `device.disconnected` for this. That event fires only when a
> device transitions from online to offline, so it does **not** fire when an
> account-level authorization problem is added to a device that was already
> offline. A device can end up in the `account_disconnected` state without any
> further `device.disconnected` event, which means an integration listening only
> for `device.disconnected` will tell the owner "your device is offline" when the
> real problem is "your account needs reconnection." See [Displaying Device
> Health](https://www.seam.co/docs/core-concepts/devices/displaying-device-health.md).

Seam also records the disconnection on the `connected_account` itself, so you can inspect the current state at any time. When an account is disconnected, Seam emits an error like the following example on the `connected_account`:

```python Python theme={"dark"}
seam.connected_accounts.get(email_address="jane@example.com")
# ConnectedAccount(
#   ...
#   errors=[
#     {
#        error_code: "account_disconnected",
#        message: "Account Disconnected, you may need to reconnect the account with a new webview..."
#     }
#  ]
# )
```

Seam recommends adding error handling logic to you application for this error. Your app should also include a fallback case if it encounters an unknown generic error code.

To resolve this error, create a new Connect Webview that the user can use to log in. You may need to instruct them to use the same email address that they used previously. You can use `connected_account.user_identifier` to learn the user's email address. For more information about creating Connect Webviews, see [Connect Webview Process](https://www.seam.co/docs/core-concepts/connect-webviews/connect-webview-process.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.