Get list of custom fields and update their settings programatically
Try this one:

$fields = \Drupal::service('entity_field.manager')-&gt;getFieldDefinitions('contact_message', 'personal');

You can change personal to your contact form bundle.