Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Policies

Create, edit and delete Governance policies written in rego

get

List all policies

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
accountIdentifierstringOptional

Harness account ID

Default: ""Example: eBqAoNchMLKigC_qZ5EdC
orgIdentifierstringOptional

Harness organization ID

Default: ""Example: test-org
projectIdentifierstringOptional

Harness project ID

Default: ""Example: test-project
per_pageinteger · int64 · min: 1 · max: 100Optional

Number of results per page

Default: 50Example: 20
pageinteger · int64Optional

Page number (starting from 0)

Default: 0Example: 4
identifierFilterstringOptional

Comma separated List of Identifiers to filter on

Default: ""Example: test-projectId1, test-projectId2
searchTermstringOptional

Filter results by partial name match

Default: ""Example: poli
sortstring · enumOptional

Sort order for results

Default: name,ASCExample: name,ASCPossible values:
excludeRegoFromResponsebooleanOptional

Set to true to exclude Rego content from the response

Default: falseExample: false
includePolicySetCountbooleanOptional

Set to true to include the count of policy sets associated with each policy in the response

Default: falseExample: true
Header parameters
x-api-keystringOptional

Harness PAT key used to perform authorization

Example: Corporis praesentium praesentium magnam.
Responses
400

GitError: Bad Request response.

application/json
faultbooleanRequired

Is the error a server-side fault?

Example: true
idstringRequired

ID is a unique identifier for this particular occurrence of the problem.

Example: 123abc
messagestringRequired

Message is a human-readable explanation specific to this occurrence of the problem.

Example: parameter 'p' must be an integer
namestringRequired

Name is the name of this class of errors.

Example: bad_request
temporarybooleanRequired

Is the error temporary?

Example: false
timeoutbooleanRequired

Is the error a timeout?

Example: true
get/api/v1/policies
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]."
}
post

Create a policy

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
accountIdentifierstringOptional

Harness account ID

Default: ""Example: eBqAoNchMLKigC_qZ5EdC
orgIdentifierstringOptional

Harness organization ID

Default: ""Example: test-org
projectIdentifierstringOptional

Harness project ID

Default: ""Example: test-project
git_commit_msgstringOptional

The commit message used in git when creating the policy

Example: harness policy commit msg
git_importbooleanOptional

A flag to determine if the api should try and import and existing policy from git

Example: true
git_branchstringOptional

The git branch the policy will be created in

Example: main
git_is_new_branchbooleanOptional

A flag to determine if the api should try and commit to a new branch

Example: true
git_base_branchstringOptional

If committing to a new branch, git_base_branch tells the api which branch to base the new branch from

Example: main
Header parameters
x-api-keystringOptional

Harness PAT key used to perform authorization

Example: Aut doloribus alias labore.
Body
git_connector_refstringOptional

The harness connector used for authenticating on the git provider

Example: .
git_pathstringOptional

The path to the file in the git repo

Example: .harness/policy.rego
git_repostringOptional

The git repo the policy resides in

Example: github.com/org/repo
identifierstring · min: 1Required

Identifier for the policy

Example: policy-1
namestring · min: 1Required

Name of the policy

Example: Check that an approval step is present
regostringOptional

Rego that defines the policy

Example: package test deny["should say hello world"] {input.message != "world"}
Responses
400

GitError: Bad Request response.

application/json
faultbooleanRequired

Is the error a server-side fault?

Example: true
idstringRequired

ID is a unique identifier for this particular occurrence of the problem.

Example: 123abc
messagestringRequired

Message is a human-readable explanation specific to this occurrence of the problem.

Example: parameter 'p' must be an integer
namestringRequired

Name is the name of this class of errors.

Example: bad_request
temporarybooleanRequired

Is the error temporary?

Example: false
timeoutbooleanRequired

Is the error a timeout?

Example: true
post/api/v1/policies
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]."
}

Dry run policy evaluation

post

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.

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
accountIdentifierstringOptional

Harness account ID

Default: ""Example: eBqAoNchMLKigC_qZ5EdC
orgIdentifierstringOptional

Harness organization ID

Default: ""Example: test-org
projectIdentifierstringOptional

Harness project ID

Default: ""Example: test-project
Header parameters
x-api-keystringOptional

Harness PAT key used to perform authorization

Example: Aut consequatur nemo perferendis earum.
Body
actionstringOptional

Optional action filter (e.g. onrun, onsave). Restricts history replay to evaluations with this action.

Example: onrun
entityOrgIdentifierstringOptional

