---
title: "Replace the policy (two-step)"
method: PUT
path: "/api/orgs/{orgId}/policy"
tags: ["policy"]
---

# Replace the policy (two-step)

`PUT /api/orgs/{orgId}/policy`

## Request

- Base URL: `https://api.wizbi.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.wizbi.ai/api/orgs/{orgId}/policy`
- Auth: none declared

`confirm:false` returns a preview with the diff; `confirm:true` saves a new version. New or changed row rules need `canary.row_level` (ADR-0041) and must parse; every group a rule names must be in `groups`; `orgAdminCanEdit` is super_admin only.

## Path parameters

- `orgId` string, required

## Request body

- PutPolicyBody
  - `groups` string[]
  - `rules` object[]
    - `id` string, required
    - `kind` 'topic' | 'source' | 'table' | 'column' | 'row', required
    - `effect` 'allow' | 'deny', required
    - `scope` union, required
      - object
        - `all` true, required
        - `except` string[]
      - object
        - `groups` string[], required
      - object
        - `principals` string[], required
    - `target` object, required
      - `sourceId` string
      - `sources` string[]
      - `table` string
      - `tables` string[]
      - `column` string
      - `columns` string[]
      - `rowFilter` string
      - `rowFilters` object
      - `topic` string
    - `compiled` object
      - `tables` string[]
      - `columns` string[]
      - `keywords` string[]
      - `rationale` string
      - `compiledAt` string, date-time, required
      - `model` string
    - `enabled` boolean
    - `say` string
    - `refusal` string
    - `exemptSuperAdmin` boolean
    - `exemptPrincipals` string[]
    - `note` string
    - `createdAt` string, date-time
    - `createdBy` string
    - `updatedAt` string, date-time
    - `updatedBy` string
  - `orgAdminCanEdit` boolean
  - `note` string
  - `version` integer
  - `confirm` boolean

## Response `200`

Preview or the saved policy.

- PutPolicyResponse
  - `policy` Policy
    - `orgId` string, required
    - `version` integer, required
    - `groups` string[]
    - `rules` object[]
      - `id` string, required
      - `kind` 'topic' | 'source' | 'table' | 'column' | 'row', required
      - `effect` 'allow' | 'deny', required
      - `scope` union, required
        - object
          - `all` true, required
          - `except` string[]
        - object
          - `groups` string[], required
        - object
          - `principals` string[], required
      - `target` object, required
        - `sourceId` string
        - `sources` string[]
        - `table` string
        - `tables` string[]
        - `column` string
        - `columns` string[]
        - `rowFilter` string
        - `rowFilters` object
        - `topic` string
      - `compiled` object
        - `tables` string[]
        - `columns` string[]
        - `keywords` string[]
        - `rationale` string
        - `compiledAt` string, date-time, required
        - `model` string
      - `enabled` boolean
      - `say` string
      - `refusal` string
      - `exemptSuperAdmin` boolean
      - `exemptPrincipals` string[]
      - `note` string
      - `createdAt` string, date-time
      - `createdBy` string
      - `updatedAt` string, date-time
      - `updatedBy` string
    - `rooms` object[]
      - `room` string, required
      - `groupId` string
      - `reads` 'group' | 'speaker'
      - `boundAt` string, date-time, required
      - `boundBy` string, required
      - `note` string
    - `orgAdminCanEdit` boolean
    - `note` string
    - `updatedAt` string, date-time, required
    - `updatedBy` string
  - `preview` object
    - `version` integer, required
    - `groups` string[], required
    - `rules` object[], required
      - `id` string, required
      - `kind` 'topic' | 'source' | 'table' | 'column' | 'row', required
      - `effect` 'allow' | 'deny', required
      - `scope` union, required
        - object
          - `all` true, required
          - `except` string[]
        - object
          - `groups` string[], required
        - object
          - `principals` string[], required
      - `target` object, required
        - `sourceId` string
        - `sources` string[]
        - `table` string
        - `tables` string[]
        - `column` string
        - `columns` string[]
        - `rowFilter` string
        - `rowFilters` object
        - `topic` string
      - `compiled` object
        - `tables` string[]
        - `columns` string[]
        - `keywords` string[]
        - `rationale` string
        - `compiledAt` string, date-time, required
        - `model` string
      - `enabled` boolean
      - `say` string
      - `refusal` string
      - `exemptSuperAdmin` boolean
      - `exemptPrincipals` string[]
      - `note` string
      - `createdAt` string, date-time
      - `createdBy` string
      - `updatedAt` string, date-time
      - `updatedBy` string
    - `orgAdminCanEdit` boolean, required
    - `diff` object, required
      - `added` string[], required
      - `removed` string[], required
      - `changed` string[], required

## Other responses

- `400`: Invalid request.
- `401`: No context.
- `403`: Forbidden.
- `404`: Not found.
- `409`: Stale version.

---

[API](https://skmtc.dev/wizbi/apis/wizbi-core-api.md) · [All operations](https://skmtc.dev/wizbi/apis/wizbi-core-api/llms.txt) · [OpenAPI document](https://skmtc.dev/wizbi/apis/wizbi-core-api/revisions/5a47416c82ec?raw)
