Mr. Garza and the director of his ambulance company protested, to no avail. Mr. Garza grudgingly transferred the patient back to a Mexican ambulance, which did not have trained personnel aboard, both he and the director recalled. Mr. Garza said he showed the patient’s husband how to squeeze an oxygen bag to try to keep his wife alive as she was driven toward a distant Mexican hospital. She died on the way there, the emergency workers said.

Persistent Problems

For at least a decade, families and advocacy organizations have reported lapses in medical care for people in the custody of C.B.P. Complaints filed over the past few years included a mother who gave birth prematurely and was later forced to stay with the baby in a “dirty hold room,” a detainee who was refused access to prescribed heart medication, and a woman who had heavy vaginal bleeding after a sexual assault and was not provided any medical attention.

The number of deaths remains unknown and is perhaps unknowable — the agency until December was not required to independently review or publicly report health-related deaths in its custody. And the consequences of failing to address urgent medical needs often emerge after detainees are quickly passed on to another agency, or released.

In 2015, C.B.P. addressed some of the criticisms by establishing its first nationwide standards on transport and detention. However, the standards are nonbinding — the agency cannot be sued for not following them — and the subject of medical care in detention covers less than a page.

Detention by Customs and Border Protection is intended to be brief — 72 hours or less, according to the standards. However that guideline is often broken. Felipe Gómez Alonzo, the boy who died in December and had influenza, was in his sixth day of detention when he was taken to a hospital, according to a timeline provided by the agency.

At the hospital, Felipe was found to have a 103-degree fever. He was discharged from the emergency room several hours later, and agents took him back to a temporary holding cell at a highway checkpoint. Hours later, as the boy grew sicker, no medically trained agents were on duty there. He was returned to the hospital, but lost consciousness on the way.

“Children should not be held in C.B.P. holding cells longer than 24 hours,” said Kathryn Hampton, a program officer for Physicians for Human Rights and the author of a recent study that found that the focus on securing the border has come at the cost of migrants’ safety.