Get Watches

Xray REST APIs

Products
JFrog Xray
Content Type
REST API
ft:sourceType
Paligo

Description: Gets a list of all watches in the system.

Notes: For Xray version 3.21.2 and above with Projects, a Project Admin with Manage Security Assets privilege can get a list of Watches using this REST API in the scope of a project, by using the additional query parameter projectKey. A Watch can include both Global and Project Policies.

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

Usage: GET /xray/api/v2/watches

Consumes: None

Produces: application/json

Path Parameters: None

Query Parameters:

Name

Type

Required/Optional

Description

projectKey

string

Optional

Project key for retrieval of project watches

Request Body: None

Response Body:

Name

Type

Description

watches

array[WatchObj]

Array of Watch Objects

WatchObj:

Name

Type

Description

general_data

WatchGeneralObj

General information about the watch

project_resources

ProjectResourcesObj

Resources associated with the watch

watch_recipients

array[string]

Email addresses to receive watch notifications

assigned_policies

array[AssignedPolicyObj]

Policies assigned to the watch

create_ticket_enabled

boolean

Indicates whether Jira ticket creation is enabled

ticket_profile

string

Jira profile for ticket generation

ticket_generation

TicketGenerationObj

Ticket generation settings for the watch

WatchGeneralObj:

Name

Type

Description

id

string

Identifier for the watch

name

string

Name of the watch

description

string

Description of the watch

active

boolean

Indicates if the watch is active

project_key

string

Project key associated with the watch

ProjectResourcesObj

Name

Type

Description

resources

array[ResourceObj]

Array of Resource Objects

ResourceObj:

Name

Type

Description

type

string

Type of the resource: repository, build, releaseBundle, releaseBundleV2 , all-repos, all-builds, all-releaseBundles, all-releaseBundlesV2, all-projects

bin_mgr_id

string

Binary manager ID. Omit or set to default.

name

string

Name of the resource

filters

array[FilterObj]

Array of Filter Objects

FilterObj:

Name

Type

Required/Optional

Description

type

string

required

Type of the filter. The acceptable filter type depends on the resource type.

For the resource types repository and all-repos:

  • regex: Regular expression artifact's name filter.

  • path-regex: Regular expression artifact's repo path filter.

  • package-type: artifact’s package type filter.

  • mime-type: artifact’s MIME type filter.

  • property: artifact’s custom property filter.

  • path-ant-patterns: artifact's repository path ant-style pattern filter.

For the resource types all-builds, all-releaseBundles, all-releaseBundlesV2, all-projects:

  • ant-patterns: Ant-style path pattern filter applied to the resource name.

For the resource types repository, build, releaseBundle, releaseBundleV2:

  • None

value

varies

required

Value of the filter, whose type depends on the filter type.

For path-ant-patterns and ant-patterns types:

PatternObj

required

arrays of ant-style include and exclude path patterns.

For regexand path-regextypes:

string

required

A regular expression string.

For package-type type:

string

required

One of the following package types:  Maven, Docker, NuGet, Generic, Npm, Bower, Pypi, Rpm, Debian, RubyGems

For mime-type type:

string

required

A MIME-type string.

For property type:

KeyValueObj

required

A custom property's key-value pair.

PatternObj

Name

Type

Description

IncludePatterns

array[string]

arrays of ant-style include path patterns.

ExcludePatterns

array[string]

arrays of ant-style exclude path patterns.

KeyValueObj:

Name

Type

Description

key

string

The key name of a custom property's key-value pair.

value

string

The value of a custom property's key-value pair.

AssignedPolicyObj:

Name

Type

Description

name

string

Name of the policy

type

string

Type of the policy (e.g., security, license)

TicketGenerationObj:

Name

Type

Description

create_duplicate_tickets

DuplicateTicketCreationObj

Settings for creating duplicate tickets

impact_path_profiles_mapping

array[ImpactPathProfileMappingObj]

Mapping of impact path profiles

DuplicateTicketCreationObj:

Name

Type

Description

by_version

VersionTicketSettingsObj

Settings for creating duplicate tickets by version

VersionTicketSettingsObj:

Name

Type

Description

build

boolean

Indicates whether duplicate tickets are created for builds

package

boolean

Indicates whether duplicate tickets are created for packages

release_bundle

boolean

Indicates whether duplicate tickets are created for release bundles

ImpactPathProfileMappingObj:

Name

Type

Description

include

arrayI[IncludeObj]

Settings for mapping impact paths to JIRA profiles

IncludeObj:

Name

Type

Description

profile

string

Impact path profile

pattern

string

Pattern for the impact path profile

Response Codes

Status code

Description

200

Success - Watches retrieved

500

Failed to get Watches

Example Response

[
  {
    "general_data": {
      "id": "5bbe364b0fe4dc29f64c25aa",
      "name": "specific-build-watch",
      "description": "This is a new watch created using API V2",
      "active": true
    },
    "project_resources": {
      "resources": [
        {
          "type": "build",
          "name": "release-pipeline"
        }
      ]
    },
    "assigned_policies": [
      {
        "name": "critial_issues",
        "type": "security"
      },
      {
        "name": "block_policy",
        "type": "security"
      }
    ]
  },
  {
    "general_data": {
      "id": "6f2s864b0fe4dc29f64r5z9m",
      "name": "all-repositories",
      "description": "This is a new watch created using API V2",
      "active": true
    },
    "project_resources": {
      "resources": [
        {
          "type": "all-repos",
          "filters": [
            {
              "type": "package-type",
              "value": "Docker"
            },
            {
              "type": "package-type",
              "value": "Debian"
            }
          ]
        }
      ]
    },
    "assigned_policies": [
      {
        "name": "critial_issues",
        "type": "security"
      }
    ]
  },
  {
    "general_data": {
      "id": "56sdf564b0fe4dc29f64cdfs564",
      "name": "vuln-prod",
      "description": "This is a new watch created using API V2",
      "active": true
    },
    "project_resources": {
      "resources": [
        {
          "type": "repository",
          "name": "libs-release-local",
          "filters": [
            {
              "type": "regex",
              "value": ".*"
            }
          ]
        }
      ]
    },
    "assigned_policies": [
      {
        "name": "medium_policy",
        "type": "security"
      }
    ],
    "create_ticket_enabled": true,
    "ticket_profile": "Profile-example",
    "ticket_generation": {
      "create_duplicate_tickets": {
        "by_version": {
          "build": false,
          "package": false,
          "release_bundle": false
        }
      },
      "impact_path_profiles_mapping": {
        "include": [
          {
            "profile": "Profile-exampleA",
            "pattern": "**a*"
          },
          {
            "profile": "Profile-exampleB",
            "pattern": "**b*"
          }
        ]
      }
    }
  }
]

Example Response - Get Watches in the Project scope

GET /xray/api/v2/watches?projectKey=myproj
[
    {
        "general_data": {
            "id": "5bbe364b0fe4dc29f64c25aa",
            "name": "specific-build-watch",
            "description": "This is a new watch created using API V2",
            "active": true,
            "project_key": "myproj"
        },
        "project_resources": {
            "resources": [
                {
                    "type": "build",
                    "name": "release-pipeline"
                }
            ]
        },
        "assigned_policies": [
            {
                "name": "critial_issues",
                "type": "security"
            },
            {
                "name": "block_policy",
                "type": "security"
            }
        ],
    "ticket_generation": {
      "create_duplicate_tickets": {
        "by_version": {
          "build": false,
          "package": false,
          "release_bundle": false
        }
      },
      "impact_path_profiles_mapping": {}
    }
  }
]