> ## Documentation Index
> Fetch the complete documentation index at: https://docs.britive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a policy

## OpenAPI

````json POST /api/v1/policy-admin/policies
{
  "openapi": "3.0.1",
  "info": {
    "title": "Secret Manager APIs",
    "version": "v1",
    "description": "API documentation for Secret Manager, Policy Administration, Notifications, Approval service, etc."
  },
  "servers": [
    {
      "url": "https://{tenantURL}",
      "description": "The primary server",
      "variables": {
        "tenantURL": {
          "default": "test.britive-app.com",
          "description": "The host of the server"
        }
      }
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Approvals"
    },
    {
      "name": "Notification Service"
    },
    {
      "name": "Policy Administration"
    },
    {
      "name": "Secrets Manager"
    },
    {
      "name": "Secret Rotation"
    }
  ],
  "paths": {
    "/api/v1/policy-admin/policies": {
      "post": {
        "tags": [
          "Policy Administration"
        ],
        "summary": "Create a policy",
        "operationId": "createPolicy",
        "parameters": [
          {
            "name": "resource",
            "in": "query",
            "description": "Resource",
            "schema": {
              "type": "string"
            },
            "example": "/a/b/c"
          },
          {
            "name": "consumer",
            "in": "query",
            "description": "Consumer",
            "schema": {
              "type": "string"
            },
            "example": "secretmanager"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PolicyDto"
              }
            }
          },
          "required": "false"
        },
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PolicyDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "maxLength": "128",
            "minLength": "1",
            "pattern": "\\s*[a-zA-Z0-9-_\\s]+\\s*",
            "type": "string"
          },
          "description": {
            "maxLength": "255",
            "minLength": "0",
            "type": "string"
          },
          "isActive": {
            "type": "boolean"
          },
          "isDraft": {
            "type": "boolean"
          },
          "isReadOnly": {
            "type": "boolean"
          },
          "condition": {
            "type": "object",
            "properties": {}
          },
          "permissions": {
            "uniqueItems": "true",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PermissionDto"
            }
          },
          "members": {
            "$ref": "#/components/schemas/MemberDto"
          },
          "roles": {
            "uniqueItems": "true",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RoleDto"
            }
          },
          "resources": {
            "uniqueItems": "true",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "accessLevel": {
            "type": "string"
          },
          "resource": {
            "type": "string"
          },
          "consumer": {
            "type": "string"
          },
          "accessType": {
            "pattern": "\\s*Allow\\s*|\\s*Deny\\s*",
            "type": "string"
          },
          "resourceLabels": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "PermissionDto": {
        "required": [
          "actions",
          "resources"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "pattern": "\\s*[a-zA-Z0-9-_\\s]+\\s*",
            "type": "string"
          },
          "description": {
            "maxLength": "255",
            "minLength": "0",
            "type": "string"
          },
          "consumer": {
            "maxLength": "30",
            "minLength": "0",
            "pattern": "\\s*[a-zA-Z]+\\s*",
            "type": "string"
          },
          "actions": {
            "uniqueItems": "true",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "resources": {
            "uniqueItems": "true",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "isInline": {
            "type": "boolean"
          },
          "isReadOnly": {
            "type": "boolean"
          }
        }
      },
      "MemberDto": {
        "type": "object",
        "properties": {
          "tags": {
            "uniqueItems": "true",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IDNamePair"
            }
          },
          "tokens": {
            "uniqueItems": "true",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IDNamePair"
            }
          },
          "users": {
            "uniqueItems": "true",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IDNamePair"
            }
          },
          "serviceIdentities": {
            "uniqueItems": "true",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IDNamePair"
            }
          }
        }
      },
      "RoleDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "maxLength": "64",
            "minLength": "1",
            "pattern": "\\s*[a-zA-Z0-9-_\\s]+\\s*",
            "type": "string"
          },
          "description": {
            "maxLength": "255",
            "minLength": "0",
            "type": "string"
          },
          "permissions": {
            "uniqueItems": "true",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PermissionDto"
            }
          },
          "isReadOnly": {
            "type": "boolean"
          }
        }
      },
      "IDNamePair": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
````

