---
title: "Detach a client from your agency"
url: https://docs.corefinity.com/api/reference/organisation/detach-company-client
type: endpoint
last_updated: 2026-11-13
feature: agency-links
related:
  - https://docs.corefinity.com/guides/agencies/client-organisations-and-the-switcher.md
---
# Detach a client from your agency

Ends the link at once: your people lose access to the client's sites, tickets and billing, and what the
preview counts goes with it. It cannot be undone. Only your agency's owners may detach, and `confirm_client`
must be the client's id.

```http
DELETE /api/company/clients/{client}
```

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 10 a minute
- Try it in the console: off. It deletes data that cannot be brought back. Copy the request and run it yourself when you are sure.

## Path parameters

- `client` (integer, required): The id of one of your agency's clients, as `GET /company/clients` lists it. Digits only.

## Body

- `confirm_client` (integer, required): The id of the client, the same number as in the path.

## Request

### curl

```bash
curl -X DELETE https://manage.corefinity.com/api/company/clients/1204 \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "confirm_client": 1204
  }'
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->delete('https://manage.corefinity.com/api/company/clients/1204', [
        'confirm_client' => 1204,
    ]);

$data = $response->json();
```

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/company/clients/1204', {
  method: 'DELETE',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    confirm_client: 1204,
  }),
});

// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);
```

### Python

```python
import os
import requests

res = requests.delete(
    "https://manage.corefinity.com/api/company/clients/1204",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "confirm_client": 1204,
    },
)

data = res.json() if res.content else None
```

## Responses

### 200 The link was removed. `effects` is what ended.

```json
{
  "detached": {
    "agency_id": 1180,
    "client_id": 1204
  },
  "effects": {
    "firewall": {
      "stay_for_review": 0,
      "stop_applying": 0
    },
    "managed_sites": {
      "count": 0
    },
    "repositories": {
      "count": 1
    },
    "side": "agency",
    "ssh_keys": {
      "count": 0
    },
    "summary": [
      "Your people lose access to this client's sites, tickets and billing at once.",
      "1 environment deploys through the agency's deployment connections. It will need a new deployment connection before its next deployment.",
      "Linking the agency again later does not bring back removed keys, repositories or subscriptions."
    ],
    "ticket_subscriptions": {
      "count": 0
    }
  }
}
```

### 401 No token, or a token that is not valid.

```json
{
  "message": "Unauthenticated."
}
```

### 403 The token lacks the `write` scope (`scope_required`), your company requires two-factor authentication and you have not set it up (`two_factor_required`), you are not an owner of your agency or your agency is archived (`forbidden`), or your company has been deleted (`company_unavailable`).

```json
{
  "code": "forbidden",
  "message": "An archived company cannot change its agency links. Contact Corefinity support.",
  "reason": "forbidden"
}
```

### 404 The id does not exist, or it is something you cannot see. Both answer the same body.

```json
{
  "message": "Not found."
}
```

### 422 `confirm_client` is missing or is not the client's id (`confirm_mismatch`). Nothing was changed; `effects` is what the detach would end.

```json
{
  "code": "confirm_mismatch",
  "effects": {
    "firewall": {
      "stay_for_review": 0,
      "stop_applying": 0
    },
    "managed_sites": {
      "count": 0
    },
    "repositories": {
      "count": 1
    },
    "side": "agency",
    "ssh_keys": {
      "count": 0
    },
    "summary": [
      "Your people lose access to this client's sites, tickets and billing at once.",
      "1 environment deploys through the agency's deployment connections. It will need a new deployment connection before its next deployment.",
      "Linking the agency again later does not bring back removed keys, repositories or subscriptions."
    ],
    "ticket_subscriptions": {
      "count": 0
    }
  },
  "errors": {
    "confirm_client": [
      "Detaching this client ends its access at once and cannot be undone. To detach it, send confirm_client set to its id, 1204. Nothing was changed."
    ]
  },
  "field": "confirm_client",
  "message": "Detaching this client ends its access at once and cannot be undone. To detach it, send confirm_client set to its id, 1204. Nothing was changed.",
  "reason": "confirm_mismatch"
}
```

### 429 Too many requests (`rate_limited`). Wait for the number of seconds in `Retry-After`, which `retry_after_seconds` repeats.

```json
{
  "code": "rate_limited",
  "message": "Too many requests. Try again in 60 seconds.",
  "reason": "rate_limited",
  "retry_after_seconds": 60
}
```

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `forbidden` | The person is not allowed to do this. |
| 403 | `company_unavailable` | Your company is unavailable. |
| 403 | `two_factor_required` | Turn on two-factor on your account, then send again. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 404 |  | Check the id. You see only what your account can reach. |
| 422 | `confirm_mismatch` | Send the confirmation exactly as the field named in `field` asks for it. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |

## The same task elsewhere

- Guide: [Client organisations and the switcher](https://docs.corefinity.com/guides/agencies/client-organisations-and-the-switcher.md)
