# Error adding multiselect filters to segments with the API

**URL:** <https://forum.mautic.org/t/error-adding-multiselect-filters-to-segments-with-the-api/29984>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [November 17, 2023, 12:54pm UTC](https://forum.mautic.org/t/error-adding-multiselect-filters-to-segments-with-the-api/29984 "2023-11-17T12:54:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marc\_id](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/marc_id/32/13296_2.png) [@marc\_id](https://forum.mautic.org/u/marc_id)\
**Post date:** [November 17, 2023, 12:54pm UTC](https://forum.mautic.org/t/error-adding-multiselect-filters-to-segments-with-the-api/29984/1 "2023-11-17T12:54:26Z")

</div>

**Your software**  
My Mautic version is: 4.4.10  
My PHP version is: 7.4.33  
My Database type and version is: MySQL 5.7.44

**Your problem**  
I’d like to use the Mautic API to create segments with filters using a multiselect custom field.  
The filters part, as an example, would be like this:  
$filters = array(  
array(  
‘glue’ =\> ‘and’,  
‘field’ =\> ‘my-custom-field’,  
‘object’ =\> ‘lead’,  
‘type’ =\> ‘multiselect’,  
‘operator’ =\> ‘in’,  
‘properties’ =\> array(  
‘filter’ =\> array  
(  
0 =\> 123,  
),  
),  
)  
);  
But when I try to create the segment, the API refuses to do so and returns a error 400: “filter: This value is not valid”.  
I created a segment using the interface with exactly the same filter without error. Then I tried getting the details from the API and found that the filter part is exactly equal to the one I’d like to create using the API, so I don’t understand.

Then I’ve tried a workaround, 1) create the segment without the filter part, 2) add the filter array serialized directly to the lead\_lists table on the database. That worked and the contacts are added as expected BUT when I try to edit the segment filters in the Mautic interface, the value of the multiselect field is empty!

So, is there something wrong I am doing or maybe is a bug of the application?

Thank you.

---

<div class="post-metadata">

**Author:** ![marc\_id](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/marc_id/32/13296_2.png) [@marc\_id](https://forum.mautic.org/u/marc_id)\
**Post date:** [December 13, 2023, 10:45am UTC](https://forum.mautic.org/t/error-adding-multiselect-filters-to-segments-with-the-api/29984/2 "2023-12-13T10:45:56Z")

</div>

Anyone have any ideas about this? I appreciate anyone’s advice.