Optional analysis org. Must stay within the policy scope hierarchy. Omit at account-level policy to replay account-wide.

Example: default
entityProjectIdentifierstringOptional

Optional analysis project. Omit at org-level policy to replay all projects in the org. Requires entityOrgIdentifier when the policy is account-level.

Example: project_alpha
identifierstringOptional

Policy identifier for edit mode. Used for RBAC and existence check only. Returns 404 if not found.

Example: my-pipeline-policy
regostringRequired

Rego source to evaluate. Always required — UI sends the current editor content (inline or GitX-loaded) on both create and edit.

Example: package policy deny["must approve"] { input.status != "approved" }
typestringRequired

Entity type to evaluate against (e.g. pipeline, featureFlag). Required.

Example: pipeline
Responses
400

GitError: Bad Request response.

application/json
faultbooleanRequired

Is the error a server-side fault?

Example: true
idstringRequired

ID is a unique identifier for this particular occurrence of the problem.

Example: 123abc
messagestringRequired

Message is a human-readable explanation specific to this occurrence of the problem.

Example: parameter 'p' must be an integer
namestringRequired

Name is the name of this class of errors.

Example: bad_request
temporarybooleanRequired

Is the error temporary?

Example: false
timeoutbooleanRequired

Is the error a timeout?

Example: true
post/api/v1/policies/dry-run
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]."
}
post

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

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
identifierstring · min: 1Required

Identifier of the policy to move

Example: policy-1
Query parameters
accountIdentifierstringOptional

Harness account ID

Default: ""Example: eBqAoNchMLKigC_qZ5EdC
orgIdentifierstringOptional

Harness organization ID

Default: ""Example: test-org
projectIdentifierstringOptional

Harness project ID

Default: ""Example: test-project
Header parameters
x-api-keystringOptional

Harness PAT key used to perform authorization

Example: Et sit voluptas.
Body
git_base_branchstringOptional

If committing to a new branch, git_base_branch tells the api which branch to base the new branch from

Example: main
git_branchstringRequired

The git branch to commit the policy to

Example: main
git_commit_msgstringRequired

The commit message used in git when moving the policy

Example: Move policy to remote
git_connector_refstringOptional

The harness connector used for authenticating on the git provider

Example: github_connector
git_is_new_branchbooleanOptional

A flag to determine if the api should try and commit to a new branch

Example: false
git_pathstringRequired

The path to the file in the git repo

Example: .harness/policy.rego
git_repostringRequired

The git repo to store the policy in

Example: github.com/org/repo
Responses
400

GitError: Bad Request response.

application/json
faultbooleanRequired

Is the error a server-side fault?

Example: true
idstringRequired

ID is a unique identifier for this particular occurrence of the problem.

Example: 123abc
messagestringRequired

Message is a human-readable explanation specific to this occurrence of the problem.

Example: parameter 'p' must be an integer
namestringRequired

Name is the name of this class of errors.

Example: bad_request
temporarybooleanRequired

Is the error temporary?

Example: false
timeoutbooleanRequired

Is the error a timeout?

Example: true
post/api/v1/policies/move-policy/{identifier}
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]."
}
get

Find a policy by identifier

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
identifierstring · min: 1Required

Identifier of the policy to retrieve

Example: policy-1
Query parameters
accountIdentifierstringOptional

Harness account ID

Default: ""Example: eBqAoNchMLKigC_qZ5EdC
orgIdentifierstringOptional

Harness organization ID

Default: ""Example: test-org
projectIdentifierstringOptional

Harness project ID

Default: ""Example: test-project
git_branchstringOptional

The git branch the policy resides in

Example: main
show_summarybooleanOptional

Setting 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.

Example: true
Header parameters
x-api-keystringOptional

Harness PAT key used to perform authorization

Example: Quia eum beatae maxime.
Responses
400

GitError: Bad Request response.

application/json
faultbooleanRequired

Is the error a server-side fault?

Example: true
idstringRequired

ID is a unique identifier for this particular occurrence of the problem.

Example: 123abc
messagestringRequired

Message is a human-readable explanation specific to this occurrence of the problem.

Example: parameter 'p' must be an integer
namestringRequired

Name is the name of this class of errors.

Example: bad_request
temporarybooleanRequired

Is the error temporary?

Example: false
timeoutbooleanRequired

Is the error a timeout?

Example: true
get/api/v1/policies/{identifier}
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

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

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
identifierstring · min: 1Required

Identifier of the policy

Example: policy-1
Query parameters
forcebooleanOptional

Force deletion even if the policy is referenced by policy sets

