Team settings

Last Update: 3/6/2017

api-version = 2.0-preview.1

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

Get a team's settings

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

Sample request

GET https://fabrikam.visualstudio.com/DefaultCollection/fabrikam-fiber/_apis/work/teamsettings?api-version=3.0-preview

Sample response

Status code: 200
{
  "backlogIteration": {
    "id": "323b04b6-2fb8-4093-94f4-fbe3bd36a19f",
    "name": "Iteration",
    "path": "",
    "url": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/_apis/wit/classificationNodes/Iterations"
  },
  "bugsBehavior": "asRequirements",
  "workingDays": [
    "monday",
    "tuesday",
    "wednesday",
    "thursday",
    "friday"
  ],
  "backlogVisibilities": {
    "Microsoft.EpicCategory": false,
    "Microsoft.FeatureCategory": true,
    "Microsoft.RequirementCategory": true
  },
  "defaultIteration": {
    "id": "a912d62f-3eba-44b9-ab54-aa82af94b1d7",
    "name": "Iteration 1",
    "path": "\\Iteration 1",
    "url": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/_apis/wit/classificationNodes/Iterations/Iteration%201"
  },
  "defaultIterationMacro": "@currentIteration",
  "url": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/3e9700ae-46cb-4ee3-ad77-3a1b1ae99572/_apis/work/teamsettings",
  "_links": {
    "self": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/3e9700ae-46cb-4ee3-ad77-3a1b1ae99572/_apis/work/teamsettings"
    },
    "project": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/projects/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb"
    },
    "team": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/projects/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/teams/3e9700ae-46cb-4ee3-ad77-3a1b1ae99572"
    },
    "teamIterations": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/3e9700ae-46cb-4ee3-ad77-3a1b1ae99572/_apis/work/teamsettings/iterations"
    },
    "teamFieldValues": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/3e9700ae-46cb-4ee3-ad77-3a1b1ae99572/_apis/work/teamsettings/teamfieldvalues"
    },
    "classificationNode": [
      {
        "href": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/_apis/wit/classificationNodes/Iterations"
      },
      {
        "href": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/_apis/wit/classificationNodes/Iterations/Iteration%201"
      }
    ]
  }
}

Sample code

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using Newtonsoft.Json;

...

public void GetTeamSettings()
{
   string _personalAccessToken = "your personal access token";
   string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));
  string _project = "fabrikam-fiber";

   //use the httpclient
   using (var client = new HttpClient())
   {
       //set our headers
       client.BaseAddress = new Uri("https://accountname.visualstudio.com/");
       client.DefaultRequestHeaders.Accept.Clear();
       client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
       client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);

       //send the request and content
       HttpResponseMessage response = client.GetAsync(project + "/_apis/work/teamsettings?api-version=3.0-preview").Result;

       if (response.IsSuccessStatusCode)
       {
           var result = response.Content.ReadAsStringAsync().Result;
       }
   }
}
using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Core.WebApi.Types;
using Microsoft.TeamFoundation.Work.WebApi;
using Microsoft.VisualStudio.Services.Common;

...

public GetTeamSettings()
{
   //create uri and VssBasicCredential variables
   Uri _uri = new Uri("https://accountname.visualstudio.com");
   string _personalAccessToken = "your personal access token";
   VssBasicCredential _credentials = new VssBasicCredential("", _personalAccessToken);
  string _project = "fabrikam-fiber";

  using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(_uri, _credentials))
  {
       var teamContext = new TeamContext(_project);
      TeamSetting result = workHttpClient.GetTeamSettingsAsync(teamContext).Result;
  }
}

Update a team's settings

PATCH https://{instance}/DefaultCollection/{project}/{team}/_apis/Work/TeamSettings?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string Name or ID of the project.
team string Name or ID of the team.
Query
api-version string Version of the API to use.
Parameter Allowed Values
bugBehavior AsRequirements, AsTasks, Off
workingDays monday, tuesday, wednesday, thursday, friday, saturday, sunday
backlogVisibilities A dictionary of keys (Microsoft.EpicCategory, Microsoft.FeatureCategor, Microsoft.RequirementCategory) and boolean values.

Sample request

PATCH https://fabrikam.visualstudio.com/DefaultCollection/fabrikam-fiber/_apis/work/teamsettings?api-version=3.0-preview
Content-Type: application/json
{
  "bugsBehavior": "AsTasks",
  "workingDays": [
    "monday",
    "tuesday",
    "wednesday",
    "thursday"
  ],
  "defaultIteration": "8C2457E8-8936-4CDC-B3AA-17B20F56C76C"
}

Sample response

