---
canonical_url: "https://docs.composio.dev/docs/auth-configuration/connected-accounts"
markdown_url: "https://docs.composio.dev/docs/auth-configuration/connected-accounts.md"
product: "platform"
version: null
last_updated: null
---

# Connected Accounts (/docs/auth-configuration/connected-accounts)

> **Legacy.** This is a point-in-time migration/legacy guide and may describe outdated APIs. For current guidance, see https://docs.composio.dev.

> If you're building an agent, we recommend using [sessions](/docs/configuring-sessions) instead. See [Managing multiple connected accounts](/docs/authentication/managing-multiple-connected-accounts) for how sessions handle account selection automatically.

Connected accounts are authenticated connections between your users and toolkits. After users authenticate (see [Authenticating tools](/docs/tools-direct/authenticating-tools)), you can manage these accounts throughout their lifecycle.

If an account is active but a session can't use it, see [When a session can't find a connected account](/docs/authentication/session-cant-find-account).

Composio automatically handles token refresh and credential management. This guide covers manual operations: listing, retrieving, refreshing, enabling, disabling, and deleting accounts.

## List accounts [#list-accounts]

Retrieve all connected accounts with optional filters:

**Python:**
```python
# List all accounts for a user
accounts = composio.connected_accounts.list(
    user_ids=[user_id]
)

# Filter by status
active_accounts = composio.connected_accounts.list(
    user_ids=[user_id],
    statuses=["ACTIVE"]
)
```

**TypeScript:**
```typescript
import { Composio } from '@composio/core';
const composio = new Composio({ apiKey: 'your_api_key' });
const userId = 'user_123';
// List all accounts for a user
const accounts = await composio.connectedAccounts.list({
  userIds: [userId]
});

// Filter by status
const activeAccounts = await composio.connectedAccounts.list({
  userIds: [userId],
  statuses: ['ACTIVE']
});
```

**API:**
```bash
# List all accounts for a user
curl -X GET "https://backend.composio.dev/api/v3.1/connected_accounts?user_ids=user_123" \
  -H "x-api-key: $COMPOSIO_API_KEY"

# Filter by status
curl -X GET "https://backend.composio.dev/api/v3.1/connected_accounts?user_ids=user_123&statuses=ACTIVE" \
  -H "x-api-key: $COMPOSIO_API_KEY"
```

## Get account details [#get-account-details]

Retrieve a connected account by ID:

**Python:**
```python
account = composio.connected_accounts.get(connected_account_id)

print(f"Status: {account.status}")
print(f"Toolkit: {account.toolkit.slug}")
```

**TypeScript:**
```typescript
import { Composio } from '@composio/core';
const composio = new Composio({ apiKey: 'your_api_key' });
const connectedAccountId = 'ca_123';
const account = await composio.connectedAccounts.get(connectedAccountId);

console.log('Status:', account.status);
console.log('Toolkit:', account.toolkit.slug);
```

**API:**
```bash
curl -X GET https://backend.composio.dev/api/v3.1/connected_accounts/ca_123 \
  -H "x-api-key: $COMPOSIO_API_KEY" | jq '{status, toolkit: .toolkit.slug}'
```

### Get account credentials [#get-account-credentials]

