Thanks @alban.
Finally I used API method like that you link here but I was searching for a method that create a new custom field for contact/company without calling the API from inside Mautic.
I tried with ORM\ClassMetadata $builder
and something like $builder->createField('my_custom_field', 'text')->nullable()->build();
inside an helper but it doesn’t work.
Thanks anyway.