# Update policy in organization

`PATCH /v1/organizations/{organization}/policies/{constraint}`, operation `policies.UpdatePolicyInOrganization`

Changes a policy of an organization or a project.

The body is a JSON merge patch (RFC 7396), sent as application/merge-patch+json: `spec` left out keeps the policy, null unsets it, and an object changes it, a field at a time. An organization's policy binds every one of its projects; a project's that is looser than its organization's is kept, and has no effect while the organization's is stricter. With If-Match, the update fails with failed_precondition, as 412, if the policy changed since it was read.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `organization` | path | Yes | `string` | The organization's ID. |
| `constraint` | path | Yes | `string` | The constraint's ID, such as environments.maxDiskGib. |
| `If-Match` | header | No | `string` | The ETag of the policy as it was read: the update fails with failed_precondition, as 412, if it changed since. |

## Request body

Content-Type: `application/merge-patch+json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `spec` | `PolicySpecPatch \| null` | No | Changes to what this level sets, which sets a policy if none is set, or null to unset it, so that what the level above makes apply applies. A spec left with nothing set, such as enforced set to false, unsets it too. |

## Responses

### 200

OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `constraint` | `string` | Yes | The constraint's ID, such as environments.maxDiskGib. |
| `effective` | `EffectivePolicy` | Yes | What applies here: the stricter of the organization's plan, its policy, and the project's, and where it comes from. |
| `effective.allowedValues` | `string[]` | No | Of an allow-list: the values allowed, in the constraint's order; every value where no policy lists them, those kosem adds later too. |
| `effective.enforced` | `boolean` | No | Of a boolean constraint: whether a policy enforces it. |
| `effective.max` | `integer (int64)` | No | Of a max: the most allowed; absent where neither the organization's plan nor any policy lowers it below kosem's limit. |
| `effective.requiredPlan` | `string` | No | When source is plan and upgrading raises this limit, the lowest plan that does. Values: `PRO`, `TEAM`. |
| `effective.source` | `string` | Yes | Where it comes from: the organization's policy, the project's, the organization's plan, or kosem's default, where none restricts it. Values: `organization`, `project`, `plan`, `default`. |
| `inherited` | `EffectivePolicy` | Yes | What the level above makes apply: for a project, its organization's effective policy; for an organization, its plan limit when lower than kosem's limit, else kosem's default. |
| `inherited.allowedValues` | `string[]` | No | Of an allow-list: the values allowed, in the constraint's order; every value where no policy lists them, those kosem adds later too. |
| `inherited.enforced` | `boolean` | No | Of a boolean constraint: whether a policy enforces it. |
| `inherited.max` | `integer (int64)` | No | Of a max: the most allowed; absent where neither the organization's plan nor any policy lowers it below kosem's limit. |
| `inherited.requiredPlan` | `string` | No | When source is plan and upgrading raises this limit, the lowest plan that does. Values: `PRO`, `TEAM`. |
| `inherited.source` | `string` | Yes | Where it comes from: the organization's policy, the project's, the organization's plan, or kosem's default, where none restricts it. Values: `organization`, `project`, `plan`, `default`. |
| `name` | `string` | Yes | Resource name, organizations/{organization_id}/policies/{constraint_id} or projects/{project_id}/policies/{constraint_id}. |
| `spec` | `PolicySpec` | No | What this level sets; absent while unset, where what the level above makes apply applies. |
| `spec.allowedValues` | `string[]` | No | Of an allow-list: the values allowed, of the constraint's, in its order; none allows nothing. |
| `spec.enforced` | `boolean` | No | Of a boolean constraint: true, which enforces it. |
| `spec.max` | `integer (int64)` | No | Of a max: the most allowed, in the constraint's unit. |
| `updateTime` | `string (date-time)` | No | When this level's policy last changed; absent if it never did. |

### default

Error

Base URL: `https://api.kosem.ai`. See [API conventions](https://docs.kosem.ai/reference/api-conventions.md) for authentication, pagination and errors, and [https://docs.kosem.ai/openapi.yaml](https://docs.kosem.ai/openapi.yaml) for the full OpenAPI document.