Connected-account responses describe the authentication state. Sensitive credential fields in `account.state.val` are [redacted by default](#credential-masking), for both Composio-managed and custom auth configs. This object is not a source of usable provider tokens for your own tools.

To call a provider API, use [Proxy Execute](/docs/extending-sessions/proxy-execute), which injects credentials server-side. For custom business logic, use [session extension tools](/docs/extending-sessions/local-tools-and-toolkits). See [Token custody architecture](/docs/security/token-custody) for the boundaries between your application, Composio, and the provider.

## Refresh credentials [#refresh-credentials]

> `composio.connected_accounts.refresh()` in Python and `composio.connectedAccounts.refresh()` in TypeScript are deprecated. Re-initiate authentication with `link()` or `composio.toolkits.authorize()` instead. The refresh endpoint no longer validates credentials. TypeScript ignores `validateCredentials` and logs a warning when you set it.

Manually refresh credentials for a connected account:

**Python:**
```python
try:
    refreshed = composio.connected_accounts.refresh(connected_account_id)
    print(f"Redirect URL: {refreshed.redirect_url}")

    # Wait for the connection to be established
    composio.connected_accounts.wait_for_connection(refreshed.id)
except Exception as e:
    print(f"Failed to refresh tokens: {e}")
```

**TypeScript:**
```typescript
import { Composio } from '@composio/core';
const composio = new Composio({ apiKey: 'your_api_key' });
const connectedAccountId = 'ca_123';
try {
  const refreshed = await composio.connectedAccounts.refresh(connectedAccountId);
  console.log('Redirect URL:', refreshed.redirect_url);

  // Wait for the connection to be established
  await composio.connectedAccounts.waitForConnection(refreshed.id);
} catch (error) {
  console.error('Failed to refresh tokens:', error);
}
```

**API:**
```bash
# Deprecated endpoint: returns a redirect URL for re-authentication
curl -X POST https://backend.composio.dev/api/v3.1/connected_accounts/ca_123/refresh \
  -H "x-api-key: $COMPOSIO_API_KEY" | jq -r '.redirect_url'

# Check whether the connection is ACTIVE again
curl -X GET https://backend.composio.dev/api/v3.1/connected_accounts/ca_123 \
  -H "x-api-key: $COMPOSIO_API_KEY" | jq -r '.status'
```

## Enable and disable accounts [#enable-and-disable-accounts]

Change account status without deleting. Set to INACTIVE to pause access, or ACTIVE to restore. Useful for:

* Pausing access during subscription lapses
* Temporary disconnection

**Python:**
```python
# Disable an account
disabled = composio.connected_accounts.disable(connected_account_id)
print(f"Account disabled status: {disabled.success}")

# Re-enable when needed
enabled = composio.connected_accounts.enable(connected_account_id)
print(f"Account enabled status: {enabled.success}")
```

**TypeScript:**
```typescript
import { Composio } from '@composio/core';
const composio = new Composio({ apiKey: 'your_api_key' });
const connectedAccountId = 'ca_123';
// Disable an account
const disabled = await composio.connectedAccounts.disable(connectedAccountId);
console.log('Account disabled status:', disabled.success);

// Re-enable when needed
const enabled = await composio.connectedAccounts.enable(connectedAccountId);
console.log('Account enabled status:', enabled.success);
```

**API:**
```bash
# Disable an account
curl -X PATCH https://backend.composio.dev/api/v3.1/connected_accounts/ca_123/status \
  -H "x-api-key: $COMPOSIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"enabled": false}'

# Re-enable when needed
curl -X PATCH https://backend.composio.dev/api/v3.1/connected_accounts/ca_123/status \
  -H "x-api-key: $COMPOSIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"enabled": true}'
```

> INACTIVE accounts cannot execute tools. Tool execution will fail until the status is changed.

## Revoke accounts [#revoke-accounts]

To revoke upstream tokens and mark a connection `REVOKED`, call `composio.connected_accounts.revoke(connected_account_id)` in Python or `await composio.connectedAccounts.revoke(connectedAccountId)` in TypeScript. Upstream token revocation is best effort. The call fails if the toolkit does not support programmatic revocation or the account is not in a revokable state.

## Complete deferred OAuth [#complete-deferred-oauth]

If your project has an OAuth callback verifier configured, Composio redirects to your verifier with a single-use session URI before activating the connection. Verify the person's identity in your application, then redeem the URI with `composio.connected_accounts.complete_auth(user_id=user_id, session_uri=session_uri)` in Python or `await composio.connectedAccounts.completeAuth({ userId, sessionUri })` in TypeScript.

Composio checks project ownership and the connection's user ID before completing the token exchange. An expired or already redeemed URI returns a `404`.

## Delete accounts [#delete-accounts]

Permanently remove a connected account:

**Python:**
```python
# Delete a connected account
composio.connected_accounts.delete(connected_account_id)
print("Account deleted successfully")
```

**TypeScript:**
```typescript
import { Composio } from '@composio/core';
const composio = new Composio({ apiKey: 'your_api_key' });
const connectedAccountId = 'ca_123';
// Delete a connected account
await composio.connectedAccounts.delete(connectedAccountId);
console.log('Account deleted successfully');
```

**API:**
```bash
curl -X DELETE https://backend.composio.dev/api/v3.1/connected_accounts/ca_123 \
  -H "x-api-key: $COMPOSIO_API_KEY"
```

> Deletion is permanent and cannot be undone.

## Credential masking [#credential-masking]

By default, sensitive fields in connected account responses are partially masked for security. This affects fields like `access_token`, `refresh_token`, `api_key`, `bearer_token`, `password`, and other secrets.

Instead of returning full values, the API returns the first 4 characters followed by `...`:

```json
{
  "access_token": "gho_...",
  "refresh_token": "ghr_...",
  "api_key": "sk-l..."
}
```

Values shorter than 4 characters are replaced with `REDACTED`.

This applies to the Get Connected Account and List Connected Accounts endpoints for both Composio-managed and custom auth configs. The API redacts these fields before returning the response to your application.

If your use case requires calling a provider API directly, use [Proxy execute](/docs/extending-sessions/proxy-execute). Composio injects the connected account's credentials server-side.

## Multiple accounts [#multiple-accounts]

Users can connect multiple accounts for the same toolkit (e.g., personal and work Gmail).

> **For Composio-managed OAuth, prefer `link()`.** The `initiate()` examples below will stop working for Composio-managed OAuth auth configs starting **2026-05-08** (new orgs) / **2026-07-03** (all orgs). `link()` provides hosted authentication and is unaffected by the rollout. Like `initiate()`, it refuses to create a second active connection for the same user and auth config unless you pass `allow_multiple=True` (Python) or `allowMultiple: true` (TypeScript). See [Connect Link authentication](/docs/tools-direct/authenticating-tools#hosted-authentication-connect-link), the [migration guide](/docs/auth-configuration/migrating-initiate-to-link), or the [changelog entry](/docs/changelog/2026/04/24).

The `initiate()` examples remain accurate for **custom auth configs** (your own OAuth app) and **non-OAuth schemes** (API key, bearer, basic) — those are unaffected.

**Python:**
```python
# First account
try:
    first_account = composio.connected_accounts.initiate(
        user_id=user_id,
        auth_config_id=auth_config_id
    )
    print(f"First account redirect URL: {first_account.redirect_url}")
    connected_first_account = first_account.wait_for_connection()
    print(f"First account status: {connected_first_account.status}")
except Exception as e:
    print(f"Error initiating first account: {e}")

# Second account - must explicitly allow multiple
try:
    second_account = composio.connected_accounts.initiate(
        user_id=user_id,
        auth_config_id=auth_config_id,
        allow_multiple=True  # Required for additional accounts
    )
    print(f"Second account redirect URL: {second_account.redirect_url}")
    connected_second_account = second_account.wait_for_connection()
    print(f"Second account status: {connected_second_account.status}")
except Exception as e:
    print(f"Error initiating second account: {e}")
```

**TypeScript:**
```typescript
import { Composio } from '@composio/core';
const composio = new Composio({ apiKey: 'your_api_key' });
const userId = 'user_123';
const authConfigId = 'ac_123';
// First account
try {
  const firstAccount = await composio.connectedAccounts.initiate(
    userId,
    authConfigId
  );
  console.log('First account redirect URL:', firstAccount.redirectUrl);
  const connectedFirstAccount = await firstAccount.waitForConnection();
  console.log('First account status:', connectedFirstAccount.status);
} catch (error) {
  console.error('Error initiating first account:', error);
}

// Second account - must explicitly allow multiple
try {
  const secondAccount = await composio.connectedAccounts.initiate(
    userId,
    authConfigId,
    {
      allowMultiple: true  // Required for additional accounts
    }
  );
  console.log('Second account redirect URL:', secondAccount.redirectUrl);
  const connectedSecondAccount = await secondAccount.waitForConnection();
  console.log('Second account status:', connectedSecondAccount.status);
} catch (error) {
  console.error('Error initiating second account:', error);
}
```

**API:**
```bash
# Each call creates a new connection for the same user and auth config.
# The API does not block duplicates; allow_multiple is an SDK-side check.
curl -X POST https://backend.composio.dev/api/v3.1/connected_accounts \
  -H "x-api-key: $COMPOSIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"auth_config": {"id": "ac_123"}, "connection": {"user_id": "user_123"}}' | jq -r '.redirect_url'
```

> For session-based apps, see [Managing multiple connected accounts](/docs/authentication/managing-multiple-connected-accounts) for how to pass a specific account to a session.

### Execute with a specific account [#execute-with-a-specific-account]

When you have multiple accounts, specify which one to use with `connected_account_id`:

**Python:**
```python
# Execute tool with a specific connected account
result = composio.tools.execute(
    "GMAIL_GET_PROFILE",
    user_id=user_id,
    connected_account_id=connected_account_id,  # Specify which account to use
    version="20251111_00",
    arguments={}
)
print(f"Tool executed: {result}")
```

**TypeScript:**
```typescript
import { Composio } from '@composio/core';
const composio = new Composio({ apiKey: 'your_api_key' });
const userId = 'user_123';
const connectedAccountId = 'ca_123';
// Execute tool with a specific connected account
const result = await composio.tools.execute('GMAIL_GET_PROFILE', {
  userId: userId,
  connectedAccountId: connectedAccountId,  // Specify which account to use
  version: '20251111_00',
  arguments: {}
});
console.log('Tool executed:', result);
```

**API:**
```bash
curl -X POST https://backend.composio.dev/api/v3.1/tools/execute/GMAIL_GET_PROFILE \
  -H "x-api-key: $COMPOSIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id": "user_123", "connected_account_id": "ca_123", "version": "20251111_00", "arguments": {}}'
```

## Next [#next]

- [Authenticating tools](/docs/tools-direct/authenticating-tools): Create auth configs and connect user accounts

---

📚 **More documentation:** [View all docs](https://docs.composio.dev/llms.txt) | [Changelog](https://docs.composio.dev/docs/changelog.md) | [Glossary](https://docs.composio.dev/llms.mdx/reference/glossary) | [Examples](https://docs.composio.dev/llms.mdx/examples) | [API Reference](https://docs.composio.dev/llms.mdx/reference)