# Create Custom Object

POST https://services.leadconnectorhq.com/objects/

Allows you to create a custom object schema. 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 |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-07-28"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/objects/": {
      "post": {
        "summary": "Create Custom Object",
        "operationId": "createCustomObject",
        "description": "Allows you to create a custom object schema. 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": [
                "2021-07-28"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomObjectSchemaDTO"
              }
            }
          }
        },
        "responses": {
          "201": {
            "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": {
      "CreateCustomObjectSchemaDTO": {
        "type": "object",
        "properties": {
          "labels": {
            "example": {
              "singular": "Pet",
              "plural": "Pets"
            },
            "description": "This is what your custom 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"
              }
            ]
          },
          "key": {
            "type": "string",
            "example": "custom_objects.pet",
            "description": "key that would be used to refer the Custom Object internally (lowercase + underscore_separated). 'custom_objects.' would be added as prefix by default"
          },
          "description": {
            "type": "string",
            "example": "These are non vaccinated pets",
            "description": "Pet Object`s description"
          },
          "locationId": {
            "type": "string",
            "description": "Location Id",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "primaryDisplayPropertyDetails": {
            "description": "Primary property which will be displayed on the record page",
            "example": {
              "key": "custom_objects.pet.name",
              "name": "Pet name",
              "dataType": "TEXT",
              "isUnique": false
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "example": "custom_objects.pet.name",
                    "description": "key that would be used to refer the custom field internally (lowercase + underscore_separated). 'custom_objects.{{objectKey}}' would be added as prefix by default is not passed"
                  },
                  "name": {
                    "type": "string",
                    "example": "Pet name",
                    "description": "Name of the Primary property name which will be displayed on the record page"
                  },
                  "dataType": {
                    "type": "string",
                    "example": "TEXT",
                    "description": "Primary property data Type (it can either be TEXT or NUMERICAL type)"
                  },
                  "isUnique": {
                    "type": "boolean",
                    "example": false,
                    "description": "Whether the primary field should be unique within the object"
                  }
                },
                "required": [
                  "key",
                  "name",
                  "dataType"
                ],
                "title": "CustomObjectDisplayPropertyDetails"
              }
            ]
          }
        },
        "required": [
          "labels",
          "key",
          "locationId",
          "primaryDisplayPropertyDetails"
        ],
        "title": "CreateCustomObjectSchemaDTO"
      },
      "CustomObjectResponseDTO": {
        "type": "object",
        "properties": {
          "object": {
            "description": "The custom or standard object schema",
            "example": {
              "id": "661c06b4ffde146bdb469442",
              "standard": false,
              "key": "custom_objects.pet",
              "labels": {
                "singular": "Pet",
                "plural": "Pets"
              },
              "description": "These are non vaccinated pets",
              "locationId": "ve9EPM428h8vShlRW1KT",
              "primaryDisplayProperty": "custom_objects.pet.name",
              "type": "USER_DEFINED",
              "dateAdded": "2025-01-02T09:35:39.032Z",
              "dateUpdated": "2025-01-02T09:35:39.032Z"
            },
            "allOf": [
              {
                "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",
                    "example": "2025-01-02T09:35:39.032Z"
                  },
                  "dateUpdated": {
                    "type": "string",
                    "description": "Date and time when the object was last updated",
                    "format": "date-time",
                    "example": "2025-01-02T09:35:39.032Z"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "SYSTEM_DEFINED",
                      "USER_DEFINED"
                    ],
                    "example": "USER_DEFINED",
                    "description": "Object`s Type — USER_DEFINED for custom objects, SYSTEM_DEFINED for standard objects"
                  }
                },
                "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"
      }
    }
  }
}
```

## HighLevel SDK Examples

**Node.js** (`@gohighlevel/api-client`)

```javascript
import HighLevel from '@gohighlevel/api-client';

const ghl = new HighLevel({
  privateIntegrationToken: '<PRIVATE_INTEGRATION_TOKEN>'
});

const body = {
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "key": "custom_objects.pet",
  "description": "These are non vaccinated pets",
  "locationId": "ve9EPM428h8vShlRW1KT",
  "primaryDisplayPropertyDetails": {
    "key": "custom_objects.pet.name",
    "name": "Pet name",
    "dataType": "TEXT",
    "isUnique": false
  }
};

const response = await ghl.objects.createCustomObject(body);
console.log(response);
```

**Python** (`gohighlevel-api-client`)

```python
from highlevel import HighLevel

client = HighLevel(
    private_integration_token='<PRIVATE_INTEGRATION_TOKEN>'
)

