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

# Reauthorizing Connections

> Refresh credentials when they expire or become invalid

## When Reauthorization is Needed

* OAuth tokens expire
* User revokes access
* API keys are rotated
* Permissions change

## Detecting Auth Issues

**Webhook event:** `integrated_account:authentication_error`

This event is sent when:

* OAuth token refresh fails
* API call returns 401 Unauthorized

## Reauthorize via Dashboard

<Steps>
  <Step title="Open Account">
    Go to **Integrated Accounts** and select the account
  </Step>

  <Step title="Start Reauthorization">
    Click **Reauthorize connection**
  </Step>

  <Step title="Get Link">
    Click **Get connection link**
  </Step>

  <Step title="Complete">
    Complete the authorization flow
  </Step>
</Steps>

## Reauthorize via API

Generate a link token for the existing account:

```bash theme={null}
curl -X POST 'https://api.usehandled.io/api/v1/ipaas/link-token' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "integrated_account_id": "ACCOUNT_ID"
  }'
```

Use the token to open the reauthorization UI:

```
https://ipaas.usehandled.io/connect-account?link_token={link_token}
```

## Embed in Your App

Use the Link SDK with the existing account ID to prompt users to reauthorize.

```javascript theme={null}
import authenticate from '@handled/link-sdk';

authenticate(linkToken)
  .then(response => console.log('Reauthorized:', response))
  .catch(error => console.error('Error:', error));
```

## After Reauthorization

**Webhook event:** `integrated_account:reactivated`

The account status returns to active and API calls work again.
