move 221 handling into central API code