# Update Object Schema By Key / Id

PUT https://services.leadconnectorhq.com/objects/{key}

Update Custom Object Schema  or standard object's like contact, opportunity, business searchable fields. To understand objects and records, please have a look at the documentation here : https://doc.clickup.com/8631005/d/h/87cpx-277156/93bf0c2e23177b0

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `key` | string | Yes | key of the custom or standard object. For custom objects, the key must include the prefix “custom_objects.”. This key can be found on the Object Details page under Settings in the UI. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/objects/{key}": {
      "put": {
        "summary": "Update Object Schema By Key / Id",
        "operationId": "updateObjectSchemaByKeyId",
        "description": "Update Custom Object Schema  or standard object's like contact, opportunity, business searchable fields. To understand objects and records, please have a look at the documentation here : https://doc.clickup.com/8631005/d/h/87cpx-277156/93bf0c2e23177b0",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "key",
            "required": true,
            "in": "path",
            "description": "key of the custom or standard object. For custom objects, the key must include the prefix “custom_objects.”. This key can be found on the Object Details page under Settings in the UI.",
            "schema": {
              "example": "custom_objects.pet",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomObjectSchemaDTO"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomObjectResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "objects/schema.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": {
      "UpdateCustomObjectSchemaDTO": {
        "type": "object",
        "properties": {
          "labels": {
            "example": {
              "singular": "Pet",
              "plural": "Pets"
            },
            "description": "This is how your custom object will  be  displayed",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "singular": {
                    "type": "string",
                    "example": "Car",
                    "description": "Singular name of the custom object"
                  },
                  "plural": {
                    "type": "string",
                    "example": "Cars",
                    "description": "Plural name of the custom object"
                  }
                },
                "title": "CustomObjectLabelUpdateDto"
              }
            ]
          },
          "description": {
            "type": "string",
            "example": "These are non vaccinated pets",
            "description": "Pet Object`s description",
            "nullable": true
          },
          "locationId": {
            "type": "string",
            "description": "location id",
            "example": "632c34b4c9b7da3358ac9891"
          },
          "searchableProperties": {
            "description": "Searchable Fields: Provide the field key of your object that you want to search on, using the format (custom_object.<object_name>.<field_key>).",
            "example": [
              "custom_objects.mad.mad",
              "custom_objects.mad.record_1",
              "custom_objects.mad.nn"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "locationId",
          "searchableProperties"
        ],
        "title": "UpdateCustomObjectSchemaDTO"
      },
      "CustomObjectResponseDTO": {
        "type": "object",
        "properties": {
          "object": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "661c06b4ffde146bdb469442",
                "description": "id of the custom / standard object schema"
              },
              "standard": {
                "type": "boolean",
                "example": false,
                "description": "false in case of custom objects and true in case of standard objects like contacts and opportunities "
              },
              "key": {
                "type": "string",
                "example": "custom_objects.pet",
                "description": "key that would be used to refer the custom / standard Object internally (lowercase + underscore_separated). For custom objects, 'custom_objects.' would be added as prefix by default"
              },
              "labels": {
                "example": {
                  "singular": "Pet",
                  "plural": "Pets"
                },
                "description": "This is what your custom / standard  object will be called. These labels will be used to display your custom object on the UI",
                "allOf": [
                  {
                    "type": "object",
                    "properties": {
                      "singular": {
                        "type": "string",
                        "example": "Pet",
                        "description": "Singular name of the custom object"
                      },
                      "plural": {
                        "type": "string",
                        "example": "Pets",
                        "description": "Plural name of the custom object"
                      }
                    },
                    "required": [
                      "singular",
                      "plural"
                    ],
                    "title": "CustomObjectLabelDto"
                  }
                ]
              },
              "description": {
                "type": "string",
                "example": "These are non vaccinated pets",
                "description": "Custom / Standard  Object Descriptions for example , Pet Object`s description"
              },
              "locationId": {
                "type": "string",
                "description": "location's id",
                "example": "Q9DT3OAqEXDLYuob1G32"
              },
              "primaryDisplayProperty": {
                "type": "string",
                "description": "Primary property for the custom / standard  Object. This would be used as primary data when rendering the UI. 'custom_objects.{{object_key}} or business.{{object_key}} (for company)' would be added as prefix by default for all the custom / standard objects",
                "example": "custom_objects.pet.name"
              },
              "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"
              },
              "type": {
                "type": "object",
                "example": "The Object type can either USER_DEFINED or SYSTEM_DEFINED",
                "description": "Object`s Type"
              }
            },
            "required": [
              "id",
              "standard",
              "key",
              "labels",
              "locationId",
              "primaryDisplayProperty",
              "dateAdded",
              "dateUpdated"
            ],
            "title": "ICustomObjectSchema"
          }
        },
        "title": "CustomObjectResponseDTO"
      },
      "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"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X PUT 'https://services.leadconnectorhq.com/objects/<key>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "description": "These are non vaccinated pets",
  "locationId": "632c34b4c9b7da3358ac9891",
  "searchableProperties": [
    "custom_objects.mad.mad",
    "custom_objects.mad.record_1",
    "custom_objects.mad.nn"
  ]
}'
```

**Node.js**

```javascript
const options = {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "labels": {
        "singular": "Pet",
        "plural": "Pets"
      },
      "description": "These are non vaccinated pets",
      "locationId": "632c34b4c9b7da3358ac9891",
      "searchableProperties": [
        "custom_objects.mad.mad",
        "custom_objects.mad.record_1",
        "custom_objects.mad.nn"
      ]
  })
};

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

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/objects/{key}"

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

payload = {
    "labels": {
        "singular": "Pet",
        "plural": "Pets"
    },
    "description": "These are non vaccinated pets",
    "locationId": "632c34b4c9b7da3358ac9891",
    "searchableProperties": [
        "custom_objects.mad.mad",
        "custom_objects.mad.record_1",
        "custom_objects.mad.nn"
    ]
}

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/objects/<key>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "description": "These are non vaccinated pets",
  "locationId": "632c34b4c9b7da3358ac9891",
  "searchableProperties": [
    "custom_objects.mad.mad",
    "custom_objects.mad.record_1",
    "custom_objects.mad.nn"
  ]
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .put("https://services.leadconnectorhq.com/objects/<key>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"labels\":{\"singular\":\"Pet\",\"plural\":\"Pets\"},\"description\":\"These are non vaccinated pets\",\"locationId\":\"632c34b4c9b7da3358ac9891\",\"searchableProperties\":[\"custom_objects.mad.mad\",\"custom_objects.mad.record_1\",\"custom_objects.mad.nn\"]}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/objects/<key>"
  payload := strings.NewReader(`{
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "description": "These are non vaccinated pets",
  "locationId": "632c34b4c9b7da3358ac9891",
  "searchableProperties": [
    "custom_objects.mad.mad",
    "custom_objects.mad.record_1",
    "custom_objects.mad.nn"
  ]
}`)
  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/objects/<key>")

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 = '{
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "description": "These are non vaccinated pets",
  "locationId": "632c34b4c9b7da3358ac9891",
  "searchableProperties": [
    "custom_objects.mad.mad",
    "custom_objects.mad.record_1",
    "custom_objects.mad.nn"
  ]
}'

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

**PowerShell**

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

$body = '{
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "description": "These are non vaccinated pets",
  "locationId": "632c34b4c9b7da3358ac9891",
  "searchableProperties": [
    "custom_objects.mad.mad",
    "custom_objects.mad.record_1",
    "custom_objects.mad.nn"
  ]
}'

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