# Delete connection

Source: https://docs.tradeit.app/api/delete-connection

`DELETE /api/brokerageConnection/{id}`

Deletes the authenticated user's brokerage connection and its associated records in Trade It.

**OAuth scope:** `brokerage:write`

> **Destructive Action**
>
> This endpoint currently deletes the entire connection across Trade It. It also deletes all accounts on that connection and their stored trades in Trade It.

## Authentication [#authentication]

Use the user's OAuth access token or a user-created API key as a bearer token.

## Connection ID [#connection-id]

Use `account.connection_id` from [Get accounts](/api/get-accounts). Multiple accounts can share one connection; deleting it removes all of them.

| Parameter | Location | Required | Description |
| --- | --- | --- | --- |
| `id` | Path | Yes | The Trade It brokerage connection ID. |

No request body is required.

## Example [#example]

```js
const response = await fetch(
  `https://api.tradeit.app/api/brokerageConnection/:Id}`,
  {
    method: 'DELETE',
    headers: { Authorization: `Bearer ${accessToken}` },
  },
);
if (!response.ok) throw new Error(`Connection deletion failed: ${response.status}`);
```

On success, Trade It returns `200`:

```json
{ "success": true }
```

## Effects [#effects]

- Deletes the connection, its accounts, and their stored trades from Trade It. The underlying brokerage accounts remain open.
- Sends an [ACCOUNT_DELETED webhook](/sdk/webhooks#account-deleted) for each deleted account to subscribed partners.
- Preserves the user's Trade It account, organization memberships, and OAuth authorization.

To end a user's organization membership and sponsorship instead, use [Remove membership](/api/remove-membership).

## Errors [#errors]

| Status | Meaning |
| --- | --- |
| `401` | The bearer token is invalid or expired. |
| `403` | The caller cannot access the connection or lacks `brokerage:write` permission. |
| `404` | The connection was not found. |
