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

API Version: v2

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

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. You can not update the project_key parameter.

Usage: GET api/v2/watches

Produces: application/json

Sample Response:

GET api/v2/watches

[
    {
        "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",
                    "bin_mgr_id": "art-prod-eu",
                    "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",
                    "bin_mgr_id": "art-prod-eu",
                    "name": "libs-release-local",
                    "filters": [
                        {
                            "type": "regex",
                            "value": ".*"
                        }
                    ]
                }
            ]
        },
        "assigned_policies": [
            {
                "name": "medium_policy",
                "type": "security"
            }
        ]
    }
]

Get Watches in Projects

GET api/v2/watches?projectKey=<project_key>
[
    {
        "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",
                    "bin_mgr_id": "art-prod-eu",
                    "name": "release-pipeline"
                }
            ]
        },
        "assigned_policies": [
            {
                "name": "critial_issues",
                "type": "security"
            },
            {
                "name": "block_policy",
                "type": "security"
            }
        ]
    }
]

Response Codes:200: Success - Watches retrieved

500: Failed to get Watch