# Where is the API "add custom field to contact" controller?

**URL:** <https://forum.mautic.org/t/where-is-the-api-add-custom-field-to-contact-controller/15190>\
**Category:** Development\
**Tags:** development\
**Created:** [July 14, 2020, 8:39am UTC](https://forum.mautic.org/t/where-is-the-api-add-custom-field-to-contact-controller/15190 "2020-07-14T08:39:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robdex](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/robdex/32/1352_2.png) [@robdex](https://forum.mautic.org/u/robdex)\
**Post date:** [July 14, 2020, 8:39am UTC](https://forum.mautic.org/t/where-is-the-api-add-custom-field-to-contact-controller/15190/1 "2020-07-14T08:39:50Z")

</div>

Hello.  
I’m trying to add custom fields programmatically with a custom plugin using API library (I was looking for pure programmatic insert method without success: [add new custom field into lead table](https://forum.mautic.org/t/add-new-custom-field-into-lead-table/9302/5)).

The API route **`/api/fields/contact/new`** it’s almost ok, but **`alias`** field, that’s is a key field, is limited to 26 chars and the insert truncate it, despite the db fields is varchar(255).  
I’m trying to debug this insert in order to use more chars.

Someone knows which is the Controller for that url? Or know a solution in order to add custom fields programmatically managing all the necessary fields without this chars limit?

Mautic version is: 2.16.0  
PHP version is: php72-fpm

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![robdex](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/robdex/32/1352_2.png) [@robdex](https://forum.mautic.org/u/robdex)\
**Post date:** [July 14, 2020, 12:19pm UTC](https://forum.mautic.org/t/where-is-the-api-add-custom-field-to-contact-controller/15190/2 "2020-07-14T12:19:56Z")

</div>

Ok, I’ve found the Controller:

> `app/bundles/ApiBundle/Controller/CommonApiController.php`

It makes a form submission but I haven’t found where the process truncate `alias` string to 25 chars, even if I’ve changed (to test the submission) the value from 25 to 100 in his template:

> `app/bundles/LeadBundle/Form/Type/FieldType.php: line 450`

How to remove this limit?

Thank you.

---

<div class="post-metadata">

**Author:** ![syrok](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/syrok/32/6601_2.png) [@syrok](https://forum.mautic.org/u/syrok)\
**Post date:** [January 4, 2022, 8:22pm UTC](https://forum.mautic.org/t/where-is-the-api-add-custom-field-to-contact-controller/15190/3 "2022-01-04T20:22:09Z")

</div>

I think need to update

> <https://github.com/mautic/mautic/blob/0abd6b79738f7cf096b435d8f87ea998617e17c1/app/bundles/LeadBundle/Helper/FieldAliasHelper.php#L45>
