Policy types

Last Update: 12/5/2016

api-version = 2.0-preview.1

This API in preview. Learn more

If you haven't already, look at the information on getting started with these APIs.

Get a list of policy types

GET https://{instance}/defaultcollection/{project}/_apis/policy/types?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string The name or ID of the team project.
Query
api-version string Version of the API to use.

Sample request

GET https://fabrikam.visualstudio.com/DefaultCollection/fabrikam-fiber-git/_apis/policy/types?api-version=2.0-preview

Sample response

Status code: 200
{
  "count": 4,
  "value": [
    {
      "description": "This policy will require a successful build has been performed before updating protected refs.",
      "_links": {
        "self": {
          "href": "https://fabrikam.visualstudio.com/DefaultCollection/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/0609b952-1397-4640-95ec-e00a01b2c241"
        }
      },
      "id": "0609b952-1397-4640-95ec-e00a01b2c241",
      "url": "https://fabrikam.visualstudio.com/DefaultCollection/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/0609b952-1397-4640-95ec-e00a01b2c241",
      "displayName": "Build"
    },
    {
      "description": "This policy will reject pushes to a repository for files which exceed the specified size.",
      "_links": {
        "self": {
          "href": "https://fabrikam.visualstudio.com/DefaultCollection/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/2e26e725-8201-4edd-8bf5-978563c34a80"
        }
      },
      "id": "2e26e725-8201-4edd-8bf5-978563c34a80",
      "url": "https://fabrikam.visualstudio.com/DefaultCollection/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/2e26e725-8201-4edd-8bf5-978563c34a80",
      "displayName": "File size restriction"
    },
    {
      "description": "This policy will ensure that required reviewers are added for files with certain extensions.",
      "_links": {
        "self": {
          "href": "https://fabrikam.visualstudio.com/DefaultCollection/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fd2167ab-b0be-447a-8ec8-39368250530e"
        }
      },
      "id": "fd2167ab-b0be-447a-8ec8-39368250530e",
      "url": "https://fabrikam.visualstudio.com/DefaultCollection/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fd2167ab-b0be-447a-8ec8-39368250530e",
      "displayName": "Required reviewers"
    },
    {
      "description": "This policy will ensure that a minimum number of reviewers have approved a pull request before completion.",
      "_links": {
        "self": {
          "href": "https://fabrikam.visualstudio.com/DefaultCollection/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fa4e907d-c16b-4a4c-9dfa-4906e5d171dd"
        }
      },
      "id": "fa4e907d-c16b-4a4c-9dfa-4906e5d171dd",
      "url": "https://fabrikam.visualstudio.com/DefaultCollection/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fa4e907d-c16b-4a4c-9dfa-4906e5d171dd",
      "displayName": "Minimum approval count"
    }
  ]
}

Get a policy type

GET https://{instance}/defaultcollection/{project}/_apis/policy/types/{id}?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string The name or ID of the team project.
id guid The ID of the policy type.
Query
api-version string Version of the API to use.

Sample request

GET https://fabrikam.visualstudio.com/DefaultCollection/fabrikam-fiber-git/_apis/policy/types/0609b952-1397-4640-95ec-e00a01b2c241?api-version=2.0-preview

Sample response

Status code: 200
{
  "description": "This policy will require a successful build has been performed before updating protected refs.",
  "_links": {
    "self": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/0609b952-1397-4640-95ec-e00a01b2c241"
    }
  },
  "id": "0609b952-1397-4640-95ec-e00a01b2c241",
  "url": "https://fabrikam.visualstudio.com/DefaultCollection/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/0609b952-1397-4640-95ec-e00a01b2c241",
  "displayName": "Build"
}