body = {
    "labels": {
        "singular": "Pet",
        "plural": "Pets"
    },
    "key": "custom_objects.pet",
    "description": "These are non vaccinated pets",
    "locationId": "ve9EPM428h8vShlRW1KT",
    "primaryDisplayPropertyDetails": {
        "key": "custom_objects.pet.name",
        "name": "Pet name",
        "dataType": "TEXT",
        "isUnique": false
    }
}

response = await client.objects.create_custom_object(body=body)
print(response)
```

**PHP** (`gohighlevel/api-client`)

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

use HighLevel\HighLevel;
use HighLevel\HighLevelConfig;

$config = new HighLevelConfig([
    'privateIntegrationToken' => '<PRIVATE_INTEGRATION_TOKEN>'
]);
$ghl = new HighLevel($config);

$body = [
    'labels' => [
        'singular' => 'Pet',
        'plural' => 'Pets'
    ],
    'key' => 'custom_objects.pet',
    'description' => 'These are non vaccinated pets',
    'locationId' => 've9EPM428h8vShlRW1KT',
    'primaryDisplayPropertyDetails' => [
        'key' => 'custom_objects.pet.name',
        'name' => 'Pet name',
        'dataType' => 'TEXT',
        'isUnique' => false
    ]
];

$response = $ghl->objects->createCustomObject($body);
echo json_encode($response, JSON_PRETTY_PRINT);
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/objects/' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-07-28' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "key": "custom_objects.pet",
  "description": "These are non vaccinated pets",
  "locationId": "ve9EPM428h8vShlRW1KT",
  "primaryDisplayPropertyDetails": {
    "key": "custom_objects.pet.name",
    "name": "Pet name",
    "dataType": "TEXT",
    "isUnique": false
  }
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-07-28',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "labels": {
        "singular": "Pet",
        "plural": "Pets"
      },
      "key": "custom_objects.pet",
      "description": "These are non vaccinated pets",
      "locationId": "ve9EPM428h8vShlRW1KT",
      "primaryDisplayPropertyDetails": {
        "key": "custom_objects.pet.name",
        "name": "Pet name",
        "dataType": "TEXT",
        "isUnique": false
      }
  })
};

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

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/objects/"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2021-07-28"
}

payload = {
    "labels": {
        "singular": "Pet",
        "plural": "Pets"
    },
    "key": "custom_objects.pet",
    "description": "These are non vaccinated pets",
    "locationId": "ve9EPM428h8vShlRW1KT",
    "primaryDisplayPropertyDetails": {
        "key": "custom_objects.pet.name",
        "name": "Pet name",
        "dataType": "TEXT",
        "isUnique": false
    }
}

response = requests.post(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/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-07-28',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "key": "custom_objects.pet",
  "description": "These are non vaccinated pets",
  "locationId": "ve9EPM428h8vShlRW1KT",
  "primaryDisplayPropertyDetails": {
    "key": "custom_objects.pet.name",
    "name": "Pet name",
    "dataType": "TEXT",
    "isUnique": false
  }
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/objects/")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-07-28")
  .header("Content-Type", "application/json")
  .body("{\"labels\":{\"singular\":\"Pet\",\"plural\":\"Pets\"},\"key\":\"custom_objects.pet\",\"description\":\"These are non vaccinated pets\",\"locationId\":\"ve9EPM428h8vShlRW1KT\",\"primaryDisplayPropertyDetails\":{\"key\":\"custom_objects.pet.name\",\"name\":\"Pet name\",\"dataType\":\"TEXT\",\"isUnique\":false}}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/objects/"
  payload := strings.NewReader(`{
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "key": "custom_objects.pet",
  "description": "These are non vaccinated pets",
  "locationId": "ve9EPM428h8vShlRW1KT",
  "primaryDisplayPropertyDetails": {
    "key": "custom_objects.pet.name",
    "name": "Pet name",
    "dataType": "TEXT",
    "isUnique": false
  }
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2021-07-28")

  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/")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-07-28"
request["Content-Type"] = "application/json"
request.body = '{
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "key": "custom_objects.pet",
  "description": "These are non vaccinated pets",
  "locationId": "ve9EPM428h8vShlRW1KT",
  "primaryDisplayPropertyDetails": {
    "key": "custom_objects.pet.name",
    "name": "Pet name",
    "dataType": "TEXT",
    "isUnique": false
  }
}'

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

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2021-07-28"
}

$body = '{
  "labels": {
    "singular": "Pet",
    "plural": "Pets"
  },
  "key": "custom_objects.pet",
  "description": "These are non vaccinated pets",
  "locationId": "ve9EPM428h8vShlRW1KT",
  "primaryDisplayPropertyDetails": {
    "key": "custom_objects.pet.name",
    "name": "Pet name",
    "dataType": "TEXT",
    "isUnique": false
  }
}'

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