# Delete a connection

> Refused while a sync, workflow, API proxy or scheduled task uses the connection.

Source: https://docs.stacksync.com/api-reference/connections/delete_connection

`DELETE https://api.stacksync.com/v1/workspaces/{workspace_id}/connections/{connection_id}`

- Operation: `delete_connection`
- Resource: Connections
- Access: writes data

## Authentication

- `Authorization: Bearer <key>`: A workspace API key (workspace_…, created by a workspace owner under Workspace settings > Stacksync API) acts with editor rights on that workspace only; a user API key (user_…, created under Profile > Stacksync API) acts as that user in every workspace they belong to. POST, PUT and PATCH requests must send Content-Type: application/json. Every authentication failure answers 403.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `workspace_id` | integer | Yes | The workspace. List the ones your key can reach with GET /v1/workspaces. |
| `connection_id` | string (uuid) | Yes | The connection. |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `region` | string (besg \| usnv) | Yes | Region of the connection: besg or usnv |

## Returns

### 200 OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | object (DeletedConnection) | Yes |  |
| `data.connection_id` | string | Yes |  |

## Example request

```bash
curl -X DELETE "https://api.stacksync.com/v1/workspaces/{workspace_id}/connections/{connection_id}?region=usnv" \
  -H "Authorization: Bearer $STACKSYNC_API_KEY"
```

## Example response (200)

```json
{
  "data": {
    "connection_id": "<connection_id>"
  }
}
```

## Errors

| Status | Meaning | Body |
| --- | --- | --- |
| 400 | Bad Request | `{ "error": string, "msg": string, "field": string \| null }` |
| 403 | Forbidden | `{ "error": string, "msg": string, "field": string \| null }` |
| 404 | Not Found | `{ "error": string, "msg": string, "field": string \| null }` |
| 409 | Conflict | `{ "error": string, "msg": string, "field": string \| null }` |

## Related

- [API Reference overview](https://docs.stacksync.com/api-reference): base URLs, regions, pagination, idempotency and errors
- [Authentication](https://docs.stacksync.com/api-reference/authentication): API keys and the 403 answers
- OpenAPI document: https://docs.stacksync.com/openapi.json
- [List connections](https://docs.stacksync.com/api-reference/connections/list_connections)
- [Get a connection](https://docs.stacksync.com/api-reference/connections/get_connection)
- [Create a connection](https://docs.stacksync.com/api-reference/connections/create_connection)
- [Update a connection](https://docs.stacksync.com/api-reference/connections/update_connection)
- [Reauthorize a connection](https://docs.stacksync.com/api-reference/connections/reauthorize_connection)