Mayor Bill de Blasio has an opening on his personal security detail — and the candidate has to be black, The Post has learned.

The head of Hizzoner’s protection unit — staffed by a racially diverse group — has been calling other commanders asking for recommendations, law enforcement sources said.

“A boss on his security detail is looking to recruit a new sergeant but they have to be the right racial makeup. He is looking for a sergeant but the sergeant has to be black,” a source told The Post.

“We all know where [the order is] coming from,” the source said, suggesting the security head was acting at the mayor’s behest.

De Blasio has infuriated the NYPD with his race-based criticism in the wake of a grand jury’s decision to not indict a white police officer in the death of Eric Garner, a black man who died July 17 while resisting arrest on Staten Island.

The mayor said he and his wife have taught their mixed-race son, Dante, about the “dangers” posed to young black men by biased cops.