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

Evaluate

Perform evaluations

post

Evaluate arbitrary rego

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 occaecati repellendus illo consequatur dolores.
Body
inputanyRequired

Input to evaluate

Example: {"message":"everyone"}
regostring · min: 1Required

Arbitrary rego to be evaluated

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

OK response.

application/json
deny_messagesstring[]Required

The values of any deny rego rules as returned by the rego engine

Example: ["deployment stage 'example-stage' does not have a HarnessApproval step","deployment stage 'example-stage' has step 'run-script' that is forbidden type 'ShellScript'"]
errorstringRequired

Any errors returned by the rego engine when this policy was evaluated

Example: policy.rego:25: rego_parse_error: non-terminated string m == "test
outputanyRequired

The output returned by the rego engine when this policy was evaluated

Example: { "deny": [ "deployment stage 'deploy' does not have a HarnessApproval step" ], "stages_with_approval": [] }
policy_severitystring · enumOptional

The severity of the policy that was selected while creating the policyset

Example: Warn & ContinuePossible values:
statusstring · enumRequired

The overall status for this individual policy indicating whether it passed

Example: errorPossible values:
post/api/v1/evaluate
POST /gateway/pm/api/v1/evaluate HTTP/1.1
Host: app.harness.io/
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 117

{
  "input": {
    "message": "everyone"
  },
  "rego": "package test\ndeny[\"should say hello world\"] {input.message != \"world\"}"
}
{
  "deny_messages": [
    "deployment stage 'example-stage' does not have a HarnessApproval step",
    "deployment stage 'example-stage' has step 'run-script' that is forbidden type 'ShellScript'"
  ],
  "error": "policy.rego:25: rego_parse_error: non-terminated string m == \"test",
  "output": "{\n    \"deny\": [\n        \"deployment stage 'deploy' does not have a HarnessApproval step\"\n    ],\n    \"stages_with_approval\": []\n}",
  "policy": {
    "account_id": "eBqAoNchMLKigC_qZ5EdC",
    "cache_response": {
      "cache_state": "STALE_CACHE",
      "is_sync_enabled": true,
      "last_updated_at": 1773917288158,
      "ttl_left": 258234442
    },
    "created": 1636669297674,
    "git_commit_sha": "1369b45c20fc685113adcfd1a08a914180ff3c0d",
    "git_connector_ref": ".",
    "git_default_branch": "main",
    "git_default_branch_commit_sha": "1369b45c20fc685113adcfd1a08a914180ff3c0d",
    "git_default_branch_file_id": "1369b45c20fc685113adcfd1a08a914180ff3c0d",
    "git_default_branch_file_url": "",
    "git_default_branch_update_error": {
      "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]."
    },
    "git_default_branch_updated": 1636669297674,
    "git_file_id": "1369b45c20fc685113adcfd1a08a914180ff3c0d",
    "git_file_url": "",
    "git_path": ".harness/policy.rego",
    "git_repo": "github.com/org/repo,omitempty",
    "identifier": "policy-1",
    "name": "Pipeline Approval",
    "org_id": "test-org",
    "parent_unique_id": "Aperiam quod.",
    "polciy_size_in_bytes": 8751929130004460000,
    "policy_package_name": "Eum qui praesentium.",
    "policy_set_count": 3,
    "project_id": "test-project",
    "rego": "",
    "unique_id": "Ullam quo libero illo officiis id quo.",
    "updated": 1636669297674
  },
  "policy_severity": "Warn & Continue",
  "status": "error"
}

Last updated

Was this helpful?