Recycling of internalized receptors from endosomal compartments is essential for the receptors' cell-surface homeostasis. Sorting nexin 27 (SNX27) cooperates with the retromer complex in the recycling of proteins containing type I PSD95-Dlg-ZO1 (PDZ)-binding motifs. Here we define specific acidic amino acid sequences upstream of the PDZ-binding motif required for high-affinity engagement of the human SNX27 PDZ domain. However, a subset of SNX27 ligands, such as the β2 adrenergic receptor and N-methyl-D-aspartate (NMDA) receptor, lack these sequence determinants. Instead, we identified conserved sites of phosphorylation that substitute for acidic residues and dramatically enhance SNX27 interactions. This newly identified mechanism suggests a likely regulatory switch for PDZ interaction and protein transport by the SNX27-retromer complex. Defining this SNX27 binding code allowed us to classify more than 400 potential SNX27 ligands with broad functional implications in signal transduction, neuronal plasticity and metabolite transport.