# Update Custom Field By Id

PUT https://services.leadconnectorhq.com/custom-fields/{id}

<div>
 <p> Update Custom Field By Id </p> 
 </div> 
 :::info
 Only supports Custom Objects and Company (Business) today. Will be extended to other Standard Objects in the future.
 :::

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `locations/customFields.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | Yes |  |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/custom-fields/{id}": {
      "put": {
        "summary": "Update Custom Field By Id",
        "operationId": "updateCustomFieldById",
        "description": "<div>\n <p> Update Custom Field By Id </p> \n </div> \n :::info\n Only supports Custom Objects and Company (Business) today. Will be extended to other Standard Objects in the future.\n :::",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomFieldsDTO"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldSuccessfulResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "locations/customFields.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "UpdateCustomFieldsDTO": {
        "type": "object",
        "properties": {
          "locationId": {
            "type": "string",
            "description": "Location Id",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "name": {
            "type": "string",
            "description": "Field name",
            "example": "Name"
          },
          "description": {
            "type": "string",
            "description": "Description of the field"
          },
          "placeholder": {
            "type": "string",
            "description": "Placeholder text for the field"
          },
          "showInForms": {
            "type": "boolean",
            "description": "Whether the field should be shown in forms"
          },
          "options": {
            "description": "Options for the field. Important: Providing options will completely replace the existing options array. You must include all existing options alongside any new options you wish to add. Removal of options is not supported through this update. Applicable only for SINGLE_OPTIONS, MULTIPLE_OPTIONS, RADIO, CHECKBOX, TEXTBOX_LIST types.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "description": "Key of the option (Included in Create and Response, excluded in Update)"
                },
                "label": {
                  "type": "string",
                  "description": "Value of the option"
                },
                "url": {
                  "type": "string",
                  "description": "URL associated with the option (Optional, valid only for RADIO type)"
                }
              },
              "required": [
                "key",
                "label"
              ],
              "title": "OptionDTO"
            }
          },
          "acceptedFormats": {
            "type": "string",
            "enum": [
              ".pdf",
              ".docx",
              ".doc",
              ".jpg",
              ".jpeg",
              ".png",
              ".gif",
              ".csv",
              ".xlsx",
              ".xls",
              "all"
            ],
            "description": "Allowed file formats for uploads. Options include: .pdf, .docx, .doc, .jpg, .jpeg, .png, .gif, .csv, .xlsx, .xls, all"
          },
          "maxFileLimit": {
            "type": "number",
            "description": "Maximum file limit for uploads. Applicable only for fields with a data type of FILE_UPLOAD.",
            "example": 2
          }
        },
        "required": [
          "locationId",
          "showInForms"
        ],
        "title": "UpdateCustomFieldsDTO"
      },
      "CustomFieldSuccessfulResponseDto": {
        "type": "object",
        "properties": {
          "field": {
            "type": "object",
            "properties": {
              "locationId": {
                "type": "string",
                "description": "Location Id",
                "example": "ve9EPM428h8vShlRW1KT"
              },
              "name": {
                "type": "string",
                "description": "Field name",
                "example": "Name"
              },
              "description": {
                "type": "string",
                "description": "Description of the field"
              },
              "placeholder": {
                "type": "string",
                "description": "Placeholder text for the field"
              },
              "showInForms": {
                "type": "boolean",
                "description": "Whether the field should be shown in forms"
              },
              "options": {
                "description": "Options for the field (Optional, valid only for SINGLE_OPTIONS, MULTIPLE_OPTIONS, RADIO, CHECKBOX, TEXTBOX_LIST type)",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string",
                      "description": "Key of the option (Included in Create and Response, excluded in Update)"
                    },
                    "label": {
                      "type": "string",
                      "description": "Value of the option"
                    },
                    "url": {
                      "type": "string",
                      "description": "URL associated with the option (Optional, valid only for RADIO type)"
                    }
                  },
                  "required": [
                    "key",
                    "label"
                  ],
                  "title": "OptionDTO"
                }
              },
              "acceptedFormats": {
                "type": "string",
                "enum": [
                  ".pdf",
                  ".docx",
                  ".doc",
                  ".jpg",
                  ".jpeg",
                  ".png",
                  ".gif",
                  ".csv",
                  ".xlsx",
                  ".xls",
                  "all"
                ],
                "description": "Allowed file formats for uploads. Options include: .pdf, .docx, .doc, .jpg, .jpeg, .png, .gif, .csv, .xlsx, .xls, all"
              },
              "id": {
                "type": "string",
                "description": "Unique identifier of the object"
              },
              "objectKey": {
                "type": "string",
                "description": "The key for your custom / standard object. This key uniquely identifies the custom object. Example: \"custom_object.pet\" for a custom object related to pets.",
                "example": "custom_object.pet"
              },
              "dataType": {
                "type": "string",
                "enum": [
                  "TEXT",
                  "LARGE_TEXT",
                  "NUMERICAL",
                  "PHONE",
                  "MONETORY",
                  "CHECKBOX",
                  "SINGLE_OPTIONS",
                  "MULTIPLE_OPTIONS",
                  "DATE",
                  "TEXTBOX_LIST",
                  "FILE_UPLOAD",
                  "RADIO"
                ],
                "description": "Type of field that you are trying to create"
              },
              "parentId": {
                "type": "string",
                "description": "ID of the parent folder",
                "example": "3v34PM428h8vShlRW1KT"
              },
              "fieldKey": {
                "type": "string",
                "description": "Field key. For Custom Object it's formatted as \"custom_object.{objectKey}.{fieldKey}\". \"custom_object\" is a fixed prefix, \"{objectKey}\" is your custom object's identifier, and \"{fieldName}\" is the unique field name within that object. Example: \"custom_object.pet.name\" for a \"name\" field in a \"pet\" custom object.",
                "example": "custom_object.pet.name"
              },
              "allowCustomOption": {
                "type": "boolean",
                "description": "Determines if users can add a custom option value different from the predefined options in records for RADIO type fields. A custom value added in one record does not automatically become an option and will not appear as an option for other records.",
                "example": true
              },
              "maxFileLimit": {
                "type": "number",
                "description": "Maximum file limit for uploads",
                "example": 2
              },
              "dateAdded": {
                "type": "string",
                "description": "Date and time when the object was added",
                "format": "date-time"
              },
              "dateUpdated": {
                "type": "string",
                "description": "Date and time when the object was last updated",
                "format": "date-time"
              }
            },
            "required": [
              "locationId",
              "showInForms",
              "id",
              "objectKey",
              "dataType",
              "parentId",
              "fieldKey",
              "dateAdded",
              "dateUpdated"
            ],
            "title": "ICustomField"
          }
        },
        "title": "CustomFieldSuccessfulResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X PUT 'https://services.leadconnectorhq.com/custom-fields/<id>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "locationId": "ve9EPM428h8vShlRW1KT",
  "name": "Name",
  "options": [],
  "maxFileLimit": 2
}'
```

