# Create Record

POST https://services.leadconnectorhq.com/objects/{schemaKey}/records

Create a Custom Object Record. Supported Objects business and custom objects. Documentation Link - https://doc.clickup.com/8631005/d/h/87cpx-277156/93bf0c2e23177b0/87cpx-376296

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `schemaKey` | string | Yes | The key of the Custom Object / Standard Object Schema. For custom objects, the key must include the “custom_objects.” prefix, while standard objects use their respective object keys. This information is available on the Custom Objects Details page under Settings. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/objects/{schemaKey}/records": {
      "post": {
        "summary": "Create Record",
        "operationId": "createRecord",
        "description": "Create a Custom Object Record. Supported Objects business and custom objects. Documentation Link - https://doc.clickup.com/8631005/d/h/87cpx-277156/93bf0c2e23177b0/87cpx-376296",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "schemaKey",
            "required": true,
            "in": "path",
            "description": "The key of the Custom Object / Standard Object Schema. For custom objects, the key must include the “custom_objects.” prefix, while standard objects use their respective object keys. This information is available on the Custom Objects Details page under Settings.",
            "schema": {
              "example": "custom_objects.pet or business.email (for company's email)",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomObjectRecordDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordByIdResponseDTO"
                }
              }
            }
          },
          "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": [
              "objects/record.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": {
      "CreateCustomObjectRecordDto": {
        "type": "object",
        "properties": {
          "locationId": {
            "type": "string",
            "description": "Location Id",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "properties": {
            "type": "object",
            "additionalProperties": true,
            "description": "Properties of the custom object record. Keys are the object field names; values are the field values (string, number, or a monetary { currency, value } object).",
            "example": {
              "pet_name": "Cat",
              "pet_age": 10
            }
          }
        },
        "required": [
          "locationId",
          "properties"
        ],
        "title": "CreateCustomObjectRecordDto"
      },
      "RecordByIdResponseDTO": {
        "type": "object",
        "properties": {
          "record": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "661c06b4ffde146bdb469442",
                "description": "id of the record"
              },
              "owner": {
                "description": "Owner (User's id). Limited to 1 for now. Only Supported with custom objects",
                "example": [
                  "sx6wyHhbFdRXh302Lunr"
                ],
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "followers": {
                "description": "Follower (User's ids). Limited to 10 for now",
                "example": [
                  "sx6wyHhbFdRXh302Lunr",
                  "v5cEPM428h8vShlRW1KT"
                ],
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "properties": {
                "type": "string",
                "example": {
                  "customer_number": 1424,
                  "ticket_name": "Customer not able login",
                  "phone_number": "+917000000000",
                  "money": {
                    "currency": "default",
                    "value": 100
                  },
                  "type_of_ticket": "doubt",
                  "section_of_app": [
                    "contacts",
                    "smartlist"
                  ],
                  "recieved_on": "2024-07-11",
                  "my_files": [
                    {
                      "url": "---url_of_file---"
                    }
                  ],
                  "my_textbox_list.option_a": "Value 1",
                  "my_textbox_list.option_b": "Value 2"
                },
                "description": "Properties of the record"
              },
              "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": [
              "id",
              "owner",
              "followers",
              "properties",
              "dateAdded",
              "dateUpdated"
            ],
            "title": "IRecordSchema"
          }
        },
        "title": "RecordByIdResponseDTO"
      },
      "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 POST 'https://services.leadconnectorhq.com/objects/<schemaKey>/records' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "locationId": "ve9EPM428h8vShlRW1KT",
  "properties": {
    "pet_name": "Cat",
    "pet_age": 10
  }
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "locationId": "ve9EPM428h8vShlRW1KT",
      "properties": {
        "pet_name": "Cat",
        "pet_age": 10
      }
  })
};

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

**Python**

```python
import requests

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

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

payload = {
    "locationId": "ve9EPM428h8vShlRW1KT",
    "properties": {
        "pet_name": "Cat",
        "pet_age": 10
    }
}

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/<schemaKey>/records',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "locationId": "ve9EPM428h8vShlRW1KT",
  "properties": {
    "pet_name": "Cat",
    "pet_age": 10
  }
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/objects/<schemaKey>/records")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"locationId\":\"ve9EPM428h8vShlRW1KT\",\"properties\":{\"pet_name\":\"Cat\",\"pet_age\":10}}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/objects/<schemaKey>/records"
  payload := strings.NewReader(`{
  "locationId": "ve9EPM428h8vShlRW1KT",
  "properties": {
    "pet_name": "Cat",
    "pet_age": 10
  }
}`)
  req, _ := http.NewRequest("POST", 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/<schemaKey>/records")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "locationId": "ve9EPM428h8vShlRW1KT",
  "properties": {
    "pet_name": "Cat",
    "pet_age": 10
  }
}'

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

**PowerShell**

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

$body = '{
  "locationId": "ve9EPM428h8vShlRW1KT",
  "properties": {
    "pet_name": "Cat",
    "pet_age": 10
  }
}'

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