Set Custom Field values of a record

PUT/api/custom-fields/values/{relatedTo}/{id}

Creates or updates the custom field values of one record. Only the fields sent in the request are touched, the others keep their current value. Send an empty string to clear a value. Multi value fields (multi_select, checkboxes, multiple_choice) accept either a comma separated string or an array of options.

The record must exist in the given context, otherwise the request is answered with a 404. Every posted value is validated against its field definition before anything is written: a field marked as required cannot be cleared, and the value of a select, multi_select, multiple_choice or checkboxes field must be one of the options of that field. The whole request runs in one transaction, so either every value is saved or none of them is.

Headers

FieldTypeDescription
authtoken String Authentication token, generated from admin area

Parameters

FieldTypeDescription
relatedTo String Context the record belongs to
id Number Unique ID of the record inside that context
values Object Mandatory map of custom field id to value. A list of {"custom_field_id": .., "value": ..} objects is accepted as well.
curl -X PUT "https://yoursite.com/api/custom-fields/values/lead/123" \
  -H "authtoken: YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "values": "..." }'

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "messages": { "success": "Record saved" },
  "data": [
    { "custom_field_id": "3", "title": "Region", "field_type": "select", "value": "North" }
  ]
}

Unknown-Record:

HTTP/1.1 404 Not Found
{ "status": false, "messages": { "error": "No data were found" } }

Unknown-Field:

HTTP/1.1 400 Bad Request
{ "status": false, "messages": { "custom_field_9": "Unknown custom field for the clients context." } }

Invalid-Value:

HTTP/1.1 400 Bad Request
{
  "status": false,
  "messages": {
    "custom_field_3": "Value not allowed. Allowed options: North, South",
    "custom_field_4": "This field is required.",
    "custom_field_5": "The value contains characters or keywords which are not allowed."
  }
}

Save-Failed:

HTTP/1.1 400 Bad Request
{
  "status": false,
  "messages": {
    "error": "None of the custom field values were saved, the whole request was rolled back.",
    "custom_field_3": "Could not be saved."
  }
}
MethodPUT
Path/api/custom-fields/values/{relatedTo}/{id}
GroupCustom Fields
Sincev1.0.0
Defined inRestApi/Controllers/CustomFieldsController.php