# Updates an environment by name PUT https://app.unleash-instance.example.com/api/admin/environments/update/{name} Content-Type: application/json **Enterprise feature** Given an environment by name updates the environment with the given payload. Note that `name`, `enabled` and `protected` cannot be changed by this API Reference: https://docs.getunleash.io/api/update-environment ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Updates an environment by name version: endpoint_environments.updateEnvironment paths: /api/admin/environments/update/{name}: put: operationId: update-environment summary: Updates an environment by name description: >- **Enterprise feature** Given an environment by name updates the environment with the given payload. Note that `name`, `enabled` and `protected` cannot be changed by this API tags: - - subpackage_environments parameters: - name: name in: path required: true schema: type: string - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '200': description: environmentSchema content: application/json: schema: $ref: '#/components/schemas/environmentSchema' '400': description: The request data does not match what we expect. content: {} '401': description: >- Authorization information is missing or invalid. Provide a valid API token as the `authorization` header, e.g. `authorization:*.*.my-admin-token`. content: {} requestBody: description: updateEnvironmentSchema content: application/json: schema: $ref: '#/components/schemas/updateEnvironmentSchema' components: schemas: updateEnvironmentSchema: type: object properties: type: type: string description: Updates the type of environment (i.e. development or production). sortOrder: type: integer description: Changes the sort order of this environment. requiredApprovals: type: - integer - 'null' description: >- Experimental field. The number of approvals required before a change request can be applied in this environment. environmentSchema: type: object properties: name: type: string description: The name of the environment type: type: string description: >- The [type of environment](https://docs.getunleash.io/concepts/environments#environment-types). enabled: type: boolean description: >- `true` if the environment is enabled for the project, otherwise `false`. protected: type: boolean description: >- `true` if the environment is protected, otherwise `false`. A *protected* environment can not be deleted. sortOrder: type: integer description: >- Priority of the environment in a list of environments, the lower the value, the higher up in the list the environment will appear. Needs to be an integer projectCount: type: - integer - 'null' description: The number of projects with this environment apiTokenCount: type: - integer - 'null' description: The number of API tokens for the project environment enabledToggleCount: type: - integer - 'null' description: The number of enabled toggles for the project environment requiredApprovals: type: - integer - 'null' description: >- Experimental field. The number of approvals required before a change request can be applied in this environment. required: - name - type - enabled - protected - sortOrder ``` ## SDK Code Examples ```python import requests url = "https://app.unleash-instance.example.com/api/admin/environments/update/name" 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/environments/update/name'; 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/environments/update/name" 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/environments/update/name") 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/environments/update/name") .header("Authorization", "") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('PUT', 'https://app.unleash-instance.example.com/api/admin/environments/update/name', [ '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/environments/update/name"); 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/environments/update/name")! 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() ```