Status code: 200
{
  "backlogIteration": {
    "id": "323b04b6-2fb8-4093-94f4-fbe3bd36a19f",
    "name": "Iteration",
    "path": "",
    "url": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/_apis/wit/classificationNodes/Iterations"
  },
  "bugsBehavior": "asTasks",
  "workingDays": [
    "monday",
    "tuesday",
    "wednesday",
    "thursday"
  ],
  "backlogVisibilities": {
    "Microsoft.EpicCategory": false,
    "Microsoft.FeatureCategory": true,
    "Microsoft.RequirementCategory": true
  },
  "defaultIteration": {
    "id": "8c2457e8-8936-4cdc-b3aa-17b20f56c76c",
    "name": "Iteration 3",
    "path": "\\Iteration 3",
    "url": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/_apis/wit/classificationNodes/Iterations/Iteration%203"
  },
  "defaultIterationMacro": null,
  "url": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/3e9700ae-46cb-4ee3-ad77-3a1b1ae99572/_apis/work/teamsettings",
  "_links": {
    "self": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/3e9700ae-46cb-4ee3-ad77-3a1b1ae99572/_apis/work/teamsettings"
    },
    "project": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/projects/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb"
    },
    "team": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/projects/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/teams/3e9700ae-46cb-4ee3-ad77-3a1b1ae99572"
    },
    "teamIterations": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/3e9700ae-46cb-4ee3-ad77-3a1b1ae99572/_apis/work/teamsettings/iterations"
    },
    "teamFieldValues": {
      "href": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/3e9700ae-46cb-4ee3-ad77-3a1b1ae99572/_apis/work/teamsettings/teamfieldvalues"
    },
    "classificationNode": [
      {
        "href": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/_apis/wit/classificationNodes/Iterations"
      },
      {
        "href": "https://fabrikam.visualstudio.com/DefaultCollection/c1f04a4e-c4e5-4e0d-8096-e5f9fd214bfb/_apis/wit/classificationNodes/Iterations/Iteration%203"
      }
    ]
  }
}

Sample code

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using Newtonsoft.Json;

...

public class BacklogVisibilities
{
   [JsonProperty(PropertyName = "Microsoft.EpicCategory")]
   public bool MicrosoftEpicCategory { get; set; }

   [JsonProperty(PropertyName = "Microsoft.FeatureCategory")]
   public bool MicrosoftFeatureCategory { get; set; }

   [JsonProperty(PropertyName = "Microsoft.RequirementCategory")]
   public bool MicrosoftRequirementCategory { get; set; }
}

public void UpdateTeamSettings()
{
   string _personalAccessToken = "your personal access token";
   string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));
  string _project = "fabrikam-fiber";

   Object patchDocument = new Object();

   patchDocument = new {
      bugsBehavior = "AsRequirements",
      workingDays = new string[4] { "monday", "tuesday", "wednesday", "thursday" },
      backlogVisibilities = new BacklogVisibilities() {
          MicrosoftEpicCategory = false,
          MicrosoftFeatureCategory = true,
          MicrosoftRequirementCategory = true
      }
   };

   //use the httpclient
   using (var client = new HttpClient())
   {
      client.DefaultRequestHeaders.Accept.Clear();
      client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
      client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);

      // serialize the fields array into a json string
      var patchValue = new StringContent(JsonConvert.SerializeObject(patchDocument), Encoding.UTF8, "application/json");

      var method = new HttpMethod("PATCH");
      var request = new HttpRequestMessage(method, "https://accountname.visualstudio.com" + _project + "/_apis/work/teamsettings?api-version=3.0-preview") { Content = patchValue };
      var response = client.SendAsync(request).Result;

      if (response.IsSuccessStatusCode) {
           var result = response.Content.ReadAsStringAsync().Result;
      }
   }
}
using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Core.WebApi.Types;
using Microsoft.TeamFoundation.Work.WebApi;
using Microsoft.VisualStudio.Services.Common;

...

public UpdateTeamSettings()
{
   //create uri and VssBasicCredential variables
   Uri _uri = new Uri("https://accountname.visualstudio.com");
   string _personalAccessToken = "your personal access token";
   VssBasicCredential _credentials = new VssBasicCredential("", _personalAccessToken);
  string _project = "fabrikam-fiber";

   IDictionary<string, bool> backlogVisibilities = new Dictionary<string, bool>() {
      { "Microsoft.EpicCategory", false },
      { "Microsoft.FeatureCategory", true },
      { "Microsoft.RequirementCategory", true }
   };

   TeamSettingsPatch patchDocument = new TeamSettingsPatch() {
      BugsBehavior = BugsBehavior.AsRequirements,
      WorkingDays = new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday },
      BacklogVisibilities = backlogVisibilities
   };

   using (WorkHttpClient workHttpClient = new WorkHttpClient(_uri, _credentials)) {
      var teamContext = new TeamContext(project);
      TeamSetting result = workHttpClient.UpdateTeamSettingsAsync(patchDocument, teamContext).Result;
   }
}