It seems our documentation needs a little work in order to be more clear. We’ll work to update that. In the meantime, I hope the following helps.
Custom fields are only available for individual contacts via Retrieve a Contact, using optional_properties. List Contacts does not accept optional_properties and does not return custom fields.
For anyone else who stumbles across this thread trying to figure out how to update or retrieve custom_fields via the REST API. It took me a while to figure out but it does work and works well.
When you start digging around information in your IS instance settings looking at custom fields you’re going to come across this text link: View the field database names (for the API). The info you get in this popup I think refers only to the older XML methods, so if you’re using the REST API and JSON this isn’t for you.
First off you need to find out information about your custom fields. SO assuming you have at least one custom field set up, put some test text in it that you’ll recognise and head over to the developer rest API here: Keap REST API
You want to use the ‘Contact > Retrieve a contact’ method, and in the parameters > optional properties field input ‘custom_fields’ (I am also assuming you have a client id and secret set up in mashery so that you can try the interactive api docs - otherwise head over there and set that up first). The result displayed here will give you the IS unique id for each custom field you have set up in your instance as well as the value assigned currently.
Now you know what the id is you can format your Rest Request parameters. The correct format is as follows:
Unfortunately we do not have Custom Fields enabled on all endpoints, but it’s possible to use your same Access Token to call the XML-RPC API and get the data from the DataFormFields (internal name for Custom Fields).
Is there a way, currently, to update a contact’s “optional_properties”? I am able to retrieve a contact’s optional properties, but have not figured out a way to update them via the api.
Specifically I am looking to update “company_name” which is listed under optional_properties. It doesn’t have the same structure as custom_fields so there must be a different way to update this via the api.