let storageId =123let filter = { name:"my first filter", type :"SEGMENT", dimension_indexes:[1],// add column index 1 (postal code in example) in the stats file column_filter:[ // filter on column value { column_index:1,// index 1, postal code in example values:["54","67","57","68"],// postal code must start with this values operator:"PREFIX"// indicate type of filter: EQUAL,PREFIX etc, see reference not:false// if true reverse the condition (here, must not start with selected values) } ] segment_filter:{ segment: [{id:456}, {id:789}],// count for hash in segment 456 or 789 }}fetch("https://gateway.sirdata.io/api/v1/public/customer/storage/"+storageId+"/filter?=", {"method":"POST","headers": {"Content-Type":"application/json","x-api-token":"XXXXX-XXXXX-XXXXX-XXXXX", },"body":JSON.stringify(filter)}).then(response => {console.log(response);}).catch(err => {console.error(err);});
If response status code is 202 then proceed to get filter object each x seconds to check status until ERROR or OK
segment_name,segment_id,countSirdata [Interest] Ecology & Environment,14,375921Sirdata [Interest] Auto & Vehicles > Electric Cars,1293,88115Sirdata [Intent] Life Events > Home Movers,578,52699Sirdata [Inferred] Life Events > Home Movers,2381,51828Sirdata [Intent] Auto & Vehicles > Electric Cars,599,38929