By/to/within a hair’s breadth/whisker
A metaphor for a very small margin i.e. the breadth or width of a hair dates from the late 1500s and was used by Shakespeare in Merry Wives of Windsor Act IV, Scene II, “I profess requital to a hair’s breadth”. In America, from the early 20th century, whisker has tended to replace hair’s breadth in all its constructions.