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

# Update an existing Shared Custom Field Association

PUT https://api.close.com/api/v1/custom_field/shared/{scf_id}/association/{object_type}/
Content-Type: application/json

You can change the `required` or the `editable_with_roles` attributes. Everything else cannot be changed.

The `object_type` in the URL can be either:

* `lead` when editing the association with the Lead object.
* `contact` when editing the association with the Contact object.
* `opportunity` when editing the association with the Opportunity object.
* `custom_activity_type/<catype_id>` when editing the association with a specific
  Custom Activity Type.
* `custom_object_type/<cotype_id>` when editing the association with a specific
  Custom Object Type.

Reference: https://developer.close.com/api/resources/custom-fields/custom-fields-shared/update-association

## Authentication

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

## Request

### Path parameters

- `scf_id` (string, required)
- `object_type` (string, required)

### Body (application/json)

- `any`

## Response

### 200

Successful response

## Examples

**Request**

```json
{
  "editable_with_roles": [
    "admin",
    "role_4zhUd9gDKwVv0Bbl2Nk0Ud"
  ]
}
```

**Response**

```json
{
  "editable_with_roles": [
    "admin",
    "role_4zhUd9gDKwVv0Bbl2Nk0Ud"
  ],
  "object_type": "lead",
  "required": false
}
```

**SDK Code**

```python
import requests

url = "https://api.close.com/api/v1/custom_field/shared/:scf_id/association/:object_type/"

payload = { "editable_with_roles": ["admin", "role_4zhUd9gDKwVv0Bbl2Nk0Ud"] }
headers = {
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.close.com/api/v1/custom_field/shared/:scf_id/association/:object_type/';
const credentials = btoa("<CLOSE_API_KEY>:");

const options = {
  method: 'PUT',
  headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'},
  body: '{"editable_with_roles":["admin","role_4zhUd9gDKwVv0Bbl2Nk0Ud"]}'
};

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://api.close.com/api/v1/custom_field/shared/:scf_id/association/:object_type/"

	payload := strings.NewReader("{\n  \"editable_with_roles\": [\n    \"admin\",\n    \"role_4zhUd9gDKwVv0Bbl2Nk0Ud\"\n  ]\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
require 'uri'
require 'net/http'

url = URI("https://api.close.com/api/v1/custom_field/shared/:scf_id/association/:object_type/")

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  \"editable_with_roles\": [\n    \"admin\",\n    \"role_4zhUd9gDKwVv0Bbl2Nk0Ud\"\n  ]\n}"

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

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

HttpResponse<String> response = Unirest.put("https://api.close.com/api/v1/custom_field/shared/:scf_id/association/:object_type/")
  .basicAuth("<CLOSE_API_KEY>", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"editable_with_roles\": [\n    \"admin\",\n    \"role_4zhUd9gDKwVv0Bbl2Nk0Ud\"\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.close.com/api/v1/custom_field/shared/:scf_id/association/:object_type/', [
  'body' => '{
  "editable_with_roles": [
    "admin",
    "role_4zhUd9gDKwVv0Bbl2Nk0Ud"
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<CLOSE_API_KEY>', ''],
]);

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

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

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

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