> 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.md).

# Governance

Manage Open Policy Agent (OPA) policies, policy sets, and evaluations with the Harness Governance API.

The Governance API manages policy as code in Harness. Policies are written in Rego, the Open Policy Agent (OPA) language, and Harness evaluates them when someone saves or runs a resource.

## Request basics

* **API key token**: Send it in the `x-api-key` header on every request. Go to [Manage API keys](https://developer.harness.io/harness-platform/use-harness-platform/automation/api/add-and-manage-api-keys) to create a key and token.
* **Account, organization, and project IDs**: Send `accountIdentifier` as a query parameter. Add `orgIdentifier` and `projectIdentifier` for policies and policy sets at those levels. Go to [Organizations and projects](https://developer.harness.io/harness-platform/use-harness-platform/organizations-and-projects) to find these identifiers.
* **Base URL**: Send requests to `https://app.harness.io/gateway/pm`, followed by the endpoint path.

## Example request

List the policies in a project:

```bash
curl "https://app.harness.io/gateway/pm/api/v1/policies?accountIdentifier=ACCOUNT_ID&orgIdentifier=ORG_ID&projectIdentifier=PROJECT_ID" \
  -H "x-api-key: $HARNESS_API_KEY"
```

Replace `ACCOUNT_ID`, `ORG_ID`, and `PROJECT_ID` with your own values, and set `HARNESS_API_KEY` to your API key token.

## Find an endpoint

Endpoint paths are relative to the base URL.

* **Policies**: Rules written in Rego, such as "every pipeline must include an approval stage". List policies with `GET /api/v1/policies`, create one with `POST /api/v1/policies`, and test one against sample input with `POST /api/v1/policies/dry-run`. Go to [Harness Policy As Code overview](https://developer.harness.io/harness-platform/use-harness-platform/governance/policy-as-code/harness-governance-overview) to write your first policy.
* **Policy sets**: Groups of policies tied to an entity type and an event, such as pipelines on save, with a warn or error action. List policy sets with `GET /api/v1/policysets` and create one with `POST /api/v1/policysets`. Go to [Enable/Disable a policy set](https://developer.harness.io/harness-platform/use-harness-platform/governance/policy-as-code/disable-a-policy-set) to enable or disable a policy set.
* **Evaluations**: The recorded result each time Harness checks a resource against a policy set. List evaluations with `GET /api/v1/evaluations` and read one with `GET /api/v1/evaluations/{id}`. Go to [Policy evaluations retention](https://developer.harness.io/harness-platform/use-harness-platform/governance/policy-as-code/opa-evaluations-retention) to understand how long evaluations are kept.
* **Policy packs**: Built-in sets of policies for common compliance standards. List the available packs with `GET /api/v1/policy-packs`.