Default: falseExample: false
accountIdentifierstringOptional

Harness account ID

Default: ""Example: eBqAoNchMLKigC_qZ5EdC
orgIdentifierstringOptional

Harness organization ID

Default: ""Example: test-org
projectIdentifierstringOptional

Harness project ID

Default: ""Example: test-project
Header parameters
x-api-keystringOptional

Harness PAT key used to perform authorization

Example: Molestiae voluptate.
Responses
400

GitError: Bad Request response.

application/json
faultbooleanRequired

Is the error a server-side fault?

Example: true
idstringRequired

ID is a unique identifier for this particular occurrence of the problem.

Example: 123abc
messagestringRequired

Message is a human-readable explanation specific to this occurrence of the problem.

Example: parameter 'p' must be an integer
namestringRequired

Name is the name of this class of errors.

Example: bad_request
temporarybooleanRequired

Is the error temporary?

Example: false
timeoutbooleanRequired

Is the error a timeout?

Example: true
delete/api/v1/policies/{identifier}
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]."
}
patch

Update a policy by identifier

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
identifierstringRequired

Identifier of the policy

Example: policy-1
Query parameters
git_commit_msgstringOptional

The commit message used in git when creating the policy

Example: harness policy commit msg
git_is_new_branchbooleanOptional

A flag to determine if the api should try and commit to a new branch

Example: true
git_base_branchstringOptional

If committing to a new branch, git_base_branch tells the api which branch to base the new branch from

Example: main
git_branchstringOptional

The git branch the policy resides in

Example: main
git_commit_shastringOptional

The existing commit sha of the file being updated

Example: 1369b45c20fc685113adcfd1a08a914180ff3c0d
git_file_idstringOptional

The existing file id of the file being updated, not required for bitbucket files

Example: 1369b45c20fc685113adcfd1a08a914180ff3c0d
accountIdentifierstringOptional

Harness account ID

Default: ""Example: eBqAoNchMLKigC_qZ5EdC
orgIdentifierstringOptional

Harness organization ID

Default: ""Example: test-org
projectIdentifierstringOptional

Harness project ID

Default: ""Example: test-project
Header parameters
x-api-keystringOptional

Harness PAT key used to perform authorization

Example: Impedit corporis.
Body
namestringOptional

The name of the policy

Example: Check that an approval step is present
regostringOptional

The rego that defines the policy

Example: package test deny["should say hello world"] {input.message != "world"}
Responses
400

GitError: Bad Request response.

application/json
faultbooleanRequired

Is the error a server-side fault?

Example: true
idstringRequired

ID is a unique identifier for this particular occurrence of the problem.

Example: 123abc
messagestringRequired

Message is a human-readable explanation specific to this occurrence of the problem.

Example: parameter 'p' must be an integer
namestringRequired

Name is the name of this class of errors.

Example: bad_request
temporarybooleanRequired

Is the error temporary?

Example: false
timeoutbooleanRequired

Is the error a timeout?

Example: true
patch/api/v1/policies/{identifier}
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]."
}
get

List all policy sets that reference a specific policy

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
identifierstringRequired

Identifier for the policy

Example: policy-1
Query parameters
accountIdentifierstringOptional

Harness account ID

Default: ""Example: eBqAoNchMLKigC_qZ5EdC
orgIdentifierstringOptional

Harness organization ID

Default: ""Example: test-org
projectIdentifierstringOptional

Harness project ID

Default: ""Example: test-project
per_pageinteger · int64 · min: 1 · max: 100Optional

Number of results per page

Default: 50Example: 20
pageinteger · int64Optional

Page number (starting from 0)

Default: 0Example: 4
searchTermstringOptional

Filter results by partial name match

Default: ""Example: poli
sortstring · enumOptional

Sort order for results

Default: name,ASCExample: updated,ASCPossible values:
Header parameters
x-api-keystringOptional

Harness PAT key used to perform authorization

Example: Omnis tempore delectus vero aliquid.
Responses
400

GitError: Bad Request response.

application/json
faultbooleanRequired

Is the error a server-side fault?

Example: true
idstringRequired

ID is a unique identifier for this particular occurrence of the problem.

Example: 123abc
messagestringRequired

Message is a human-readable explanation specific to this occurrence of the problem.

Example: parameter 'p' must be an integer
namestringRequired

Name is the name of this class of errors.

Example: bad_request
temporarybooleanRequired

Is the error temporary?

Example: false
timeoutbooleanRequired

Is the error a timeout?

Example: true
get/api/v1/policies/{identifier}/policysets
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?