---
title: "corestack_company_client_detach"
url: https://docs.corefinity.com/mcp/tools/corestack_company_client_detach
type: tool
last_updated: 2026-11-13
feature: agency-links
related:
  - https://docs.corefinity.com/guides/agencies/client-organisations-and-the-switcher.md
---
# corestack_company_client_detach

**Detach a client.** Detach one of your agency's client companies: your people lose access to its sites, tickets and billing at once. The agency's owners only. Send confirm_client set to the client's id once the person has agreed; without it nothing changes and the refusal lists what would end. Scope: write.

- Scope: `write`
- Confirmation: `confirm_client`
- Runs as a task: no

## When to use it

Detach one of your agency's client companies, for example a client you no longer work for. Your people lose access to
the client's sites, tickets and billing at once, and you stop managing its sites. Only your agency's owners may detach a
client. Needs the `write` scope. The same as Detach client on the Organisations list in the Control Panel and
`DELETE /api/company/clients/{client}`.

What ends with the link: the client's sites you manage go back to the client, your people's SSH keys on its
environments are removed, your firewall allowances stop applying to its sites, your people stop following its tickets,
and its environments that deploy through your deployment connections lose that repository (the client is shown which
ones need a new deployment connection). Linking again later does not bring back removed keys, repositories or
subscriptions.

Detaching cannot be undone. First call without `confirm_client`: nothing changes, and the `confirm_mismatch` refusal
lists what would end in `details.effects`. Show that to the person, ask them, and only once they have agreed call again
with `confirm_client` set to the client's id.

## Inputs

- `client_id` (integer, required): the client to detach, an `id` from `corestack_company_clients_list`.
- `confirm_client` (integer): the same id again, sent only after the person agreed. Without it, or with another id,
  nothing changes.

The answer is `detached` (`agency_id`, `client_id`) and `effects`: what ended, in the preview's shape.

### Input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "client_id": {
      "description": "The client to detach (corestack_company_clients_list).",
      "minimum": 1,
      "type": "integer"
    },
    "confirm_client": {
      "description": "The same id again, sent only after the person agreed to detach this client.",
      "minimum": 1,
      "type": "integer"
    }
  },
  "required": [
    "client_id"
  ],
  "type": "object"
}
```

## Refusals

- `confirm_mismatch`: `confirm_client` is missing or is not the client's id; `field` names it. Nothing changed.
  `details.effects` is what the detach would end, as counts only (the client's site and environment names are the
  client's): `managed_sites`, `repositories`, `ssh_keys`, `firewall` (`stop_applying`, `stay_for_review`),
  `ticket_subscriptions`, and `summary`, the same in plain sentences.
- `forbidden`: you are not one of your agency's owners, or your agency is archived. Nothing changed.
- `tenant_mismatch`: your agency has no such client, or it was already detached.
- `pin_refused`: a token limited to some sites cannot change company-wide links.
- The refusals every tool can answer: `invalid_arguments`, `tenant_mismatch`, `scope_required`, `pin_refused`, `rate_limited`, `temporarily_unavailable`, `internal_error` (corestack://guides/how-this-server-works).

## Example

```json
{
  "name": "corestack_company_client_detach",
  "arguments": {
    "client_id": 412,
    "confirm_client": 412
  }
}
```

## Prompt

```text
Using the Corefinity MCP server, call corestack_company_client_detach with client_id 412. (Detach a client.) Tell me what it returned.
```

## The same task elsewhere

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