Junior The
Calgary Hitmen of the
Western Hockey League (WHL) selected Sanheim in the ninth round, 177th overall, of the 2011
WHL Bantam Draft. He debuted with the team for the
2013–14 season and had a difficult adjustment period, coupled by a late
growth spurt, that limited Sanheim to only three points through his first 21 games of the season. That summer, the
Philadelphia Flyers of the
National Hockey League (NHL) selected Sanheim in the first round, 17th overall, of the
2014 NHL entry draft. Sanheim attended both the Flyers' rookie and general training camps in 2014, and appeared in one preseason game, before returning to Calgary for the
2014–15 WHL season. He also signed an
entry-level contract with Philadelphia just before the WHL and NHL seasons began. His sophomore season in the WHL proved to be a breakout, with 15 goals and 65 points in 67 games. Although he led all defencemen with 39 points through the first 41 games of the season, Sanheim found additional success starting in January when he was paired with
Jake Bean, another offensively-minded defenceman. Through the remainder of their respective junior hockey careers, Sanheim and Bean served as primary scorers, as well as
penalty killers, for a team that often lacked elite
forwards. In the postseason, Sanheim scored the game-winning, double-overtime goal for the Hitmen to advance them past the
Medicine Hat Tigers and into the Eastern Conference Finals for the
Ed Chynoweth Cup. The
Brandon Wheat Kings ultimately defeated the Hitmen in five games of the conference finals. With a number of the Hitmen's playoff core leaving the team for the NHL just before the
2015–16 season, Sanheim, who was returned to the team after another training camp with Philadelphia, became a veteran presence for Calgary. He led all WHL defencemen in scoring with 22 points through the first 18 games of the season before suffering an upper-body injury in a game against the
Prince Albert Raiders at the start of November. He missed nearly the entire month, returning on November 30 with a goal and an assist in a 4–3 overtime loss to the
Regina Pats. Sanheim missed another stretch of games at the turn of the calendar year, during which time he was representing
Canada at the
2016 World Junior Ice Hockey Championships. In his absence, Calgary appointed his twin brother Taylor as a temporary
alternate captain. Despite missing a total of 15 regular season games, Sanheim finished his final season of junior hockey with 15 goals and 68 points, and he led all
Canadian Hockey League (CHL) defencemen in points per game.
Professional After the Hitmen's season ended, Sanheim joined the Flyers'
American Hockey League (AHL) affiliate, the
Lehigh Valley Phantoms, for the final stretch of their
2015–16 season. He appeared in four games for the Phantoms, recording three points in the process. Sanheim returned to the Phantoms for the
2016–17 AHL season, where he and his defensive partner
Samuel Morin worked with assistant coach
Kerry Huffman in order to heighten the physical aspect of their game for an older, larger group of skaters. While Sanheim's offensive abilities were already strong from his junior career, his work with Huffman helped Sanheim to develop his overall game. He did not score a goal until December, but through 63 games, Sanheim had both scored 10 goals and 29 points and he carried a +7 plus-minus. He finished the year with 10 goals and 37 points in 76 AHL games. All but one of these goals were at
full strength, as
T. J. Brennan was the Phantoms' main
power play defenceman. Sanheim made Philadelphia's final roster out of training camp and started the
2017–18 season in the NHL. He scored his first NHL goal on December 14, 2017, in his 28th NHL game, to help the Flyers defeat the
Buffalo Sabres 2–1. He was reassigned to Philadelphia's
American Hockey League (AHL) affiliate, the
Lehigh Valley Phantoms, on January 22, 2018, but was later recalled on March 9 due to an injury to
Robert Hägg. Sanheim made his
Stanley Cup playoff debut during the first round of the
2018 playoffs against the
Pittsburgh Penguins. He recorded his first career playoff goal on April 15 in a 5–1 loss to the Penguins. The Flyers ended up losing to the Penguins in six games, after which Sanheim was loaned to the Phantoms to help them with their run in the
2018 Calder Cup playoffs. On June 24, 2019, Sanheim signed a new two-year, $6.5 million contract. Sanheim and his defensive mate
Philippe Myers were two of the young Flyers to struggle in the protracted
2020–21 season, during which Philadelphia went 25-23-8. The loss of veteran presence in
Matt Niskanen particularly affected many of the team's young defenders, as
Alain Vigneault struggled to find a stable top pairing for
Ivan Provorov. Sanheim was also the first Flyer to test positive for the COVID-19 virus during a team outbreak that February. Although he did not experience any significant symptoms, he was forced to isolate from February 7 to 18. The 2020–21 season proved to be the worst of Sanheim's career thus far, as he dropped to only three goals, 15 points, and a –22 rating while skating in all but one of the 56 games in the shortened season. Although statistically Sanheim's defensive performance was similar to seasons prior, his mistakes tended to be costlier during the 2020–21 season, with his turnovers and positioning leading more often to goals against than they had earlier in his NHL career. Sanheim, a restricted free agent going into the
2021–22 season, successfully avoided contract arbitration on August 21, when he signed a two-year contract extension that carried an average annual value of $4.675 million. As Myers had been traded to the
Nashville Predators over the summer, Sanheim's new partner on the second defensive line was
Rasmus Ristolainen, who the Flyers had received in a trade with the
Buffalo Sabres. On October 13, 2022, Sanheim signed an 8-year, $50 million extension that would keep him in Philadelphia through 2031. ==International play==