---
title: "Create or replace a policy set binding"
method: PUT
path: "/zones/{zone_id}/policy-bindings"
tags: ["PolicyBindings"]
---

# Create or replace a policy set binding

`PUT /zones/{zone_id}/policy-bindings`

## Request

- Base URL: `https://docs.keycard.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://docs.keycard.ai/zones/{zone_id}/policy-bindings`
- Auth: one of:
  - HTTP bearer
  - OAuth 2
    - Client credentials
    - Token URL: `/service-account-token`

Upserts a binding for a slot identified by (scope_type, scope_target_id, mode).
If a binding already exists for the slot, it is replaced. The binding ID
is stable per slot and survives replacements.

## Path parameters

- `zone_id` string, required

## Headers

- `X-API-Version` string
- `X-Client-Request-ID` string, uuid

## Request body

- PdpSetPolicySetBindingRequest: Exactly one of `target_type` or the deprecated `scope_type` must be provided; supplying both with different values returns 400. The same applies to `target_id` / `scope_target_id`.
  - `scope_type` 'zone': **Deprecated.** Use `target_type` instead.
  - `scope_target_id` string: **Deprecated.** Use `target_id` instead.
  - `target_type` 'zone': What the binding targets. Only `zone` is supported for direct binding writes.
  - `target_id` string: Defaults to zone_id for zone targets. Required for other targets.
  - `mode` 'shadow', required: Binding mode
  - `policy_set_id` string, required: Public ID of the policy set to bind
  - `policy_set_version_id` string, required: Public ID of the policy set version to bind

## Response `200`

The binding was created or replaced

- PdpPolicySetBinding
  - `id` string, required: Binding identifier (stable per slot)
  - `scope_type` 'zone', required: **Deprecated.** Use `target_type` instead. Carries the same value.
  - `scope_target_id` string, required: **Deprecated.** Use `target_id` instead. Carries the same value.
  - `target_type` 'zone' | 'user', required: What this binding targets
  - `target_id` string, required: Target entity ID. Equals zone_id for zone-targeted bindings.
  - `mode` 'active' | 'shadow', required: Binding mode
  - `policy_set_id` string, required: Public ID of the bound policy set
  - `policy_set_version_id` string, required: Public ID of the bound policy set version
  - `created_at` string, date-time, required

## Other responses

- `400`: bad request error response when caller supplied invalid input data
- `401`: unauthorized error response when caller session is not authenticated
- `403`: forbidden error response when caller does not have permissions to a resource
- `404`: not found error response when caller does not have permission to see a resource or the resource does not exist
- `429`: rate limit exceeded error response when caller has exhausted api limits for the given time period
- `500`: internal server error response when server encountered error of its own creation
- `default`: internal server error response when server encountered error of its own creation

## Changes

- **2026-10-16** `0cfaff865771`: 14 breaking, 7 warning, 70 info
  - the response property `details/items/field` became optional for the status `400`
  - the response property `details/items/field` became optional for the status `401`
  - the response property `details/items/field` became optional for the status `403`
  - the response property `details/items/field` became optional for the status `404`
  - …87 more
- **2026-06-17** `1a0dd4d857ee`: 1 warning, 9 info
  - added the new `active` enum value to the `mode` response property for the response status `200`
  - added the new optional request property `target_id`
  - added the new optional request property `target_type`
  - the request property `scope_type` became optional
  - …6 more
- **2026-04-20** `932699a5ea16`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/keycardai/apis/keycard-ai-keycard-api/changes/zones/:zone_id/policy-bindings/put.md)

---

[API](https://skmtc.dev/keycardai/apis/keycard-ai-keycard-api.md) - [All operations](https://skmtc.dev/keycardai/apis/keycard-ai-keycard-api/llms.txt) - [OpenAPI document](https://skmtc.dev/keycardai/apis/keycard-ai-keycard-api/revisions/0dee67e0a73a?raw)
