> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/api-reference/platform-apis/governance/policies.md).

# Policies

Create, edit and delete Governance policies written in rego

## GET /api/v1/policies

> List all policies

```json
{"openapi":"3.0.3","info":{"title":"Governance Policy Management API","version":"1.2.0"},"tags":[{"name":"policies","description":"Create, edit and delete Governance policies written in rego"}],"servers":[{"url":"https://app.harness.io/gateway/pm/"}],"security":[{"jwt_header_Authorization":["core_governancePolicy_view"]},{"api_key_header_x-api-key":[]}],"components":{"securitySchemes":{"jwt_header_Authorization":{"type":"http","scheme":"bearer"},"api_key_header_x-api-key":{"type":"apiKey","description":"Harness PAT","name":"x-api-key","in":"header"}},"schemas":{"Policy":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID associated with this policy","default":""},"cache_response":{"$ref":"#/components/schemas/CacheResponse"},"created":{"type":"integer","description":"Time the policy was created","format":"int64"},"git_commit_sha":{"type":"string","description":"The commit sha of the commit that last effected the file"},"git_connector_ref":{"type":"string","description":"The harness connector used for authenticating on the git provider"},"git_default_branch":{"type":"string","description":"The default branch, the service pulls in changes from this branch for policy evaluation"},"git_default_branch_commit_sha":{"type":"string","description":"The commit sha of the commit that last effected the file in the default branch"},"git_default_branch_file_id":{"type":"string","description":"The file id of the file in the default branch, may be empty for bitbucket files"},"git_default_branch_file_url":{"type":"string","description":"The url of the file in the default branch"},"git_default_branch_update_error":{"$ref":"#/components/schemas/GitErrorResult"},"git_default_branch_updated":{"type":"integer","description":"The last time the service successfully pulled in changes from the default branch","format":"int64"},"git_file_id":{"type":"string","description":"The file id of the file, may be empty for bitbucket files"},"git_file_url":{"type":"string","description":"The url of the file on the fit provider"},"git_path":{"type":"string","description":"The path to the file in the git repo"},"git_repo":{"type":"string","description":"The git repo the policy resides in"},"identifier":{"type":"string","description":"identifier of the policy","minLength":1},"name":{"type":"string","description":"Name of the policy","minLength":1},"org_id":{"type":"string","description":"Harness organization ID associated with this policy","default":""},"parent_unique_id":{"type":"string","description":"Parent unique identifier for the policy"},"polciy_size_in_bytes":{"type":"integer","description":"Size of the policy in bytes","format":"int64"},"policy_package_name":{"type":"string","description":"Package name of the policy"},"policy_set_count":{"type":"integer","description":"Count of policy sets associated with this policy","format":"int64"},"project_id":{"type":"string","description":"Harness project ID associated with this policy","default":""},"rego":{"type":"string","description":"Rego that defines the policy","minLength":1},"unique_id":{"type":"string","description":"Unique identifier for the policy"},"updated":{"type":"integer","description":"Time the policy was last updated","format":"int64"}},"required":["identifier","name","rego","created","updated","account_id","org_id","project_id"]},"CacheResponse":{"type":"object","properties":{"cache_state":{"type":"string","description":"Cache state (UNKNOWN_STATE, VALID_CACHE, STALE_CACHE)"},"is_sync_enabled":{"type":"boolean","description":"Whether sync is enabled for this resource"},"last_updated_at":{"type":"integer","description":"Timestamp (millis) when cache was last updated","format":"int64"},"ttl_left":{"type":"integer","description":"Remaining time-to-live in milliseconds","format":"int64"}},"description":"Cache metadata from GitX getFile RPC"},"GitErrorResult":{"type":"object","properties":{"explanation":{"type":"string","description":"the explanation of the error"},"hint":{"type":"string","description":"the hint on how to resolve the error"},"message":{"type":"string","description":"the message is a human-readable explanation specific to this occurrence of the problem"}},"required":["message","explanation","hint"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]},"PolicyReferencedResult":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable warning message"},"referenced_by":{"type":"array","items":{"$ref":"#/components/schemas/PolicySetRef"},"description":"Policy sets that reference this policy"}},"description":"Error returned when deleting a policy that is referenced by policy sets","required":["message","referenced_by"]},"PolicySetRef":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID"},"identifier":{"type":"string","description":"Identifier of the referencing policy set"},"name":{"type":"string","description":"Name of the referencing policy set"},"org_id":{"type":"string","description":"Harness organization ID","default":""},"project_id":{"type":"string","description":"Harness project ID","default":""}},"description":"Lightweight reference to a policy set (used in error responses)","required":["identifier","name","account_id"]}}},"paths":{"/api/v1/policies":{"get":{"tags":["policies"],"description":"List all policies","operationId":"policies#list","parameters":[{"name":"accountIdentifier","in":"query","description":"Harness account ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness account ID","default":""}},{"name":"orgIdentifier","in":"query","description":"Harness organization ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness organization ID","default":""}},{"name":"projectIdentifier","in":"query","description":"Harness project ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness project ID","default":""}},{"name":"per_page","in":"query","description":"Number of results per page","allowEmptyValue":true,"schema":{"type":"integer","description":"Number of results per page","default":50,"format":"int64","minimum":1,"maximum":100}},{"name":"page","in":"query","description":"Page number (starting from 0)","allowEmptyValue":true,"schema":{"type":"integer","description":"Page number (starting from 0)","default":0,"format":"int64","minimum":0}},{"name":"identifierFilter","in":"query","description":"Comma separated List of Identifiers to filter on","allowEmptyValue":true,"schema":{"type":"string","description":"Comma separated List of Identifiers to filter on","default":""}},{"name":"searchTerm","in":"query","description":"Filter results by partial name match","allowEmptyValue":true,"schema":{"type":"string","description":"Filter results by partial name match","default":""}},{"name":"sort","in":"query","description":"Sort order for results","allowEmptyValue":true,"schema":{"type":"string","description":"Sort order for results","default":"name,ASC","enum":["name,ASC","name,DESC","updated,ASC","updated,DESC"]}},{"name":"excludeRegoFromResponse","in":"query","description":"Set to true to exclude Rego content from the response","allowEmptyValue":true,"schema":{"type":"boolean","description":"Set to true to exclude Rego content from the response","default":false}},{"name":"includePolicySetCount","in":"query","description":"Set to true to include the count of policy sets associated with each policy in the response","allowEmptyValue":true,"schema":{"type":"boolean","description":"Set to true to include the count of policy sets associated with each policy in the response","default":false}},{"name":"x-api-key","in":"header","description":"Harness PAT key used to perform authorization","allowEmptyValue":true,"schema":{"type":"string","description":"Harness PAT key used to perform authorization"}}],"responses":{"200":{"description":"OK response.","headers":{"Link":{"description":"Link-based paging","schema":{"type":"string","description":"Link-based paging"}},"X-Page-Index":{"description":"Deprecated: Please use pageNumber / X-Page-Number instead. Same value as pageNumber; kept for legacy UI clients.","schema":{"type":"integer","description":"Deprecated: Please use pageNumber / X-Page-Number instead. Same value as pageNumber; kept for legacy UI clients.","format":"int64"}},"X-Page-Item-Count":{"description":"Number of results in this page","schema":{"type":"integer","description":"Number of results in this page","format":"int64"}},"X-Page-Number":{"description":"Current page number (0-based). Harness standard pagination header X-Page-Number.","schema":{"type":"integer","description":"Current page number (0-based). Harness standard pagination header X-Page-Number.","format":"int64"}},"X-Page-Size":{"description":"Requested page size. Harness standard pagination header X-Page-Size.","schema":{"type":"integer","description":"Requested page size. Harness standard pagination header X-Page-Size.","format":"int64"}},"X-Total-Elements":{"description":"Total number of results available. Harness standard pagination header X-Total-Elements.","schema":{"type":"integer","description":"Total number of results available. Harness standard pagination header X-Total-Elements.","format":"int64"}},"X-Total-Items":{"description":"Deprecated: Please use totalElements / X-Total-Elements instead. Same value as totalElements; kept for legacy UI clients.","schema":{"type":"integer","description":"Deprecated: Please use totalElements / X-Total-Elements instead. Same value as totalElements; kept for legacy UI clients.","format":"int64"}},"X-Total-Pages":{"description":"Total pages available","schema":{"type":"integer","description":"Total pages available","format":"int64"}}},"content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Policy"}}}}},"400":{"description":"GitError: Bad Request response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFound: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"PolicyReferenced: Conflict response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyReferencedResult"}}}},"500":{"description":"ScopeInfoError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGateway: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## POST /api/v1/policies

> Create a policy

```json
{"openapi":"3.0.3","info":{"title":"Governance Policy Management API","version":"1.2.0"},"tags":[{"name":"policies","description":"Create, edit and delete Governance policies written in rego"}],"servers":[{"url":"https://app.harness.io/gateway/pm/"}],"security":[{"jwt_header_Authorization":["core_governancePolicy_create"]},{"api_key_header_x-api-key":[]}],"components":{"securitySchemes":{"jwt_header_Authorization":{"type":"http","scheme":"bearer"},"api_key_header_x-api-key":{"type":"apiKey","description":"Harness PAT","name":"x-api-key","in":"header"}},"schemas":{"CreateRequestBody":{"type":"object","properties":{"git_connector_ref":{"type":"string","description":"The harness connector used for authenticating on the git provider"},"git_path":{"type":"string","description":"The path to the file in the git repo"},"git_repo":{"type":"string","description":"The git repo the policy resides in"},"identifier":{"type":"string","description":"Identifier for the policy","minLength":1},"name":{"type":"string","description":"Name of the policy","minLength":1},"rego":{"type":"string","description":"Rego that defines the policy"}},"required":["name","identifier"]},"Policy":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID associated with this policy","default":""},"cache_response":{"$ref":"#/components/schemas/CacheResponse"},"created":{"type":"integer","description":"Time the policy was created","format":"int64"},"git_commit_sha":{"type":"string","description":"The commit sha of the commit that last effected the file"},"git_connector_ref":{"type":"string","description":"The harness connector used for authenticating on the git provider"},"git_default_branch":{"type":"string","description":"The default branch, the service pulls in changes from this branch for policy evaluation"},"git_default_branch_commit_sha":{"type":"string","description":"The commit sha of the commit that last effected the file in the default branch"},"git_default_branch_file_id":{"type":"string","description":"The file id of the file in the default branch, may be empty for bitbucket files"},"git_default_branch_file_url":{"type":"string","description":"The url of the file in the default branch"},"git_default_branch_update_error":{"$ref":"#/components/schemas/GitErrorResult"},"git_default_branch_updated":{"type":"integer","description":"The last time the service successfully pulled in changes from the default branch","format":"int64"},"git_file_id":{"type":"string","description":"The file id of the file, may be empty for bitbucket files"},"git_file_url":{"type":"string","description":"The url of the file on the fit provider"},"git_path":{"type":"string","description":"The path to the file in the git repo"},"git_repo":{"type":"string","description":"The git repo the policy resides in"},"identifier":{"type":"string","description":"identifier of the policy","minLength":1},"name":{"type":"string","description":"Name of the policy","minLength":1},"org_id":{"type":"string","description":"Harness organization ID associated with this policy","default":""},"parent_unique_id":{"type":"string","description":"Parent unique identifier for the policy"},"polciy_size_in_bytes":{"type":"integer","description":"Size of the policy in bytes","format":"int64"},"policy_package_name":{"type":"string","description":"Package name of the policy"},"policy_set_count":{"type":"integer","description":"Count of policy sets associated with this policy","format":"int64"},"project_id":{"type":"string","description":"Harness project ID associated with this policy","default":""},"rego":{"type":"string","description":"Rego that defines the policy","minLength":1},"unique_id":{"type":"string","description":"Unique identifier for the policy"},"updated":{"type":"integer","description":"Time the policy was last updated","format":"int64"}},"required":["identifier","name","rego","created","updated","account_id","org_id","project_id"]},"CacheResponse":{"type":"object","properties":{"cache_state":{"type":"string","description":"Cache state (UNKNOWN_STATE, VALID_CACHE, STALE_CACHE)"},"is_sync_enabled":{"type":"boolean","description":"Whether sync is enabled for this resource"},"last_updated_at":{"type":"integer","description":"Timestamp (millis) when cache was last updated","format":"int64"},"ttl_left":{"type":"integer","description":"Remaining time-to-live in milliseconds","format":"int64"}},"description":"Cache metadata from GitX getFile RPC"},"GitErrorResult":{"type":"object","properties":{"explanation":{"type":"string","description":"the explanation of the error"},"hint":{"type":"string","description":"the hint on how to resolve the error"},"message":{"type":"string","description":"the message is a human-readable explanation specific to this occurrence of the problem"}},"required":["message","explanation","hint"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]},"PolicyReferencedResult":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable warning message"},"referenced_by":{"type":"array","items":{"$ref":"#/components/schemas/PolicySetRef"},"description":"Policy sets that reference this policy"}},"description":"Error returned when deleting a policy that is referenced by policy sets","required":["message","referenced_by"]},"PolicySetRef":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID"},"identifier":{"type":"string","description":"Identifier of the referencing policy set"},"name":{"type":"string","description":"Name of the referencing policy set"},"org_id":{"type":"string","description":"Harness organization ID","default":""},"project_id":{"type":"string","description":"Harness project ID","default":""}},"description":"Lightweight reference to a policy set (used in error responses)","required":["identifier","name","account_id"]}}},"paths":{"/api/v1/policies":{"post":{"tags":["policies"],"description":"Create a policy","operationId":"policies#create","parameters":[{"name":"accountIdentifier","in":"query","description":"Harness account ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness account ID","default":""}},{"name":"orgIdentifier","in":"query","description":"Harness organization ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness organization ID","default":""}},{"name":"projectIdentifier","in":"query","description":"Harness project ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness project ID","default":""}},{"name":"git_commit_msg","in":"query","description":"The commit message used in git when creating the policy","allowEmptyValue":true,"schema":{"type":"string","description":"The commit message used in git when creating the policy"}},{"name":"git_import","in":"query","description":"A flag to determine if the api should try and import and existing policy from git","allowEmptyValue":true,"schema":{"type":"boolean","description":"A flag to determine if the api should try and import and existing policy from git"}},{"name":"git_branch","in":"query","description":"The git branch the policy will be created in","allowEmptyValue":true,"schema":{"type":"string","description":"The git branch the policy will be created in"}},{"name":"git_is_new_branch","in":"query","description":"A flag to determine if the api should try and commit to a new branch","allowEmptyValue":true,"schema":{"type":"boolean","description":"A flag to determine if the api should try and commit to a new branch"}},{"name":"git_base_branch","in":"query","description":"If committing to a new branch, git_base_branch tells the api which branch to base the new branch from","allowEmptyValue":true,"schema":{"type":"string","description":"If committing to a new branch, git_base_branch tells the api which branch to base the new branch from"}},{"name":"x-api-key","in":"header","description":"Harness PAT key used to perform authorization","allowEmptyValue":true,"schema":{"type":"string","description":"Harness PAT key used to perform authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRequestBody"}}}},"responses":{"201":{"description":"Created response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Policy"}}}},"400":{"description":"GitError: Bad Request response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFound: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"PolicyReferenced: Conflict response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyReferencedResult"}}}},"500":{"description":"ScopeInfoError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGateway: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Dry run policy evaluation

> Evaluate a Rego policy against recent entity inputs without persisting results (dry run). Requires CREATE permission when identifier is omitted; EDIT when identifier is present.

```json
{"openapi":"3.0.3","info":{"title":"Governance Policy Management API","version":"1.2.0"},"tags":[{"name":"policies","description":"Create, edit and delete Governance policies written in rego"}],"servers":[{"url":"https://app.harness.io/gateway/pm/"}],"security":[{"jwt_header_Authorization":["core_governancePolicy_edit"]},{"api_key_header_x-api-key":[]}],"components":{"securitySchemes":{"jwt_header_Authorization":{"type":"http","scheme":"bearer"},"api_key_header_x-api-key":{"type":"apiKey","description":"Harness PAT","name":"x-api-key","in":"header"}},"schemas":{"DryRunRequestBody":{"type":"object","properties":{"action":{"type":"string","description":"Optional action filter (e.g. onrun, onsave). Restricts history replay to evaluations with this action."},"entityOrgIdentifier":{"type":"string","description":"Optional analysis org. Must stay within the policy scope hierarchy. Omit at account-level policy to replay account-wide."},"entityProjectIdentifier":{"type":"string","description":"Optional analysis project. Omit at org-level policy to replay all projects in the org. Requires entityOrgIdentifier when the policy is account-level."},"identifier":{"type":"string","description":"Policy identifier for edit mode. Used for RBAC and existence check only. Returns 404 if not found."},"rego":{"type":"string","description":"Rego source to evaluate. Always required — UI sends the current editor content (inline or GitX-loaded) on both create and edit."},"type":{"type":"string","description":"Entity type to evaluate against (e.g. pipeline, featureFlag). Required."}},"required":["type","rego"]},"DryRunResult":{"type":"object","properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/DryRunEntityResult"},"description":"Per-entity evaluation results"},"summary":{"$ref":"#/components/schemas/DryRunSummary"}},"description":"Dry-run evaluation response","required":["summary","results"]},"DryRunEntityResult":{"type":"object","properties":{"deny_messages":{"type":"array","items":{"type":"string"},"description":"Deny messages produced by the Rego policy"},"entity":{"type":"string","description":"Entity identifier that was evaluated"},"error":{"type":"string","description":"Error message when evaluation failed (e.g. GCS fetch timeout, parse error)"},"source":{"type":"string","description":"Origin of the input: history or sample_payload"},"source_evaluation_id":{"type":"integer","description":"ID of the history evaluation this input was replayed from (only set when source=history)","format":"int64"},"status":{"type":"string","description":"Evaluation status: pass, fail, or error","enum":["pass","fail","error"]}},"description":"Result of evaluating a single entity payload during dry run","required":["entity","status","source"]},"DryRunSummary":{"type":"object","properties":{"errors":{"type":"integer","description":"Number of entities that could not be evaluated due to infrastructure errors","format":"int64"},"failed":{"type":"integer","description":"Number of entities that triggered at least one deny rule","format":"int64"},"passed":{"type":"integer","description":"Number of entities that passed all deny rules","format":"int64"},"total":{"type":"integer","description":"Total number of entities evaluated","format":"int64"}},"description":"Aggregate counts for a dry-run evaluation","required":["total","passed","failed","errors"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]},"PolicyReferencedResult":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable warning message"},"referenced_by":{"type":"array","items":{"$ref":"#/components/schemas/PolicySetRef"},"description":"Policy sets that reference this policy"}},"description":"Error returned when deleting a policy that is referenced by policy sets","required":["message","referenced_by"]},"PolicySetRef":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID"},"identifier":{"type":"string","description":"Identifier of the referencing policy set"},"name":{"type":"string","description":"Name of the referencing policy set"},"org_id":{"type":"string","description":"Harness organization ID","default":""},"project_id":{"type":"string","description":"Harness project ID","default":""}},"description":"Lightweight reference to a policy set (used in error responses)","required":["identifier","name","account_id"]}}},"paths":{"/api/v1/policies/dry-run":{"post":{"tags":["policies"],"summary":"Dry run policy evaluation","description":"Evaluate a Rego policy against recent entity inputs without persisting results (dry run). Requires CREATE permission when identifier is omitted; EDIT when identifier is present.","operationId":"policies#dry_run","parameters":[{"name":"accountIdentifier","in":"query","description":"Harness account ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness account ID","default":""}},{"name":"orgIdentifier","in":"query","description":"Harness organization ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness organization ID","default":""}},{"name":"projectIdentifier","in":"query","description":"Harness project ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness project ID","default":""}},{"name":"x-api-key","in":"header","description":"Harness PAT key used to perform authorization","allowEmptyValue":true,"schema":{"type":"string","description":"Harness PAT key used to perform authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DryRunRequestBody"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DryRunResult"}}}},"400":{"description":"GitError: Bad Request response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFound: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"PolicyReferenced: Conflict response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyReferencedResult"}}}},"500":{"description":"ScopeInfoError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGateway: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## POST /api/v1/policies/move-policy/{identifier}

> Move an inline policy's configuration to remote (Git)

```json
{"openapi":"3.0.3","info":{"title":"Governance Policy Management API","version":"1.2.0"},"tags":[{"name":"policies","description":"Create, edit and delete Governance policies written in rego"}],"servers":[{"url":"https://app.harness.io/gateway/pm/"}],"security":[{"jwt_header_Authorization":["core_governancePolicy_edit"]},{"api_key_header_x-api-key":[]}],"components":{"securitySchemes":{"jwt_header_Authorization":{"type":"http","scheme":"bearer"},"api_key_header_x-api-key":{"type":"apiKey","description":"Harness PAT","name":"x-api-key","in":"header"}},"schemas":{"MovePolicyRequestBody":{"type":"object","properties":{"git_base_branch":{"type":"string","description":"If committing to a new branch, git_base_branch tells the api which branch to base the new branch from"},"git_branch":{"type":"string","description":"The git branch to commit the policy to"},"git_commit_msg":{"type":"string","description":"The commit message used in git when moving the policy"},"git_connector_ref":{"type":"string","description":"The harness connector used for authenticating on the git provider"},"git_is_new_branch":{"type":"boolean","description":"A flag to determine if the api should try and commit to a new branch"},"git_path":{"type":"string","description":"The path to the file in the git repo"},"git_repo":{"type":"string","description":"The git repo to store the policy in"}},"required":["git_repo","git_branch","git_path","git_commit_msg"]},"Policy":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID associated with this policy","default":""},"cache_response":{"$ref":"#/components/schemas/CacheResponse"},"created":{"type":"integer","description":"Time the policy was created","format":"int64"},"git_commit_sha":{"type":"string","description":"The commit sha of the commit that last effected the file"},"git_connector_ref":{"type":"string","description":"The harness connector used for authenticating on the git provider"},"git_default_branch":{"type":"string","description":"The default branch, the service pulls in changes from this branch for policy evaluation"},"git_default_branch_commit_sha":{"type":"string","description":"The commit sha of the commit that last effected the file in the default branch"},"git_default_branch_file_id":{"type":"string","description":"The file id of the file in the default branch, may be empty for bitbucket files"},"git_default_branch_file_url":{"type":"string","description":"The url of the file in the default branch"},"git_default_branch_update_error":{"$ref":"#/components/schemas/GitErrorResult"},"git_default_branch_updated":{"type":"integer","description":"The last time the service successfully pulled in changes from the default branch","format":"int64"},"git_file_id":{"type":"string","description":"The file id of the file, may be empty for bitbucket files"},"git_file_url":{"type":"string","description":"The url of the file on the fit provider"},"git_path":{"type":"string","description":"The path to the file in the git repo"},"git_repo":{"type":"string","description":"The git repo the policy resides in"},"identifier":{"type":"string","description":"identifier of the policy","minLength":1},"name":{"type":"string","description":"Name of the policy","minLength":1},"org_id":{"type":"string","description":"Harness organization ID associated with this policy","default":""},"parent_unique_id":{"type":"string","description":"Parent unique identifier for the policy"},"polciy_size_in_bytes":{"type":"integer","description":"Size of the policy in bytes","format":"int64"},"policy_package_name":{"type":"string","description":"Package name of the policy"},"policy_set_count":{"type":"integer","description":"Count of policy sets associated with this policy","format":"int64"},"project_id":{"type":"string","description":"Harness project ID associated with this policy","default":""},"rego":{"type":"string","description":"Rego that defines the policy","minLength":1},"unique_id":{"type":"string","description":"Unique identifier for the policy"},"updated":{"type":"integer","description":"Time the policy was last updated","format":"int64"}},"required":["identifier","name","rego","created","updated","account_id","org_id","project_id"]},"CacheResponse":{"type":"object","properties":{"cache_state":{"type":"string","description":"Cache state (UNKNOWN_STATE, VALID_CACHE, STALE_CACHE)"},"is_sync_enabled":{"type":"boolean","description":"Whether sync is enabled for this resource"},"last_updated_at":{"type":"integer","description":"Timestamp (millis) when cache was last updated","format":"int64"},"ttl_left":{"type":"integer","description":"Remaining time-to-live in milliseconds","format":"int64"}},"description":"Cache metadata from GitX getFile RPC"},"GitErrorResult":{"type":"object","properties":{"explanation":{"type":"string","description":"the explanation of the error"},"hint":{"type":"string","description":"the hint on how to resolve the error"},"message":{"type":"string","description":"the message is a human-readable explanation specific to this occurrence of the problem"}},"required":["message","explanation","hint"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]},"PolicyReferencedResult":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable warning message"},"referenced_by":{"type":"array","items":{"$ref":"#/components/schemas/PolicySetRef"},"description":"Policy sets that reference this policy"}},"description":"Error returned when deleting a policy that is referenced by policy sets","required":["message","referenced_by"]},"PolicySetRef":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID"},"identifier":{"type":"string","description":"Identifier of the referencing policy set"},"name":{"type":"string","description":"Name of the referencing policy set"},"org_id":{"type":"string","description":"Harness organization ID","default":""},"project_id":{"type":"string","description":"Harness project ID","default":""}},"description":"Lightweight reference to a policy set (used in error responses)","required":["identifier","name","account_id"]}}},"paths":{"/api/v1/policies/move-policy/{identifier}":{"post":{"tags":["policies"],"description":"Move an inline policy's configuration to remote (Git)","operationId":"policies#move_policy","parameters":[{"name":"accountIdentifier","in":"query","description":"Harness account ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness account ID","default":""}},{"name":"orgIdentifier","in":"query","description":"Harness organization ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness organization ID","default":""}},{"name":"projectIdentifier","in":"query","description":"Harness project ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness project ID","default":""}},{"name":"identifier","in":"path","description":"Identifier of the policy to move","required":true,"schema":{"type":"string","description":"Identifier of the policy to move","minLength":1}},{"name":"x-api-key","in":"header","description":"Harness PAT key used to perform authorization","allowEmptyValue":true,"schema":{"type":"string","description":"Harness PAT key used to perform authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MovePolicyRequestBody"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Policy"}}}},"400":{"description":"GitError: Bad Request response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFound: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"PolicyReferenced: Conflict response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyReferencedResult"}}}},"500":{"description":"ScopeInfoError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGateway: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## GET /api/v1/policies/{identifier}

> Find a policy by identifier

```json
{"openapi":"3.0.3","info":{"title":"Governance Policy Management API","version":"1.2.0"},"tags":[{"name":"policies","description":"Create, edit and delete Governance policies written in rego"}],"servers":[{"url":"https://app.harness.io/gateway/pm/"}],"security":[{"jwt_header_Authorization":["core_governancePolicy_view"]},{"api_key_header_x-api-key":[]}],"components":{"securitySchemes":{"jwt_header_Authorization":{"type":"http","scheme":"bearer"},"api_key_header_x-api-key":{"type":"apiKey","description":"Harness PAT","name":"x-api-key","in":"header"}},"schemas":{"Policy":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID associated with this policy","default":""},"cache_response":{"$ref":"#/components/schemas/CacheResponse"},"created":{"type":"integer","description":"Time the policy was created","format":"int64"},"git_commit_sha":{"type":"string","description":"The commit sha of the commit that last effected the file"},"git_connector_ref":{"type":"string","description":"The harness connector used for authenticating on the git provider"},"git_default_branch":{"type":"string","description":"The default branch, the service pulls in changes from this branch for policy evaluation"},"git_default_branch_commit_sha":{"type":"string","description":"The commit sha of the commit that last effected the file in the default branch"},"git_default_branch_file_id":{"type":"string","description":"The file id of the file in the default branch, may be empty for bitbucket files"},"git_default_branch_file_url":{"type":"string","description":"The url of the file in the default branch"},"git_default_branch_update_error":{"$ref":"#/components/schemas/GitErrorResult"},"git_default_branch_updated":{"type":"integer","description":"The last time the service successfully pulled in changes from the default branch","format":"int64"},"git_file_id":{"type":"string","description":"The file id of the file, may be empty for bitbucket files"},"git_file_url":{"type":"string","description":"The url of the file on the fit provider"},"git_path":{"type":"string","description":"The path to the file in the git repo"},"git_repo":{"type":"string","description":"The git repo the policy resides in"},"identifier":{"type":"string","description":"identifier of the policy","minLength":1},"name":{"type":"string","description":"Name of the policy","minLength":1},"org_id":{"type":"string","description":"Harness organization ID associated with this policy","default":""},"parent_unique_id":{"type":"string","description":"Parent unique identifier for the policy"},"polciy_size_in_bytes":{"type":"integer","description":"Size of the policy in bytes","format":"int64"},"policy_package_name":{"type":"string","description":"Package name of the policy"},"policy_set_count":{"type":"integer","description":"Count of policy sets associated with this policy","format":"int64"},"project_id":{"type":"string","description":"Harness project ID associated with this policy","default":""},"rego":{"type":"string","description":"Rego that defines the policy","minLength":1},"unique_id":{"type":"string","description":"Unique identifier for the policy"},"updated":{"type":"integer","description":"Time the policy was last updated","format":"int64"}},"required":["identifier","name","rego","created","updated","account_id","org_id","project_id"]},"CacheResponse":{"type":"object","properties":{"cache_state":{"type":"string","description":"Cache state (UNKNOWN_STATE, VALID_CACHE, STALE_CACHE)"},"is_sync_enabled":{"type":"boolean","description":"Whether sync is enabled for this resource"},"last_updated_at":{"type":"integer","description":"Timestamp (millis) when cache was last updated","format":"int64"},"ttl_left":{"type":"integer","description":"Remaining time-to-live in milliseconds","format":"int64"}},"description":"Cache metadata from GitX getFile RPC"},"GitErrorResult":{"type":"object","properties":{"explanation":{"type":"string","description":"the explanation of the error"},"hint":{"type":"string","description":"the hint on how to resolve the error"},"message":{"type":"string","description":"the message is a human-readable explanation specific to this occurrence of the problem"}},"required":["message","explanation","hint"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]},"PolicyReferencedResult":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable warning message"},"referenced_by":{"type":"array","items":{"$ref":"#/components/schemas/PolicySetRef"},"description":"Policy sets that reference this policy"}},"description":"Error returned when deleting a policy that is referenced by policy sets","required":["message","referenced_by"]},"PolicySetRef":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID"},"identifier":{"type":"string","description":"Identifier of the referencing policy set"},"name":{"type":"string","description":"Name of the referencing policy set"},"org_id":{"type":"string","description":"Harness organization ID","default":""},"project_id":{"type":"string","description":"Harness project ID","default":""}},"description":"Lightweight reference to a policy set (used in error responses)","required":["identifier","name","account_id"]}}},"paths":{"/api/v1/policies/{identifier}":{"get":{"tags":["policies"],"description":"Find a policy by identifier","operationId":"policies#find","parameters":[{"name":"accountIdentifier","in":"query","description":"Harness account ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness account ID","default":""}},{"name":"orgIdentifier","in":"query","description":"Harness organization ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness organization ID","default":""}},{"name":"projectIdentifier","in":"query","description":"Harness project ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness project ID","default":""}},{"name":"git_branch","in":"query","description":"The git branch the policy resides in","allowEmptyValue":true,"schema":{"type":"string","description":"The git branch the policy resides in"}},{"name":"show_summary","in":"query","description":"Setting to true returns the metadata about the\n\t\t\t    requested policy including the information held about the status of this policy in the default branch.\n\t\t\t    git_branch is ignored as no git operation takes place.","allowEmptyValue":true,"schema":{"type":"boolean","description":"Setting to true returns the metadata about the\n\t\t\t    requested policy including the information held about the status of this policy in the default branch.\n\t\t\t    git_branch is ignored as no git operation takes place."}},{"name":"identifier","in":"path","description":"Identifier of the policy to retrieve","required":true,"schema":{"type":"string","description":"Identifier of the policy to retrieve","minLength":1}},{"name":"x-api-key","in":"header","description":"Harness PAT key used to perform authorization","allowEmptyValue":true,"schema":{"type":"string","description":"Harness PAT key used to perform authorization"}}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Policy"}}}},"400":{"description":"GitError: Bad Request response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFound: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"PolicyReferenced: Conflict response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyReferencedResult"}}}},"500":{"description":"ScopeInfoError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGateway: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## DELETE /api/v1/policies/{identifier}

> Delete a policy by identifier. Returns 409 Conflict if the policy is referenced by policy sets (unless force=true).

```json
{"openapi":"3.0.3","info":{"title":"Governance Policy Management API","version":"1.2.0"},"tags":[{"name":"policies","description":"Create, edit and delete Governance policies written in rego"}],"servers":[{"url":"https://app.harness.io/gateway/pm/"}],"security":[{"jwt_header_Authorization":["core_governancePolicy_delete"]},{"api_key_header_x-api-key":[]}],"components":{"securitySchemes":{"jwt_header_Authorization":{"type":"http","scheme":"bearer"},"api_key_header_x-api-key":{"type":"apiKey","description":"Harness PAT","name":"x-api-key","in":"header"}},"schemas":{"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]},"PolicyReferencedResult":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable warning message"},"referenced_by":{"type":"array","items":{"$ref":"#/components/schemas/PolicySetRef"},"description":"Policy sets that reference this policy"}},"description":"Error returned when deleting a policy that is referenced by policy sets","required":["message","referenced_by"]},"PolicySetRef":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID"},"identifier":{"type":"string","description":"Identifier of the referencing policy set"},"name":{"type":"string","description":"Name of the referencing policy set"},"org_id":{"type":"string","description":"Harness organization ID","default":""},"project_id":{"type":"string","description":"Harness project ID","default":""}},"description":"Lightweight reference to a policy set (used in error responses)","required":["identifier","name","account_id"]}}},"paths":{"/api/v1/policies/{identifier}":{"delete":{"tags":["policies"],"description":"Delete a policy by identifier. Returns 409 Conflict if the policy is referenced by policy sets (unless force=true).","operationId":"policies#delete","parameters":[{"name":"force","in":"query","description":"Force deletion even if the policy is referenced by policy sets","allowEmptyValue":true,"schema":{"type":"boolean","description":"Force deletion even if the policy is referenced by policy sets","default":false}},{"name":"accountIdentifier","in":"query","description":"Harness account ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness account ID","default":""}},{"name":"orgIdentifier","in":"query","description":"Harness organization ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness organization ID","default":""}},{"name":"projectIdentifier","in":"query","description":"Harness project ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness project ID","default":""}},{"name":"identifier","in":"path","description":"Identifier of the policy","required":true,"schema":{"type":"string","description":"Identifier of the policy","minLength":1}},{"name":"x-api-key","in":"header","description":"Harness PAT key used to perform authorization","allowEmptyValue":true,"schema":{"type":"string","description":"Harness PAT key used to perform authorization"}}],"responses":{"204":{"description":"No Content response."},"400":{"description":"GitError: Bad Request response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFound: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"PolicyReferenced: Conflict response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyReferencedResult"}}}},"500":{"description":"ScopeInfoError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGateway: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## PATCH /api/v1/policies/{identifier}

> Update a policy by identifier

```json
{"openapi":"3.0.3","info":{"title":"Governance Policy Management API","version":"1.2.0"},"tags":[{"name":"policies","description":"Create, edit and delete Governance policies written in rego"}],"servers":[{"url":"https://app.harness.io/gateway/pm/"}],"security":[{"jwt_header_Authorization":["core_governancePolicy_edit"]},{"api_key_header_x-api-key":[]}],"components":{"securitySchemes":{"jwt_header_Authorization":{"type":"http","scheme":"bearer"},"api_key_header_x-api-key":{"type":"apiKey","description":"Harness PAT","name":"x-api-key","in":"header"}},"schemas":{"UpdateRequestBody":{"type":"object","properties":{"name":{"type":"string","description":"The name of the policy"},"rego":{"type":"string","description":"The rego that defines the policy"}}},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]},"PolicyReferencedResult":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable warning message"},"referenced_by":{"type":"array","items":{"$ref":"#/components/schemas/PolicySetRef"},"description":"Policy sets that reference this policy"}},"description":"Error returned when deleting a policy that is referenced by policy sets","required":["message","referenced_by"]},"PolicySetRef":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID"},"identifier":{"type":"string","description":"Identifier of the referencing policy set"},"name":{"type":"string","description":"Name of the referencing policy set"},"org_id":{"type":"string","description":"Harness organization ID","default":""},"project_id":{"type":"string","description":"Harness project ID","default":""}},"description":"Lightweight reference to a policy set (used in error responses)","required":["identifier","name","account_id"]}}},"paths":{"/api/v1/policies/{identifier}":{"patch":{"tags":["policies"],"description":"Update a policy by identifier","operationId":"policies#update","parameters":[{"name":"git_commit_msg","in":"query","description":"The commit message used in git when creating the policy","allowEmptyValue":true,"schema":{"type":"string","description":"The commit message used in git when creating the policy"}},{"name":"git_is_new_branch","in":"query","description":"A flag to determine if the api should try and commit to a new branch","allowEmptyValue":true,"schema":{"type":"boolean","description":"A flag to determine if the api should try and commit to a new branch"}},{"name":"git_base_branch","in":"query","description":"If committing to a new branch, git_base_branch tells the api which branch to base the new branch from","allowEmptyValue":true,"schema":{"type":"string","description":"If committing to a new branch, git_base_branch tells the api which branch to base the new branch from"}},{"name":"git_branch","in":"query","description":"The git branch the policy resides in","allowEmptyValue":true,"schema":{"type":"string","description":"The git branch the policy resides in"}},{"name":"git_commit_sha","in":"query","description":"The existing commit sha of the file being updated","allowEmptyValue":true,"schema":{"type":"string","description":"The existing commit sha of the file being updated"}},{"name":"git_file_id","in":"query","description":"The existing file id of the file being updated, not required for bitbucket files","allowEmptyValue":true,"schema":{"type":"string","description":"The existing file id of the file being updated, not required for bitbucket files"}},{"name":"accountIdentifier","in":"query","description":"Harness account ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness account ID","default":""}},{"name":"orgIdentifier","in":"query","description":"Harness organization ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness organization ID","default":""}},{"name":"projectIdentifier","in":"query","description":"Harness project ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness project ID","default":""}},{"name":"identifier","in":"path","description":"Identifier of the policy","required":true,"schema":{"type":"string","description":"Identifier of the policy"}},{"name":"x-api-key","in":"header","description":"Harness PAT key used to perform authorization","allowEmptyValue":true,"schema":{"type":"string","description":"Harness PAT key used to perform authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateRequestBody"}}}},"responses":{"204":{"description":"No Content response."},"400":{"description":"GitError: Bad Request response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFound: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"PolicyReferenced: Conflict response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyReferencedResult"}}}},"500":{"description":"ScopeInfoError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGateway: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## GET /api/v1/policies/{identifier}/policysets

> List all policy sets that reference a specific policy

```json
{"openapi":"3.0.3","info":{"title":"Governance Policy Management API","version":"1.2.0"},"tags":[{"name":"policies","description":"Create, edit and delete Governance policies written in rego"}],"servers":[{"url":"https://app.harness.io/gateway/pm/"}],"security":[{"jwt_header_Authorization":["core_governancePolicy_view"]},{"api_key_header_x-api-key":[]}],"components":{"securitySchemes":{"jwt_header_Authorization":{"type":"http","scheme":"bearer"},"api_key_header_x-api-key":{"type":"apiKey","description":"Harness PAT","name":"x-api-key","in":"header"}},"schemas":{"PolicyToPolicySet":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID associated with this policy set","default":""},"action":{"type":"string","description":"Action that triggers the policy set","minLength":1},"created":{"type":"integer","description":"Time the policy set was created","format":"int64"},"enabled":{"type":"boolean","description":"Only enabled policy sets are evaluated when evaluating by type/action"},"identifier":{"type":"string","description":"Identifier of the policy set","minLength":1},"name":{"type":"string","description":"Name of the policy set","minLength":1},"org_id":{"type":"string","description":"Harness organization ID associated with this policy set","default":""},"project_id":{"type":"string","description":"Harness project ID associated with this policy set","default":""},"updated":{"type":"integer","description":"Time the policy set was last updated","format":"int64"}},"required":["identifier","name","action","enabled","created","updated","account_id","org_id","project_id"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]},"PolicyReferencedResult":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable warning message"},"referenced_by":{"type":"array","items":{"$ref":"#/components/schemas/PolicySetRef"},"description":"Policy sets that reference this policy"}},"description":"Error returned when deleting a policy that is referenced by policy sets","required":["message","referenced_by"]},"PolicySetRef":{"type":"object","properties":{"account_id":{"type":"string","description":"Harness account ID"},"identifier":{"type":"string","description":"Identifier of the referencing policy set"},"name":{"type":"string","description":"Name of the referencing policy set"},"org_id":{"type":"string","description":"Harness organization ID","default":""},"project_id":{"type":"string","description":"Harness project ID","default":""}},"description":"Lightweight reference to a policy set (used in error responses)","required":["identifier","name","account_id"]}}},"paths":{"/api/v1/policies/{identifier}/policysets":{"get":{"tags":["policies"],"description":"List all policy sets that reference a specific policy","operationId":"policies#list_policy_sets","parameters":[{"name":"accountIdentifier","in":"query","description":"Harness account ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness account ID","default":""}},{"name":"orgIdentifier","in":"query","description":"Harness organization ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness organization ID","default":""}},{"name":"projectIdentifier","in":"query","description":"Harness project ID","allowEmptyValue":true,"schema":{"type":"string","description":"Harness project ID","default":""}},{"name":"per_page","in":"query","description":"Number of results per page","allowEmptyValue":true,"schema":{"type":"integer","description":"Number of results per page","default":50,"format":"int64","minimum":1,"maximum":100}},{"name":"page","in":"query","description":"Page number (starting from 0)","allowEmptyValue":true,"schema":{"type":"integer","description":"Page number (starting from 0)","default":0,"format":"int64","minimum":0}},{"name":"searchTerm","in":"query","description":"Filter results by partial name match","allowEmptyValue":true,"schema":{"type":"string","description":"Filter results by partial name match","default":""}},{"name":"sort","in":"query","description":"Sort order for results","allowEmptyValue":true,"schema":{"type":"string","description":"Sort order for results","default":"name,ASC","enum":["name,ASC","name,DESC","updated,ASC","updated,DESC"]}},{"name":"identifier","in":"path","description":"Identifier for the policy","required":true,"schema":{"type":"string","description":"Identifier for the policy"}},{"name":"x-api-key","in":"header","description":"Harness PAT key used to perform authorization","allowEmptyValue":true,"schema":{"type":"string","description":"Harness PAT key used to perform authorization"}}],"responses":{"200":{"description":"OK response.","headers":{"Link":{"description":"Link-based paging","schema":{"type":"string","description":"Link-based paging"}},"X-Page-Index":{"description":"Deprecated: Please use pageNumber / X-Page-Number instead. Same value as pageNumber; kept for legacy UI clients.","schema":{"type":"integer","description":"Deprecated: Please use pageNumber / X-Page-Number instead. Same value as pageNumber; kept for legacy UI clients.","format":"int64"}},"X-Page-Item-Count":{"description":"Number of results in this page","schema":{"type":"integer","description":"Number of results in this page","format":"int64"}},"X-Page-Number":{"description":"Current page number (0-based). Harness standard pagination header X-Page-Number.","schema":{"type":"integer","description":"Current page number (0-based). Harness standard pagination header X-Page-Number.","format":"int64"}},"X-Page-Size":{"description":"Requested page size. Harness standard pagination header X-Page-Size.","schema":{"type":"integer","description":"Requested page size. Harness standard pagination header X-Page-Size.","format":"int64"}},"X-Total-Elements":{"description":"Total number of results available. Harness standard pagination header X-Total-Elements.","schema":{"type":"integer","description":"Total number of results available. Harness standard pagination header X-Total-Elements.","format":"int64"}},"X-Total-Items":{"description":"Deprecated: Please use totalElements / X-Total-Elements instead. Same value as totalElements; kept for legacy UI clients.","schema":{"type":"integer","description":"Deprecated: Please use totalElements / X-Total-Elements instead. Same value as totalElements; kept for legacy UI clients.","format":"int64"}},"X-Total-Pages":{"description":"Total pages available","schema":{"type":"integer","description":"Total pages available","format":"int64"}}},"content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PolicyToPolicySet"}}}}},"400":{"description":"GitError: Bad Request response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFound: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"PolicyReferenced: Conflict response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyReferencedResult"}}}},"500":{"description":"ScopeInfoError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGateway: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```
