---
title: "Create policy"
method: POST
path: "/policies"
tags: ["policies"]
---

# Create policy

`POST /policies`

## Request

- Base URL: `https://api.instruxi.dev/api/v1/enforcer`
- URL: `https://api.instruxi.dev/api/v1/enforcer/policies`
- Auth: one of:
  - API key in header `Authorization`
  - API key in header `X-API-Key`

Compiles and stores a new custom Rego policy under the fixed enforcer.custom package, live immediately with no restart — every replica compiles and caches it by content hash on first evaluation, not at deploy time. The module is UNTRUSTED CODE by construction: network/host builtins (http.send, net.lookup_ip_addr, opa.runtime) are stripped, so a policy referencing them fails to compile rather than being allowed to exfiltrate accessor data or reach the cluster network. A policy with no tenant_id (global, consumable by every tenant) requires the admin role — 403 forbidden otherwise for a tenant_admin caller.

## Request body

- EnforcerV3InternalUsecasePoliciesWriteInput
  - `active` boolean: Active defaults to true on create; on update it is applied as given.
  - `description` string
  - `name` string
  - `source` string
  - `tenant_id` string: TenantID targets a tenant-scoped policy (admin may target any tenant; a tenant_admin is always pinned to their own). Empty = a global policy (admin only).

## Response `201`

Created

- InternalDeliveryHttpHandlerPolicyResponse
  - `data` EnforcerV3InternalDomainPolicyPolicy
    - `active` boolean
    - `created_at` string
    - `created_by` string
    - `description` string
    - `id` string
    - `name` string
    - `source` string
    - `source_sha` string
    - `tenant_id` string: nil = global
    - `updated_at` string
  - `success` boolean

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden

---

[API](https://skmtc.dev/instruxi/apis/enforcer-api.md) · [All operations](https://skmtc.dev/instruxi/apis/enforcer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/instruxi/apis/enforcer-api/revisions/fa82bc1becc0?raw)
