---
title: "Replace a Directory"
method: PUT
path: "/v2/directories/{directoryId}"
tags: ["Kong Identity Directories"]
---

# Replace a Directory

`PUT /v2/directories/{directoryId}`

Completely replaces an existing directory with the provided data.
All fields must be specified; any omitted fields will be reset to their defaults.

## Request body

- ReplaceDirectoryBody
  - `name` string, required — Human-readable name of the directory, used to identify the organizational boundary. A directory name is unique within the organization.
  - `description` string — Optional description providing additional context about the directory's purpose or usage.
  - `allowed_control_planes` string[] — List of control plane IDs authorized to make authentication requests to this directory. Maximum of 32 control planes can be specified. Use allow_all_control_planes for unrestricted access.
  - `allow_all_control_planes` boolean — When set to true, all control planes within the organization can make authentication requests to this directory. This overrides the allowed_control_planes list. Defaults to false for security.
  - `ttl_secs` integer — The time in seconds that a principal will be cached in memory on a running Gateway if it is successfully authenticated from this directory. Maximum is 86400 seconds (24 hours).
  - `negative_ttl_secs` integer — If a running Gateway triggers a lookup for a principal that cannot be authenticated in this directory, a `negative_ttl_secs` is set. The Gateway will not try to look up the principal in Konnect for `negative_ttl_secs` seconds. A principal will be cached for `negative_ttl_secs` if it does not exist in the directory, or if the provided credentials are invalid. Maximum is 86400 seconds (24 hours).
  - `labels` Labels — Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types. Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".
  - `managed_by` ManagedBy — Stores information about what manages this entity, such as the tool or system responsible for its lifecycle (for example, `terraform`). Keys must be 1–63 characters long and start with an alphanumeric character.

## Response `200`

A Directory

- KongDirectory — A directory represents an organizational boundary for grouping principals and managing their identities. Directories are region-specific and can control which control planes have authentication access.
  - `id` string, uuid, required — Contains a unique identifier used for this resource.
  - `name` string, required — Human-readable name of the directory, used to identify the organizational boundary. A directory name is unique within the organization.
  - `description` string, required — Optional description providing additional context about the directory's purpose or usage.
  - `allowed_control_planes` string[], required — List of control plane IDs authorized to make authentication requests to this directory. Maximum of 32 control planes can be specified. Use allow_all_control_planes for unrestricted access.
  - `allow_all_control_planes` boolean, required — When set to true, all control planes within the organization can make authentication requests to this directory. This overrides the allowed_control_planes list. Defaults to false for security.
  - `ttl_secs` integer, required — The time in seconds that a principal will be cached in memory on a running Gateway if it is successfully authenticated from this directory. Maximum is 86400 seconds (24 hours).
  - `negative_ttl_secs` integer, required — If a running Gateway triggers a lookup for a principal that cannot be authenticated in this directory, a `negative_ttl_secs` is set. The Gateway will not try to look up the principal in Konnect for `negative_ttl_secs` seconds. A principal will be cached for `negative_ttl_secs` if it does not exist in the directory, or if the provided credentials are invalid. Maximum is 86400 seconds (24 hours).
  - `labels` Labels, required — Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types. Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".
  - `managed_by` ManagedBy, required — Stores information about what manages this entity, such as the tool or system responsible for its lifecycle (for example, `terraform`). Keys must be 1–63 characters long and start with an alphanumeric character.
  - `created_at` string, date-time, required — An ISO-8601 timestamp representation of entity creation date.
  - `updated_at` string, date-time, required — An ISO-8601 timestamp representation of entity update date.

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `409` — Conflict

---

[API](https://skmtc.net/kong/apis/konnect-api-beta.md) · [All operations](https://skmtc.net/kong/apis/konnect-api-beta/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kong/konnect-api-beta/versions/73b05fbfd2ef/schema)
