Create Policy

Xray REST APIs

Products
JFrog Xray
Content Type
REST API
ft:sourceType
Paligo

Description: Creates a new policy.

Security: Requires the "Manage Policies" role to be set on the User or Group level.

Usage: POST /policies

Consumes: application/json

Produces : application/json

-- Example 1
{
  "name": "securityPolicy",
  "type": "security",
  "description": "some description",
  "rules": [
    {
      "name": "securityRule",
      "priority": 1,
      "criteria": {
        "min_severity": "High"
      },
      "actions": {
        "mails": [
          "mail1@example.com",
          "mail2@example.com"
        ],
        "fail_build": true,
        "block_download": {
          "unscanned": true,
          "active": true
        }
      }
    }
  ]
}

-- Example 2

{
  "name": "licensesPolicy",
  "type": "license",
  "description": "some description",
  "rules": [
    {
      "name": "LicenseRule",
      "priority": 1,
      "criteria": {
        "allowed_licenses": [
          "0BSD",
          "AAL"
        ],
        "allow_unknown": true
      }
    }
  ]
}
-- Example 3
{
  "name": "securityPolicy",
  "type": "security",
  "description": "some description",
  "rules": [
       {
         "name": "SLA_ rule",
          "criteria": { … },
          "actions": {
          "webhooks": [],
          "mails": [],
          "block_download": { … },
          "block_release_bundle_distribution": false,
          "block_release_bundle_promotion": true,
          "notify_watch_recipients": false,
          "notify_deployer": true
          "fail_build": true,
          "build_failure_grace_period_in_days": 5
        }
      }
    }
  ]
}