---
title: Update Population
description: To update a population resource, you must know the environment ID and the ID of the population to modify. Use PUT {{apiPath}}/v1/environments/{{envID}}/populations/{{populationID}} to update the attribute values for a population in the specified environment.
component: pingone-api
page_id: pingone-api:platform:populations/update-population
canonical_url: https://developer.pingidentity.com/pingone-api/platform/populations/update-population.html
section_ids:
  prerequisites: Prerequisites
  headers: Headers
  body: Body
  example-request: Example Request
  example-response: Example Response
---

# Update Population

##

```none
PUT {{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}
```

To update a population resource, you must know the environment ID and the ID of the population to modify. Use `PUT {{apiPath}}/v1/environments/{{envID}}/populations/{{populationID}}` to update the attribute values for a population in the specified environment.

An optional `default` property can be used to assign the population as the default for the environment. When new users are created, they are assigned to the environment's default population, unless otherwise specified. When `default` is set to `true`, all other populations within the environment are set to `false`.

Populations, by default, use the default password policy and default theme for the environment. However, you've the option to:

* Assign a password policy specific to this population with the `passwordPolicy.id` property in the request body. To unassign the `passwordPolicy.id` property, omit `passwordPolicy.id` from the request body, and the population again uses the default password policy for the environment.

* Assign a theme specific to this population with the `theme.id` property in the request body. To unassign the `theme.id` property, omit `theme.id` from the request body, and the population again uses the default theme for the environment.

### Prerequisites

* Refer to [Populations](../populations.html) for important overview information.

> **Collapse: Request Model**
>
> | Property                 | Type      | Required? |
> | ------------------------ | --------- | --------- |
> | `alternativeIdentifiers` | String\[] | Optional  |
> | `default`                | Boolean   | Optional  |
> | `description`            | String    | Optional  |
> | `name`                   | String    | Required  |
> | `passwordPolicy.id`      | String    | Optional  |
> | `preferredLanguage`      | String    | Optional  |
> | `theme.id`               | String    | Optional  |
>
> Refer to the [Populations data model](../populations.html#populations-data-model) for full property descriptions.

### Headers

Authorization      Bearer {{accessToken}}

Content-Type      application/json

### Body

raw ( application/json )

```json
{
  "name" : "Accounting",
  "description" : "Accounting group",
  "default": false,
  "passwordPolicy": {
       "id": "{{passwordPolicyID}}"
   }
}
```

##

### Example Request

* cURL

* C#

* Go

* HTTP

* Java

* jQuery

* NodeJS

* Python

* PHP

* Ruby

* Swift

```shell
curl --location --globoff --request PUT '{{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{accessToken}}' \
--data '{
  "name" : "Accounting",
  "description" : "Accounting group",
  "default": false,
  "passwordPolicy": {
       "id": "{{passwordPolicyID}}"
   }
}'
```

```csharp
var options = new RestClientOptions("{{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Put);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer {{accessToken}}");
var body = @"{" + "\n" +
@"  ""name"" : ""Accounting""," + "\n" +
@"  ""description"" : ""Accounting group""," + "\n" +
@"  ""default"": false," + "\n" +
@"  ""passwordPolicy"": {" + "\n" +
@"       ""id"": ""{{passwordPolicyID}}""" + "\n" +
@"   }" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

```golang
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "{{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}"
  method := "PUT"

  payload := strings.NewReader(`{
  "name" : "Accounting",
  "description" : "Accounting group",
  "default": false,
  "passwordPolicy": {
       "id": "{{passwordPolicyID}}"
   }
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer {{accessToken}}")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

```http
PUT /v1/environments/{{envID}}/populations/{{popID}} HTTP/1.1
Host: {{apiPath}}
Content-Type: application/json
Authorization: Bearer {{accessToken}}

{
  "name" : "Accounting",
  "description" : "Accounting group",
  "default": false,
  "passwordPolicy": {
       "id": "{{passwordPolicyID}}"
   }
}
```

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"name\" : \"Accounting\",\n  \"description\" : \"Accounting group\",\n  \"default\": false,\n  \"passwordPolicy\": {\n       \"id\": \"{{passwordPolicyID}}\"\n   }\n}");
Request request = new Request.Builder()
  .url("{{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}")
  .method("PUT", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer {{accessToken}}")
  .build();
Response response = client.newCall(request).execute();
```

```javascript
var settings = {
  "url": "{{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}",
  "method": "PUT",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Bearer {{accessToken}}"
  },
  "data": JSON.stringify({
    "name": "Accounting",
    "description": "Accounting group",
    "default": false,
    "passwordPolicy": {
      "id": "{{passwordPolicyID}}"
    }
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

```javascript
var request = require('request');
var options = {
  'method': 'PUT',
  'url': '{{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {{accessToken}}'
  },
  body: JSON.stringify({
    "name": "Accounting",
    "description": "Accounting group",
    "default": false,
    "passwordPolicy": {
      "id": "{{passwordPolicyID}}"
    }
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

```python
import requests
import json

url = "{{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}"

payload = json.dumps({
  "name": "Accounting",
  "description": "Accounting group",
  "default": False,
  "passwordPolicy": {
    "id": "{{passwordPolicyID}}"
  }
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer {{accessToken}}'
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)
```

```php
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}');
$request->setMethod(HTTP_Request2::METHOD_PUT);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer {{accessToken}}'
));
$request->setBody('{\n  "name" : "Accounting",\n  "description" : "Accounting group",\n  "default": false,\n  "passwordPolicy": {\n       "id": "{{passwordPolicyID}}"\n   }\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
```

```ruby
require "uri"
require "json"
require "net/http"

url = URI("{{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Put.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer {{accessToken}}"
request.body = JSON.dump({
  "name": "Accounting",
  "description": "Accounting group",
  "default": false,
  "passwordPolicy": {
    "id": "{{passwordPolicyID}}"
  }
})

response = http.request(request)
puts response.read_body
```

```swift
let parameters = "{\n  \"name\" : \"Accounting\",\n  \"description\" : \"Accounting group\",\n  \"default\": false,\n  \"passwordPolicy\": {\n       \"id\": \"{{passwordPolicyID}}\"\n   }\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "{{apiPath}}/v1/environments/{{envID}}/populations/{{popID}}")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Bearer {{accessToken}}", forHTTPHeaderField: "Authorization")

request.httpMethod = "PUT"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()
```

### Example Response

200 OK

```json
{
    "_links": {
        "self": {
            "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/populations/941b174d-1471-47e0-8ebf-fd934c472deb"
        },
        "environment": {
            "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
        }
    },
    "id": "941b174d-1471-47e0-8ebf-fd934c472deb",
    "environment": {
        "id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
    },
    "name": "Accounting",
    "description": "Accounting group",
    "userCount": 0,
    "createdAt": "2022-02-07T22:17:16.241Z",
    "updatedAt": "2022-02-08T14:06:50.335Z",
    "passwordPolicy": {
        "id": "3d36d311-c424-4b61-b1da-865faced4d00"
    },
    "default": false
}
```
