> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.getunleash.io/api/update-context-field-for-project/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getunleash.io/_mcp/server. # [BETA] Update an existing context field PUT https://app.unleash-instance.example.com/api/admin/projects/{projectId}/context/{contextField} Content-Type: application/json **[BETA]** This API is in beta state, which means it may change or be removed in the future. Endpoint that allows updating a custom context field. Used to toggle stickiness and add/remove legal values for this context field Reference: https://docs.getunleash.io/api/update-context-field-for-project ## Authentication - `Authorization` header (required) — API key needed to access this API - `Authorization` header (bearer token, required) — API key needed to access this API, in Bearer token format ## Request ### Path parameters - `projectId` (string, required) - `contextField` (string, required) ### Body (application/json) This endpoint expects an updateContextFieldSchema. - `description` (string, optional) — A description of the context field - `stickiness` (boolean, optional) — `true` if this field should be available for use with [custom stickiness](https://docs.getunleash.io/concepts/stickiness#custom-stickiness), otherwise `false` - `sortOrder` (integer, optional) — How this context field should be sorted if no other sort order is selected - `legalValues` (list of legalValueSchema, optional) — A list of allowed values for this context field - `project` (string, optional) — The project this context field belongs to (if it is project-specific) ## Response ### 200 This response has no body. ## Types ### legalValueSchema Describes a legal value. Typically used to limit possible values for contextFields or strategy properties - `value` (string, required) — The valid value - `description` (string, optional) — Describes this specific legal value ## Examples **Request** ```json {} ``` **Response** ```json {} ``` **SDK Code** ```python import requests url = "https://app.unleash-instance.example.com/api/admin/projects/projectId/context/contextField" payload = {} headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.put(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://app.unleash-instance.example.com/api/admin/projects/projectId/context/contextField'; const options = { method: 'PUT', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/projects/projectId/context/contextField" payload := strings.NewReader("{}") req, _ := http.NewRequest("PUT", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://app.unleash-instance.example.com/api/admin/projects/projectId/context/contextField") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.put("https://app.unleash-instance.example.com/api/admin/projects/projectId/context/contextField") .header("Authorization", "") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('PUT', 'https://app.unleash-instance.example.com/api/admin/projects/projectId/context/contextField', [ 'body' => '{}', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://app.unleash-instance.example.com/api/admin/projects/projectId/context/contextField"); var request = new RestRequest(Method.PUT); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://app.unleash-instance.example.com/api/admin/projects/projectId/context/contextField")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```