Policies
Create, edit and delete Governance policies written in rego
List all policies
Harness account ID
""Example: eBqAoNchMLKigC_qZ5EdCHarness organization ID
""Example: test-orgHarness project ID
""Example: test-projectNumber of results per page
50Example: 20Page number (starting from 0)
0Example: 4Comma separated List of Identifiers to filter on
""Example: test-projectId1, test-projectId2Filter results by partial name match
""Example: poliSort order for results
name,ASCExample: name,ASCPossible values: Set to true to exclude Rego content from the response
falseExample: falseSet to true to include the count of policy sets associated with each policy in the response
falseExample: trueHarness PAT key used to perform authorization
Corporis praesentium praesentium magnam.OK response.
GitError: Bad Request response.
Is the error a server-side fault?
trueID is a unique identifier for this particular occurrence of the problem.
123abcMessage is a human-readable explanation specific to this occurrence of the problem.
parameter 'p' must be an integerName is the name of this class of errors.
bad_requestIs the error temporary?
falseIs the error a timeout?
trueUnauthorized: Unauthorized response.
Forbidden: Forbidden response.
NotFound: Not Found response.
PolicyReferenced: Conflict response.
ScopeInfoError: Internal Server Error response.
BadGateway: Bad Gateway response.
GET /gateway/pm/api/v1/policies HTTP/1.1
Host: app.harness.io/
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"explanation": "File with given filepath [file.rego] already exists in Github, thus couldn't create a new file",
"hint": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main].",
"message": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main]."
}Create a policy
Harness account ID
""Example: eBqAoNchMLKigC_qZ5EdCHarness organization ID
""Example: test-orgHarness project ID
""Example: test-projectThe commit message used in git when creating the policy
harness policy commit msgA flag to determine if the api should try and import and existing policy from git
trueThe git branch the policy will be created in
mainA flag to determine if the api should try and commit to a new branch
trueIf committing to a new branch, git_base_branch tells the api which branch to base the new branch from
mainHarness PAT key used to perform authorization
Aut doloribus alias labore.The harness connector used for authenticating on the git provider
.The path to the file in the git repo
.harness/policy.regoThe git repo the policy resides in
github.com/org/repoIdentifier for the policy
policy-1Name of the policy
Check that an approval step is presentRego that defines the policy
package test deny["should say hello world"] {input.message != "world"}Created response.
GitError: Bad Request response.
Is the error a server-side fault?
trueID is a unique identifier for this particular occurrence of the problem.
123abcMessage is a human-readable explanation specific to this occurrence of the problem.
parameter 'p' must be an integerName is the name of this class of errors.
bad_requestIs the error temporary?
falseIs the error a timeout?
trueUnauthorized: Unauthorized response.
Forbidden: Forbidden response.
NotFound: Not Found response.
PolicyReferenced: Conflict response.
ScopeInfoError: Internal Server Error response.
BadGateway: Bad Gateway response.
POST /gateway/pm/api/v1/policies HTTP/1.1
Host: app.harness.io/
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 249
{
"git_connector_ref": ".",
"git_path": ".harness/policy.rego",
"git_repo": "github.com/org/repo",
"identifier": "policy-1",
"name": "Check that an approval step is present",
"rego": "package test\ndeny[\"should say hello world\"] {input.message != \"world\"}"
}{
"explanation": "File with given filepath [file.rego] already exists in Github, thus couldn't create a new file",
"hint": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main].",
"message": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main]."
}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.
Harness account ID
""Example: eBqAoNchMLKigC_qZ5EdCHarness organization ID
""Example: test-orgHarness project ID
""Example: test-projectHarness PAT key used to perform authorization
Aut consequatur nemo perferendis earum.Optional action filter (e.g. onrun, onsave). Restricts history replay to evaluations with this action.
onrunOptional analysis org. Must stay within the policy scope hierarchy. Omit at account-level policy to replay account-wide.
defaultOptional analysis project. Omit at org-level policy to replay all projects in the org. Requires entityOrgIdentifier when the policy is account-level.
project_alphaPolicy identifier for edit mode. Used for RBAC and existence check only. Returns 404 if not found.
my-pipeline-policyRego source to evaluate. Always required — UI sends the current editor content (inline or GitX-loaded) on both create and edit.
package policy deny["must approve"] { input.status != "approved" }Entity type to evaluate against (e.g. pipeline, featureFlag). Required.
pipelineOK response.
GitError: Bad Request response.
Is the error a server-side fault?
trueID is a unique identifier for this particular occurrence of the problem.
123abcMessage is a human-readable explanation specific to this occurrence of the problem.
parameter 'p' must be an integerName is the name of this class of errors.
bad_requestIs the error temporary?
falseIs the error a timeout?
trueUnauthorized: Unauthorized response.
Forbidden: Forbidden response.
NotFound: Not Found response.
PolicyReferenced: Conflict response.
ScopeInfoError: Internal Server Error response.
BadGateway: Bad Gateway response.
POST /gateway/pm/api/v1/policies/dry-run HTTP/1.1
Host: app.harness.io/
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 225
{
"action": "onrun",
"entityOrgIdentifier": "default",
"entityProjectIdentifier": "project_alpha",
"identifier": "my-pipeline-policy",
"rego": "package policy\ndeny[\"must approve\"] { input.status != \"approved\" }",
"type": "pipeline"
}{
"explanation": "File with given filepath [file.rego] already exists in Github, thus couldn't create a new file",
"hint": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main].",
"message": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main]."
}Move an inline policy's configuration to remote (Git)
Identifier of the policy to move
policy-1Harness account ID
""Example: eBqAoNchMLKigC_qZ5EdCHarness organization ID
""Example: test-orgHarness project ID
""Example: test-projectHarness PAT key used to perform authorization
Et sit voluptas.If committing to a new branch, git_base_branch tells the api which branch to base the new branch from
mainThe git branch to commit the policy to
mainThe commit message used in git when moving the policy
Move policy to remoteThe harness connector used for authenticating on the git provider
github_connectorA flag to determine if the api should try and commit to a new branch
falseThe path to the file in the git repo
.harness/policy.regoThe git repo to store the policy in
github.com/org/repoOK response.
GitError: Bad Request response.
Is the error a server-side fault?
trueID is a unique identifier for this particular occurrence of the problem.
123abcMessage is a human-readable explanation specific to this occurrence of the problem.
parameter 'p' must be an integerName is the name of this class of errors.
bad_requestIs the error temporary?
falseIs the error a timeout?
trueUnauthorized: Unauthorized response.
Forbidden: Forbidden response.
NotFound: Not Found response.
PolicyReferenced: Conflict response.
ScopeInfoError: Internal Server Error response.
BadGateway: Bad Gateway response.
POST /gateway/pm/api/v1/policies/move-policy/{identifier} HTTP/1.1
Host: app.harness.io/
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 219
{
"git_base_branch": "main",
"git_branch": "main",
"git_commit_msg": "Move policy to remote",
"git_connector_ref": "github_connector",
"git_is_new_branch": false,
"git_path": ".harness/policy.rego",
"git_repo": "github.com/org/repo"
}{
"explanation": "File with given filepath [file.rego] already exists in Github, thus couldn't create a new file",
"hint": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main].",
"message": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main]."
}Find a policy by identifier
Identifier of the policy to retrieve
policy-1Harness account ID
""Example: eBqAoNchMLKigC_qZ5EdCHarness organization ID
""Example: test-orgHarness project ID
""Example: test-projectThe git branch the policy resides in
mainSetting to true returns the metadata about the requested policy including the information held about the status of this policy in the default branch. git_branch is ignored as no git operation takes place.
trueHarness PAT key used to perform authorization
Quia eum beatae maxime.OK response.
GitError: Bad Request response.
Is the error a server-side fault?
trueID is a unique identifier for this particular occurrence of the problem.
123abcMessage is a human-readable explanation specific to this occurrence of the problem.
parameter 'p' must be an integerName is the name of this class of errors.
bad_requestIs the error temporary?
falseIs the error a timeout?
trueUnauthorized: Unauthorized response.
Forbidden: Forbidden response.
NotFound: Not Found response.
PolicyReferenced: Conflict response.
ScopeInfoError: Internal Server Error response.
BadGateway: Bad Gateway response.
GET /gateway/pm/api/v1/policies/{identifier} HTTP/1.1
Host: app.harness.io/
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"explanation": "File with given filepath [file.rego] already exists in Github, thus couldn't create a new file",
"hint": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main].",
"message": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main]."
}Delete a policy by identifier. Returns 409 Conflict if the policy is referenced by policy sets (unless force=true).
Identifier of the policy
policy-1Force deletion even if the policy is referenced by policy sets
falseExample: falseHarness account ID
""Example: eBqAoNchMLKigC_qZ5EdCHarness organization ID
""Example: test-orgHarness project ID
""Example: test-projectHarness PAT key used to perform authorization
Molestiae voluptate.No Content response.
GitError: Bad Request response.
Is the error a server-side fault?
trueID is a unique identifier for this particular occurrence of the problem.
123abcMessage is a human-readable explanation specific to this occurrence of the problem.
parameter 'p' must be an integerName is the name of this class of errors.
bad_requestIs the error temporary?
falseIs the error a timeout?
trueUnauthorized: Unauthorized response.
Forbidden: Forbidden response.
NotFound: Not Found response.
PolicyReferenced: Conflict response.
ScopeInfoError: Internal Server Error response.
BadGateway: Bad Gateway response.
DELETE /gateway/pm/api/v1/policies/{identifier} HTTP/1.1
Host: app.harness.io/
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"explanation": "File with given filepath [file.rego] already exists in Github, thus couldn't create a new file",
"hint": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main].",
"message": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main]."
}Update a policy by identifier
Identifier of the policy
policy-1The commit message used in git when creating the policy
harness policy commit msgA flag to determine if the api should try and commit to a new branch
trueIf committing to a new branch, git_base_branch tells the api which branch to base the new branch from
mainThe git branch the policy resides in
mainThe existing commit sha of the file being updated
1369b45c20fc685113adcfd1a08a914180ff3c0dThe existing file id of the file being updated, not required for bitbucket files
1369b45c20fc685113adcfd1a08a914180ff3c0dHarness account ID
""Example: eBqAoNchMLKigC_qZ5EdCHarness organization ID
""Example: test-orgHarness project ID
""Example: test-projectHarness PAT key used to perform authorization
Impedit corporis.The name of the policy
Check that an approval step is presentThe rego that defines the policy
package test deny["should say hello world"] {input.message != "world"}No Content response.
GitError: Bad Request response.
Is the error a server-side fault?
trueID is a unique identifier for this particular occurrence of the problem.
123abcMessage is a human-readable explanation specific to this occurrence of the problem.
parameter 'p' must be an integerName is the name of this class of errors.
bad_requestIs the error temporary?
falseIs the error a timeout?
trueUnauthorized: Unauthorized response.
Forbidden: Forbidden response.
NotFound: Not Found response.
PolicyReferenced: Conflict response.
ScopeInfoError: Internal Server Error response.
BadGateway: Bad Gateway response.
PATCH /gateway/pm/api/v1/policies/{identifier} HTTP/1.1
Host: app.harness.io/
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 134
{
"name": "Check that an approval step is present",
"rego": "package test\ndeny[\"should say hello world\"] {input.message != \"world\"}"
}{
"explanation": "File with given filepath [file.rego] already exists in Github, thus couldn't create a new file",
"hint": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main].",
"message": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main]."
}List all policy sets that reference a specific policy
Identifier for the policy
policy-1Harness account ID
""Example: eBqAoNchMLKigC_qZ5EdCHarness organization ID
""Example: test-orgHarness project ID
""Example: test-projectNumber of results per page
50Example: 20Page number (starting from 0)
0Example: 4Filter results by partial name match
""Example: poliSort order for results
name,ASCExample: updated,ASCPossible values: Harness PAT key used to perform authorization
Omnis tempore delectus vero aliquid.OK response.
GitError: Bad Request response.
Is the error a server-side fault?
trueID is a unique identifier for this particular occurrence of the problem.
123abcMessage is a human-readable explanation specific to this occurrence of the problem.
parameter 'p' must be an integerName is the name of this class of errors.
bad_requestIs the error temporary?
falseIs the error a timeout?
trueUnauthorized: Unauthorized response.
Forbidden: Forbidden response.
NotFound: Not Found response.
PolicyReferenced: Conflict response.
ScopeInfoError: Internal Server Error response.
BadGateway: Bad Gateway response.
GET /gateway/pm/api/v1/policies/{identifier}/policysets HTTP/1.1
Host: app.harness.io/
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"explanation": "File with given filepath [file.rego] already exists in Github, thus couldn't create a new file",
"hint": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main].",
"message": "Please check if there's already a file [file.rego] in Github repository [rego-demo] for the given filepath and branch [main]."
}Last updated
Was this helpful?