# Delete a Connection

Deletes a connection you previously created. The connection moves to `DELETED` status and stops being available to routing. Returns `204 No Content` on success.

<Warning>
A connection that is still referenced by an active routing rule cannot be deleted — the request fails with `409 CONNECTION_IN_USE`. Detach it from your routes first, then retry.
</Warning>

### Path Parameters

<ParamField path="connection_id" type="string" required>
  The id returned by [Create a Connection](/reference/organizations/connections/create-connection). Must belong to the account your API key is scoped to.
</ParamField>

### Headers

<ParamField header="X-Account-Code" type="string" required>
  UUID of the account the connection belongs to.
</ParamField>

### Response

Returns `204 No Content` with an empty body.

<CodeGroup>
```bash cURL
curl -X DELETE 'https://api.whitelabel.com/v1/connections/f1a3c4d5-7b8e-4a2c-9d1e-3f4a5b6c7d8e' \
  -H 'public-api-key: <YOUR_PUBLIC_KEY>' \
  -H 'private-secret-key: <YOUR_SECRET_KEY>' \
  -H 'X-Account-Code: a1b2c3d4-e5f6-7890-abcd-ef1234567890'
```

```json 409 — In Use
{
  "type": "conflict",
  "code": "CONNECTION_IN_USE",
  "message": "Connection 'f1a3c4d5-7b8e-4a2c-9d1e-3f4a5b6c7d8e' is still referenced by an active routing rule",
  "details": { "connection_id": "f1a3c4d5-7b8e-4a2c-9d1e-3f4a5b6c7d8e" }
}
```

```json 404 Not Found
{
  "type": "not_found",
  "code": "CONNECTION_NOT_FOUND",
  "message": "Connection '...' was not found",
  "details": { "connection_id": "..." }
}
```
</CodeGroup>

### Errors

<div className="code-nowrap-table dense-table">

| HTTP | `code` |
| --- | --- |
| `401` | `NOT_AUTHENTICATED`<br />Missing or invalid API key. |
| `404` | `CONNECTION_NOT_FOUND`<br />Unknown `connection_id`, or the id belongs to a different account. |
| `409` | `CONNECTION_IN_USE`<br />The connection is still referenced by an active routing rule. |

</div>

**DELETE** `/connections/{connection_id}`

Base URL: `https://api-sandbox.whitelabel.com/v1`

Deletes a connection. The connection moves to DELETED status and stops being available to routing.

## Authorization

- PUBLIC-API-KEY (apiKey in header)
- PRIVATE-SECRET-KEY (apiKey in header)

## Header parameters

- `X-Account-Code` (string, required)

## Path parameters

- `connection_id` (string, required)

## Responses

### 204

No Content

### 401

Unauthorized

- `type` (string)
- `code` (string)
- `message` (string)

Example:

```json
{
  "type": "auth_error",
  "code": "NOT_AUTHENTICATED",
  "message": "Not authenticated"
}
```

### 404

Not Found

- `type` (string)
- `code` (string)
- `message` (string)

Example:

```json
{
  "type": "not_found",
  "code": "CONNECTION_NOT_FOUND",
  "message": "Connection '...' was not found"
}
```

### 409

Conflict

- `type` (string)
- `code` (string)
- `message` (string)

Example:

```json
{
  "type": "conflict",
  "code": "CONNECTION_IN_USE",
  "message": "Connection '...' is still referenced by an active routing rule"
}
```