Skip to content

Create a custom field

Request to create a new custom field:

POST /api/v2/custom_fields.json

The request body contains the custom field object. name and type are required. Attributes that are not included take their default values. When tenant_id is omitted, the field is created in the tenant of the API user.

For example, a drop-down field:

{
    "custom_field": {
        "name": "Call type",
        "computer_name": "call_type",
        "description": "Type of the call, like Sales, Collection, etc.",
        "type": "option",
        "enable": true,
        "editable": true,
        "fieldset_dropdown_value_settings": {
            "options": [
                {"value": "Sales call", "color": "#00AA00"},
                {"value": "Collection call", "color": ""}
            ]
        }
    }
}

A number field with value buckets:

{
    "custom_field": {
        "name": "CSAT",
        "type": "integer",
        "enable": true,
        "editable": false,
        "dashboard": true,
        "fieldset_integer_value_settings": {
            "int_min": 1,
            "int_max": 5,
            "aggregate": "avg",
            "fieldset_thresholds": {
                "thresholds": [
                    {"op": "ge", "value": 4, "label": "Satisfied", "color": "#00AA00"},
                    {"op": "le", "value": 2, "label": "Dissatisfied", "color": "#AA0000"}
                ]
            }
        }
    }
}

Response contains HTTP status code as shown in the following table.

Response Description
201 Created

The custom field has been successfully created. The Location header and the response body contain the URL of the new field:

HTTP/1.1 201 Created
Location: /api/v2/custom_fields/e011c408-f288-11e4-9b73-e03f497dbdff.json

{"url": "/api/v2/custom_fields/e011c408-f288-11e4-9b73-e03f497dbdff.json"} | | 400 Bad Request |

The request cannot be completed because the supplied JSON object has invalid data.

The response contains a detailed description of the error, like:

{"error": "InvalidRecord", "explanation": "Record Validation errors", "details": {"fieldset_text_value_settings.display_as": "\"invalid\" is not one of default, label, multiline"}}
| | 403 Forbidden | The request cannot be completed because API user has no permission to create custom fields |