---
title: "Create Policy"
method: POST
path: "/policies/{policy_id}"
tags: ["Policies"]
---

# Create Policy

`POST /policies/{policy_id}`

## Request

- Base URL: `http://localhost:8000/api/v1`
- URL: `http://localhost:8000/api/v1/policies/{policy_id}`
- Auth: one of:
  - HTTP bearer
  - API key in header `Authorization`
- TypeScript: <https://skmtc.dev/deeptrail/apis/deepsecure-api-dual-service-architecture/docs/policies/:policy_id/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a new access control policy.

## Request body

- PolicyCreate
  - `name` string, required
  - `agent_id` string, required
  - `effect` 'allow' | 'deny'
  - `actions` string[], required
  - `resources` string[], required
  - `updated_at` string, date-time

## Response `201`

Policy created

- Policy
  - `id` string, uuid
  - `agent_id` string
  - `effect` 'allow' | 'deny'
  - `actions` string[]
  - `resources` string[]
  - `conditions` object: Optional conditions for policy evaluation
  - `created_at` string, date-time

## Other responses

- `400`: Bad Request - Invalid input parameters
- `401`: Unauthorized - Invalid or missing authentication
- `500`: Internal Server Error - Unexpected server error

---

[API](https://skmtc.dev/deeptrail/apis/deepsecure-api-dual-service-architecture.md) - [All operations](https://skmtc.dev/deeptrail/apis/deepsecure-api-dual-service-architecture/llms.txt) - [OpenAPI document](https://skmtc.dev/deeptrail/apis/deepsecure-api-dual-service-architecture/revisions/78627360c082?raw)
