# Delete connection

DELETE https://api.snaptrade.com/api/v1/connection/{connectionId}

Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is asynchronous, a 200 response indicates that a task has been queued to delete the connection. Listen for the [`CONNECTION_DELETED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_deleted) webhook to know when the deletion has been completed and the data has been removed.

Reference: https://docs.snaptrade.com/reference/Connections/Connections_deleteConnection

## Code Examples

### TypeScript

```typescript

import { Snaptrade } from "snaptrade-typescript-sdk";

const snaptrade = new Snaptrade({
  clientId: "PARTNER_CLIENT_ID",
  consumerKey: "CONSUMER_KEY",
});

const response =
  await snaptrade.connections.deleteConnection({
    connectionId:
      "87b24961-b51e-4db8-9226-f198f6518a89",
    userId: "snaptrade-user-123",
    userSecret:
      "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });
console.log(response.data);

```

### Python

```python

from pprint import pprint
from snaptrade_client import SnapTrade

snaptrade = SnapTrade(
    client_id="PARTNER_CLIENT_ID",
    consumer_key="CONSUMER_KEY"
)

response = snaptrade.connections.delete_connection(
    connection_id="87b24961-b51e-4db8-9226-f198f6518a89",
    user_id="snaptrade-user-123",
    user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61"
)
pprint(response.body)

```

## OpenAPI Specification

```yaml

openapi: 3.0.0
info:
  description: Connect brokerage accounts to your app for live positions and trading
  version: 1.0.0
  title: SnapTrade
  termsOfService: N/A
  contact:
    email: api@snaptrade.com
  x-konfig-ignore:
    potential-incorrect-type: true
  x-readme:
    explorer-enabled: false
paths:
  /connection/{connectionId}:
    delete:
      tags:
        - Connections
      summary: Delete connection
      description: >-
        Deletes the SnapTrade connection specified by the ID. This will also
        remove the accounts and holdings data associated with the connection
        from SnapTrade. This action is irreversible. This endpoint is
        asynchronous, a 200 response indicates that a task has been queued to
        delete the connection. Listen for the [`CONNECTION_DELETED`
        webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_deleted)
        webhook to know when the deletion has been completed and the data has
        been removed.
      operationId: Connections_deleteConnection
      parameters:
        - in: path
          name: connectionId
          required: true
          schema:
            description: >-
              Unique identifier for the connection (brokerage_authorization_id).
              This is the UUID used to reference the connection in SnapTrade.
            type: string
            format: uuid
            example: 87b24961-b51e-4db8-9226-f198f6518a89
        - in: query
          required: true
          name: userId
          schema:
            description: >-
              SnapTrade User ID. This is chosen by the API partner and can be
              any string that is a) unique to the user, and b) immutable for the
              user. It is recommended to NOT use email addresses for this
              property because they are usually not immutable.
            type: string
            example: snaptrade-user-123
        - in: query
          required: true
          name: userSecret
          schema:
            description: >-
              SnapTrade User Secret. This is a randomly generated string and
              should be stored securely. If compromised, please rotate it via
              the [rotate user secret
              endpoint](/reference/Authentication/Authentication_resetSnapTradeUserSecret).
            type: string
            example: adf2aa34-8219-40f7-a6b3-60156985cc61
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                description: >-
                  Confirmation that a task has been scheduled to delete the
                  connection.
                type: object
                properties:
                  detail:
                    description: >-
                      Connection queued for deletion; please wait for webhook
                      for confirmation.
                    type: string
                    example: >-
                      Connection queued for deletion; please wait for webhook
                      for confirmation.
                  connection_id:
                    description: >-
                      The ID of the connection (brokerage authorization) that
                      was scheduled for deletion.
                    type: string
                    example: 0b3ebefb-ed47-43df-cd8f-729a4420b5cf
        '400':
          description: Bad Request
        '404':
          description: Not Found
        default:
          description: Unexpected error

```