Custom fields
Define the extra fields your companies, persons and deals carry, and read and write their values.
On this page
A custom field is a field you add to one kind of record: company, person or deal. It has a key, a label that people see and a type. Every record of that kind then carries customFields, an object with the values by key.
Types
| Type | A value is |
|---|---|
text | Text. |
decimal | A decimal string, for example "12.50". |
date | A day, YYYY-MM-DD. |
choice | One of the options of the field. |
Define a field
The key is lower case letters, digits and underscores, and starts with a letter. A choice field names its options.
curl
curl -X POST "$RDC_BASE_URL/crm/v1/custom-fields" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "95242917-1d3d-49e3-97c6-c26acc3318fa",
"entity": "company",
"key": "delivery_days",
"label": "Delivery days",
"type": "text"
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/custom-fields`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "95242917-1d3d-49e3-97c6-c26acc3318fa",
"entity": "company",
"key": "delivery_days",
"label": "Delivery days",
"type": "text"
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/crm/v1/custom-fields',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '95242917-1d3d-49e3-97c6-c26acc3318fa',
'entity': 'company',
'key': 'delivery_days',
'label': 'Delivery days',
'type': 'text',
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "95242917-1d3d-49e3-97c6-c26acc3318fa",
"entity": "company",
"key": "delivery_days",
"label": "Delivery days",
"type": "text"
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/custom-fields');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/custom-fields");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "95242917-1d3d-49e3-97c6-c26acc3318fa",
"entity": "company",
"key": "delivery_days",
"label": "Delivery days",
"type": "text"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "95242917-1d3d-49e3-97c6-c26acc3318fa",
"status": "accepted",
"aggregateRevision": 1
} Write a value
Send the values in customFields when you create a record. A company can also change them with Update a company. A key that is not a field of that kind of record is refused with custom_field_unknown, and a value that does not fit its field with custom_field_invalid.
curl
curl -X PATCH "$RDC_BASE_URL/crm/v1/companies/61d54dde-e1f3-43da-b2fc-a4a21540e5f3" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "412dcfb7-fd2e-4f1e-9506-5e798a98c0a6",
"expectedRevision": 1,
"customFields": {
"delivery_days": "Tuesday and Friday"
}
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/companies/61d54dde-e1f3-43da-b2fc-a4a21540e5f3`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "412dcfb7-fd2e-4f1e-9506-5e798a98c0a6",
"expectedRevision": 1,
"customFields": {
"delivery_days": "Tuesday and Friday"
}
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'PATCH',
f'{os.environ["RDC_BASE_URL"]}/crm/v1/companies/61d54dde-e1f3-43da-b2fc-a4a21540e5f3',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '412dcfb7-fd2e-4f1e-9506-5e798a98c0a6',
'expectedRevision': 1,
'customFields': {
'delivery_days': 'Tuesday and Friday',
},
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "412dcfb7-fd2e-4f1e-9506-5e798a98c0a6",
"expectedRevision": 1,
"customFields": {
"delivery_days": "Tuesday and Friday"
}
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/companies/61d54dde-e1f3-43da-b2fc-a4a21540e5f3');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Patch, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/companies/61d54dde-e1f3-43da-b2fc-a4a21540e5f3");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "412dcfb7-fd2e-4f1e-9506-5e798a98c0a6",
"expectedRevision": 1,
"customFields": {
"delivery_days": "Tuesday and Friday"
}
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "412dcfb7-fd2e-4f1e-9506-5e798a98c0a6",
"status": "accepted",
"aggregateRevision": 2
} List custom fields returns the fields of one kind of record, so that a form or an import knows what to send.