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

What detaching the agency from your company would end, with the names of your own sites and environments.
Nothing is changed. Any member of your company may read it.

```http
GET /api/company/agencies/{agency}/detach-preview
```

- Scope: `read`
- Rate limit: 60 a minute
- Try it in the console: on

## Path parameters

- `agency` (integer, required): The id of an agency your company is a client of, as `GET /company/agencies` lists it. Digits only.

## Request

### curl

```bash
curl https://manage.corefinity.com/api/company/agencies/1180/detach-preview \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json"
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->get('https://manage.corefinity.com/api/company/agencies/1180/detach-preview');

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/company/agencies/1180/detach-preview', {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
  },
});

// 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.get(
    "https://manage.corefinity.com/api/company/agencies/1180/detach-preview",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
)

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

## Responses

### 200 What the detach would end.

```json
{
  "agency_id": 1180,
  "effects": {
    "firewall": {
      "stay_for_review": 0,
      "stop_applying": 0
    },
    "managed_sites": {
      "count": 0,
      "names": []
    },
    "repositories": {
      "count": 1,
      "environments": [
        {
          "id": 1311,
          "name": "Production"
        }
      ],
      "other_environments": 0
    },
    "side": "client",
    "ssh_keys": {
      "count": 0
    },
    "summary": [
      "The agency's people lose access to your 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 `read` scope (`scope_required`), the link is one only Corefinity support can change (`forbidden`), or your company has been deleted (`company_unavailable`).

```json
{
  "code": "company_unavailable",
  "message": "Your company is unavailable.",
  "reason": "company_unavailable"
}
```

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

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

### 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 | `company_unavailable` | Your company is unavailable. |
| 403 | `forbidden` | The person is not allowed to do this. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 404 |  | Check the id. You see only what your account can reach. |
| 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)
