Peloton’s CEO said his company was protecting consumer privacy when it refused for nearly a month to give the name of a child killed in a treadmill accident to federal safety investigators.

“At no time was Peloton trying to impede CPSC’s investigation,” chief executive John Foley wrote in a letter sent Sunday to the in-home workout equipment company’s millions of customers.

But that is exactly what happened, according to officials with knowledge of the Consumer Product Safety Commission’s investigation.

The agency’s leaders were forced to vote to issue an administrative subpoena last week, requiring Peloton to hand over the information, the officials said.

“We tried to get them to give us the name of the family for several weeks,” said an official who spoke on the condition of anonymity to discuss the agency’s ongoing inquiry.

The official added, “This was not a friendly subpoena.”

The fight over identifying the child for federal authorities captures the unusually confrontational and public nature of the ongoing safety investigation involving Peloton’s Tread+ treadmill, which has been tied to 39 incidents involving children, objects and one pet being trapped under the machine. One child was killed. Others suffered injuries, including a brain injury and broken bones.

The two sides spent weeks trying to strike a deal on how to respond to the accidents. A Washington Post report published Friday detailed how Peloton declined to voluntarily recall the treadmill and clashed with the agency over the wording of a proposed safety notice. The next day, the CPSC issued a public warning calling the Tread+ dangerous and telling people with small children or pets to stop using it.

Peloton responded with a statement calling those claims “misleading” and “inaccurate.”

The stakes are high for Peloton, and its tactics potentially risky. Its line of high-end stationary bicycles and treadmills — combined with online workout classes — has boomed during the pandemic.

On Monday, after the dispute with the CPSC was announced, Peloton’s stock price fell 7 percent.

Yet Peloton appeared unlikely to back down from its fight with regulators.

Foley said in his letter Sunday that the company had “no intention” of agreeing to a product recall, appearing to rule one out even if safety investigators find evidence of a problem. Peloton’s earlier refusal of a voluntary recall means the agency must file a lawsuit if it wants to force a recall without the company’s cooperation.

Peloton’s approach toward the treadmill accidents has puzzled longtime safety advocates such as Nancy Cowles, executive director of Kids in Danger.

Cowles said she had talked with Peloton officials earlier this year about a company TV ad that inadvertently showed an unsafe crib in the background. She asked them to remove it. They agreed. She said she came away with the impression that the company prioritized safety.

Cowles said she was surprised to see Peloton clash with the CPSC over the treadmill accidents and then claim privacy was the reason the company at first refused to disclose the name to regulators.

“If you’re withholding information from them, you’re really impeding their ability to keep other consumers safe,” Cowles said. “The days that you’re waiting to get more information are days that consumers are unaware running on that thing.”

She was also surprised to see Foley in his letter hint that some customers might want their information kept private to avoid online harassment.

“I imagine some [customers] asked for their information to be protected in order to avoid personal attacks like some that we’ve seen in response to the Tread+ incidents that CPSC publicized yesterday,” Foley said.

There was no indication that CPSC investigators disclosed the customers’ identities.

A timeline of events leading up to CPSC’s safety warning was shared with The Post on Monday. A Peloton spokesman confirmed the dates.

Peloton first notified regulators about the death, as required by law, on March 4. It was one day after the company first learned of the accident.

Five days later, the CPSC asked for a full report on the incident to be filed within two weeks.

Just over a week later, on March 18, Foley posted a public letter about the fatal accident and “a small handful of incidents involving the Tread+ where children have been hurt.”

Foley’s letter did not mention the federal safety inquiry. And the CPSC did not know the letter was coming.

The next day, the agency asked for a complete list of incidents and contact information for families.

Ten days later, on March 29, Peloton handed over all of the information except for information on the family involved in the fatal incident. Peloton also did not name the family’s attorney, who also asked not to be named.

After attempting to persuade Peloton to share the information voluntarily, the CPSC’s four commissioners voted April 12 to subpoena the information from Peloton, giving the company 24 hours to comply. Peloton did.

Days later, the CPSC issued its safety warning.

Foley, in his letter Sunday, framed Peloton’s withholding of information as a privacy issue. He said the family asked the company not to give the information to the CPSC.

“Government agencies shouldn’t have unfettered access to consumers’ private information,” Foley wrote, “and I am proud that we took a stand to protect these [customers’] privacy.”

Cowles said Peloton’s actions raised doubts about the company’s focus on safety. She pointed to Foley’s claim in his letter that the Tread+ “is safe when our warnings and safety instructions are followed.”

That sounded to her like Peloton was deflecting blame, she said. Cowles compared it to how car companies once responded to accidents involving children killed by vehicles backing out of driveways.

“You could say, ‘You shouldn’t have your kids in the driveway.’ And that is what people said for years,” Cowles said. “But now we have backup cameras.”