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

# Connections

A connection is an authenticated link to an external app. Before you can interact with an app (read data, create records), a connection must be established that authorizes access. See [Connections API Reference](/reference/workspace-elements/connections) for the full API.

Membrane handles the full authentication lifecycle: OAuth flows, token refresh, API key storage, reconnection on failure, and credential encryption at rest.

## Connecting

Create a connection to an external app. You can connect by intent — just describe what you want to connect to and Membrane finds the right app automatically.

| Way to Use  | How to Connect                             |
| ----------- | ------------------------------------------ |
| CLI         | `membrane connect --intent "CRM"`          |
| MCP         | Use the `create-connection` tool           |
| API         | `POST /connect` with `{ "intent": "CRM" }` |
| SDK         | `membrane.connect({ intent: 'CRM' })`      |
| Embedded UI | `membrane.ui.connect({ intent: 'CRM' })`   |
| Console     | Connections → Create Connection            |

## Managing Connections

### Listing

List all connections for the current tenant.

| Way to Use | How to List                     |
| ---------- | ------------------------------- |
| CLI        | `membrane connection list`      |
| MCP        | Use the `list-connections` tool |
| API        | `GET /connections`              |
| SDK        | `membrane.connections.find()`   |
| Console    | Connections page                |

Each connection includes a `disconnected` flag. If `true`, the connection needs re-authentication.

### Reconnecting

When a connection is disconnected (expired token, revoked access), Membrane attempts to fix it automatically with token refresh and exponential backoff. To reconnect manually:

| Way to Use  | How to Reconnect                                  |
| ----------- | ------------------------------------------------- |
| CLI         | `membrane connect --connectionId <id>`            |
| API         | `POST /connect` with `{ "connectionId": "<id>" }` |
| SDK         | `membrane.connect({ connectionId: '<id>' })`      |
| Embedded UI | `membrane.ui.connect({ connectionId: '<id>' })`   |
| Console     | Connection → Reconnect                            |

### Deleting

Archive a connection to disconnect and remove it.

| Way to Use | How to Delete                                     |
| ---------- | ------------------------------------------------- |
| CLI        | `membrane connection archive <connectionId>`      |
| API        | `DELETE /connections/<connectionId>`              |
| SDK        | `membrane.connection('<connectionId>').archive()` |
| Console    | Connection → Archive                              |

## Lifecycle Events

Subscribe to [webhook notifications](/docs/managing-membrane/monitoring-troubleshooting/webhook-notifications) for connection lifecycle events:

* `connection.created` — connection established with credentials
* `connection.deleted` — connection archived
* `connection.disconnected` — connection lost access
* `connection.reconnected` — connection restored
