> For a complete page index, fetch https://developer.close.com/llms.txt

# Bulk update memberships

PUT https://api.close.com/api/v1/membership/
Content-Type: application/json

Any field that can be updated on a membership individually can also be used to bulk update multiple memberships. Pass the comma-separated ids of the memberships to update into `id__in` in `_params`. For example:

```json
{"_params": {"id__in": "memb_A,memb_B"}, "role_id": "role_y6eLquXvRUdmwqi61tsmgCJUU7uGfxaRbDuLoONZL9p"}
```

Reference: https://developer.close.com/api/resources/memberships/bulk-update

## Authentication

- `Authorization` header (basic auth, required) — Use your API key as the username and leave the password empty.
- `Authorization` header (bearer token, required)

## Request

### Body (application/json)

- `auto_record_calls` (enum, optional) — Whether this member's calls are automatically recorded. Starts as `unset` and can be set to `enabled` or `disabled`.
  - Allowed values: `enabled`, `disabled`, `unset`
- `default_caller_id` (string, optional, nullable) — ID of the phone number to use as this member's default outbound caller ID.
- `hangup_recording_url` (string, optional, nullable) — URL of the audio file used as this member's voicemail drop recording.
- `may_workflows_impersonate` (boolean, optional) — Whether Workflows may send emails on this member's behalf.
- `role_id` (string, optional) — One of `admin`, `superuser`, `user`, or `restricteduser` for the corresponding predefined role, or the ID of a custom [Role](https://developer.close.com/api/resources/roles).
- `track_email_opens` (boolean, optional) — Whether email opens are tracked for emails this member sends.

## Response

### 200

Successful response

## Examples

**Request**

```json
{
  "role_id": "role_y6eLquXvRUdmwqi61tsmgCJUU7uGfxaRbDuLoONZL9p"
}
```

**Response**

```json
{
  "count": 2
}
```

**SDK Code**

```python memberships_bulkUpdate_example
import requests

url = "https://api.close.com/api/v1/membership/"

payload = { "role_id": "role_y6eLquXvRUdmwqi61tsmgCJUU7uGfxaRbDuLoONZL9p" }
headers = {
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers, auth=("<CLOSE_API_KEY>", ""))

print(response.json())
```

```javascript memberships_bulkUpdate_example
const url = 'https://api.close.com/api/v1/membership/';
const credentials = btoa("<CLOSE_API_KEY>:");

const options = {
  method: 'PUT',
  headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'},
  body: '{"role_id":"role_y6eLquXvRUdmwqi61tsmgCJUU7uGfxaRbDuLoONZL9p"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go memberships_bulkUpdate_example
package main

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

func main() {

	url := "https://api.close.com/api/v1/membership/"

	payload := strings.NewReader("{\n  \"role_id\": \"role_y6eLquXvRUdmwqi61tsmgCJUU7uGfxaRbDuLoONZL9p\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.SetBasicAuth("<CLOSE_API_KEY>", "")
	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 memberships_bulkUpdate_example
require 'uri'
require 'net/http'

url = URI("https://api.close.com/api/v1/membership/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request.basic_auth("<CLOSE_API_KEY>", "")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"role_id\": \"role_y6eLquXvRUdmwqi61tsmgCJUU7uGfxaRbDuLoONZL9p\"\n}"

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

```java memberships_bulkUpdate_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.close.com/api/v1/membership/")
  .basicAuth("<CLOSE_API_KEY>", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"role_id\": \"role_y6eLquXvRUdmwqi61tsmgCJUU7uGfxaRbDuLoONZL9p\"\n}")
  .asString();
```

```php memberships_bulkUpdate_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.close.com/api/v1/membership/', [
  'body' => '{
  "role_id": "role_y6eLquXvRUdmwqi61tsmgCJUU7uGfxaRbDuLoONZL9p"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<CLOSE_API_KEY>', ''],
]);

echo $response->getBody();
```

```csharp memberships_bulkUpdate_example
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://api.close.com/api/v1/membership/");
client.Authenticator = new HttpBasicAuthenticator("<CLOSE_API_KEY>", "");
var request = new RestRequest(Method.PUT);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"role_id\": \"role_y6eLquXvRUdmwqi61tsmgCJUU7uGfxaRbDuLoONZL9p\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```