---
title: "Adds a policy with a specific id"
method: POST
path: "/policies/{id}"
tags: ["policies"]
---

# Adds a policy with a specific id

`POST /policies/{id}`

## Request

- Base URL: `/v1` (relative, and the document’s source URL is not known)
- URL: `/v1/policies/{id}`
- Auth: API key in header `Authorization`

Adds a policy corresponding to the provided body and id in this request. A policy binds a role to specific members (groups or users) conditional on an attribute

## Path parameters

- `id` string, required

## Request body

- NewPolicy
  - `entities` EntityId[], required: A list of entities for this policy
  - `role` string, required: Role for this policy
  - `condition` Condition
    - `attribute` string: Attribute of the request
    - `operator` 'StringEquals' | 'StartsWith': operator of the condition
    - `values` Value[]: List of truth condition values

## Response `201`

Successfully added a policy

- Policy
  - `id` string: Unique id for this policy
  - `entities` EntityId[]: A list of entities for this policy
  - `role` string: Role for this policy
  - `condition` Condition
    - `attribute` string: Attribute of the request
    - `operator` 'StringEquals' | 'StartsWith': operator of the condition
    - `values` Value[]: List of truth condition values

## Other responses

- `400`: Bad request. Invalid policy supplied
- `401`: Unauthorised request
- `403`: User is unauthorised for this role
- `409`: Conflict. policy already exists with given id
- `500`: Failed to process the request due to an internal error

---

[API](https://skmtc.dev/office-of-national-statistics/apis/permissions-api.md) - [All operations](https://skmtc.dev/office-of-national-statistics/apis/permissions-api/llms.txt) - [OpenAPI document](https://skmtc.dev/office-of-national-statistics/apis/permissions-api/revisions/c0050251683f?raw)
