@MarceloCP You can refer this example.
@Autowired
private FilterService filterService;
public void createUnassignedTaskFilter(String processDefinitionKey) {
TaskQuery taskQuery = taskService.createTaskQuery().processDefinitionKey(processDefinitionKey).taskUnassigned();
Filter newFilter = new FilterEntity(ResourceTypes.RUNTIME.getName());
newFilter = newFilter.setName("unassigneTaskFilter").setQuery(taskQuery);
Filter savedFilter = filterService.saveFilter(newFilter);
log.info("Unassigned task filter created: {}", savedFilter.getName());
}