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 |
---|---|---|---|
| string | Optional | Project key for retrieval of project watches |
Request Body: None
Response Body:
Name | Type | Description |
---|---|---|
| array[WatchObj] | Array of Watch Objects |
WatchObj:
Name | Type | Description |
---|---|---|
| General information about the watch | |
| Resources associated with the watch | |
| array[string] | Email addresses to receive watch notifications |
| array[AssignedPolicyObj] | Policies assigned to the watch |
| boolean | Indicates whether Jira ticket creation is enabled |
| string | Jira profile for ticket generation |
| Ticket generation settings for the watch |
WatchGeneralObj:
Name | Type | Description |
---|---|---|
| string | Identifier for the watch |
| string | Name of the watch |
| string | Description of the watch |
| boolean | Indicates if the watch is active |
| string | Project key associated with the watch |
ProjectResourcesObj
Name | Type | Description |
---|---|---|
| array[ResourceObj] | Array of Resource Objects |
ResourceObj:
Name | Type | Description |
---|---|---|
| string | Type of the resource: |
| string | Binary manager ID. Omit or set to default. |
| string | Name of the resource |
| array[FilterObj] | Array of Filter Objects |
FilterObj:
Name | Type | Required/Optional | Description |
---|---|---|---|
| string | required | Type of the filter. The acceptable filter type depends on the resource type. For the resource types repository and all-repos:
For the resource types all-builds,
For the resource types
|
| varies | required | Value of the filter, whose type depends on the filter type. |
For | |||
required | arrays of ant-style include and exclude path patterns. | ||
For | |||
string | required | A regular expression string. | |
For | |||
string | required | One of the following package types: | |
For | |||
string | required | A MIME-type string. | |
For | |||
required | A custom property's key-value pair. |
PatternObj
Name | Type | Description |
---|---|---|
| array[string] | arrays of ant-style include path patterns. |
| array[string] | arrays of ant-style exclude path patterns. |
KeyValueObj:
Name | Type | Description |
---|---|---|
| string | The key name of a custom property's key-value pair. |
| string | The value of a custom property's key-value pair. |
AssignedPolicyObj:
Name | Type | Description |
---|---|---|
| string | Name of the policy |
| string | Type of the policy (e.g., security, license) |
TicketGenerationObj:
Name | Type | Description |
---|---|---|
| Settings for creating duplicate tickets | |
| array[ImpactPathProfileMappingObj] | Mapping of impact path profiles |
DuplicateTicketCreationObj:
Name | Type | Description |
---|---|---|
| Settings for creating duplicate tickets by version |
VersionTicketSettingsObj:
Name | Type | Description |
---|---|---|
| boolean | Indicates whether duplicate tickets are created for builds |
| boolean | Indicates whether duplicate tickets are created for packages |
| boolean | Indicates whether duplicate tickets are created for release bundles |
ImpactPathProfileMappingObj:
Name | Type | Description |
---|---|---|
| arrayI[IncludeObj] | Settings for mapping impact paths to JIRA profiles |
IncludeObj:
Name | Type | Description |
---|---|---|
| string | Impact path profile |
| 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": {} } } ]