---
title: "Create a guardrail or a custom Cedar policy"
method: POST
path: "/v1/authz/policies"
tags: ["Access"]
---

# Create a guardrail or a custom Cedar policy

`POST /v1/authz/policies`

## Request

- Base URL: `https://api.openrelay.inc`
- URL: `https://api.openrelay.inc/v1/authz/policies`
- Auth: HTTP bearer

Saves a guardrail (key networks, everyone networks or a model allowlist) or a custom Cedar policy and returns it, enabled unless you send enabled: false.
Requires a signed-in session. Guardrails that apply to API keys only need guardrail.manage; the everyone_networks guardrail and every custom policy can block sessions and need policy.manage (owners). A policy that would take policy.manage or member.manage from the saving owner is refused with 409 WOULD_LOCK_OUT.

Checked against the `guardrail.manage` permission for the resource it acts on. See [Permissions](https://docs.openrelay.inc/docs/permissions) for the roles and API key permissions that include it.

## Request body

- AuthzPolicyRequest
  - `cedarText` string
  - `description` string
  - `enabled` boolean: Defaults to true.
  - `endpoints` string[]
  - `guardrail` 'key_networks' | 'everyone_networks' | 'model_allowlist'
  - `ipRanges` string[]
  - `kind` 'guardrail' | 'custom', required
  - `models` string[]
  - `name` string, required

## Response `200`

Created

- AuthzPolicy
  - `cedar` string: The Cedar a guardrail generates.
  - `cedarText` string: A custom policy's Cedar source.
  - `createdAt` string
  - `createdBy` string
  - `description` string
  - `enabled` boolean, required
  - `endpoints` string[]
  - `guardrail` 'key_networks' | 'everyone_networks' | 'model_allowlist': key_networks limits API keys to ipRanges; everyone_networks limits sessions and keys (owners only); model_allowlist limits inference to models and endpoints.
  - `id` string, required
  - `ipRanges` string[]
  - `kind` 'guardrail' | 'custom', required
  - `models` string[]
  - `name` string, required
  - `stale` string: Set when an enabled policy names something this version of OpenRelay does not know, or can no longer be read: what it does now and what to change.
  - `updatedAt` string
  - `updatedBy` string

## Other responses

- `400`: Invalid policy
- `401`: Missing or invalid API key
- `403`: The caller is authenticated but may not do this. The caller's role or the API key's permissions do not allow it, or the request targets another organization (FORBIDDEN, or NOT_A_MEMBER for a session); a permission denial also names the action it needed (permission), which kind of policy denied it (deniedBy) and the deciding policy ids (policies). Or the organization is suspended pending review (ORG_SUSPENDED) or has been deleted (ORG_DISABLED). A new API key or a wider scope clears neither of the last two; see [Account and balance refusals](https://docs.openrelay.inc/docs/errors#account-and-balance-refusals). A user session whose email address is not confirmed is refused on every operation (EMAIL_UNVERIFIED); confirm the address from the confirmation email, then sign in again.
- `404`: Resource not found
- `409`: The request conflicts with existing state

## Changes

- **2026-10-26** `7fe59d94a9f5`: 5 info
  - added the optional property `requestId` to the response with the `400` status
  - added the optional property `requestId` to the response with the `401` status
  - added the optional property `requestId` to the response with the `403` status
  - added the optional property `requestId` to the response with the `404` status
  - …1 more
- **2026-10-10** `12b2fcbcc298`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/openrelay/apis/openrelay-api/changes/v1/authz/policies/post.md)

---

[API](https://skmtc.dev/openrelay/apis/openrelay-api.md) - [All operations](https://skmtc.dev/openrelay/apis/openrelay-api/llms.txt) - [OpenAPI document](https://skmtc.dev/openrelay/apis/openrelay-api/revisions/7fe59d94a9f5?raw)
