convert codes to two new apis: codes and code_ids