**Node.js**

```javascript
const options = {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "locationId": "ve9EPM428h8vShlRW1KT",
      "name": "Name",
      "options": [],
      "maxFileLimit": 2
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/custom-fields/<id>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/custom-fields/{id}"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

payload = {
    "locationId": "ve9EPM428h8vShlRW1KT",
    "name": "Name",
    "options": [],
    "maxFileLimit": 2
}

response = requests.put(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/custom-fields/<id>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "locationId": "ve9EPM428h8vShlRW1KT",
  "name": "Name",
  "options": [],
  "maxFileLimit": 2
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .put("https://services.leadconnectorhq.com/custom-fields/<id>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"locationId\":\"ve9EPM428h8vShlRW1KT\",\"name\":\"Name\",\"options\":[],\"maxFileLimit\":2}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/custom-fields/<id>"
  payload := strings.NewReader(`{
  "locationId": "ve9EPM428h8vShlRW1KT",
  "name": "Name",
  "options": [],
  "maxFileLimit": 2
}`)
  req, _ := http.NewRequest("PUT", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/custom-fields/<id>")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "locationId": "ve9EPM428h8vShlRW1KT",
  "name": "Name",
  "options": [],
  "maxFileLimit": 2
}'

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

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "locationId": "ve9EPM428h8vShlRW1KT",
  "name": "Name",
  "options": [],
  "maxFileLimit": 2
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/custom-fields/<id>' -Method 'PUT' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
