
# 디렉터리 비활성화

`POST /v1/directories/{directory_id}:deactivate` · 권한 `directories:write`

디렉터리를 비활성화합니다(`state`가 `inactive`가 됨). 디렉터리의 토큰은 계속 유효하지만, 디렉터리는 모든 SCIM 요청에 잘못된 토큰과 같은 `401`로 응답하며, 한 번도 사용되지 않은 디렉터리는 첫 요청으로 더 이상 활성화되지 않습니다. 이미 동기화된 사용자와 그룹은 유지됩니다. 되돌리려면 `POST /v1/directories/{directory_id}:activate`를 사용하세요. 이 작업은 멱등적입니다. 디렉터리가 이미 비활성 상태이면 아무것도 쓰지 않고, 버전을 유지하며, 디렉터리를 `200`으로 반환합니다. 쓰기 작업은 `directory.deactivated`로 감사됩니다.

## 요청

| 필드 | 유형 | 필수 | 설명 |
|---|---|---|---|
| `directory_id` | 경로 | 예 | SCIM 디렉터리 ID(`dir_…`). |
| `Idempotency-Key` | 헤더 | 아니요 | 재시도된 요청에 대해 첫 응답을 다시 반환합니다. |

본문은 선택 사항이며 필드가 없습니다(`{}`). `If-Match`는 사용하지 않습니다.

## 응답

디렉터리와 `ETag`를 담은 `200 OK`.

```json
{
  "id": "dir_01j9xm2n4p6q8r0s2t4v6w8y0z",
  "organization_id": "org_01j9xk3m7q8r2s4t6v8w0y2z4a",
  "type": "scim",
  "name": "Okta",
  "state": "inactive",
  "base_url": "https://acme.eu.keenauth.app/scim/v2/dir_01j9xm2n4p6q8r0s2t4v6w8y0z",
  "created_at": "2026-10-19T09:31:00.123456Z",
  "last_request_at": null,
  "provisioning_mode": "user_store",
  "attribute_allowlist": ["title", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:user:department"],
  "unverified_domain_action": "invite",
  "delete_action": "remove_membership",
  "on_delete_memberships": "keep",
  "mass_deprovision_guard": {"enabled": true, "percent": 20, "absolute_min": 25},
  "send_welcome_email": false
}
```

## 오류

| HTTP | code | 발생 조건 |
|---|---|---|
| 400 | `unknown_field` | 본문에 필드가 있습니다. |
| 404 | `not_found` | 이 환경에 디렉터리가 없습니다. |
| 409 | `conflict` | 디렉터리가 삭제 중입니다. |
| 422 | `idempotency_key_reuse` | `Idempotency-Key`가 다른 요청에 사용되었습니다. |
| 401 | `unauthenticated` | 자격 증명이 없거나, 잘못되었거나, 폐기되었습니다. |
| 403 | `insufficient_permissions` | 자격 증명에 필요한 권한이 없습니다. |
| 429 | `rate_limited` | 속도 제한을 초과했습니다. `Retry-After` 시간 후에 다시 시도하세요. |
| 503 | `service_unavailable` | 디렉터리 동기화를 일시적으로 사용할 수 없거나 이 배포에서 구성되지 않았습니다. `Retry-After` 시간 후에 다시 시도하세요. |

## 예시

```bash
curl -i -X POST "https://api.eu.keenauth.com/v1/directories/dir_01j9xm2n4p6q8r0s2t4v6w8y0z:deactivate" \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY"
```
