(CNN) One morning last August, David, a 16-year-old from Guatemala, was awakened at 3 a.m., handed a snack, and told to get dressed quickly.

Nobody would tell him what was happening. But the day before, at the unaccompanied children's shelter in Phoenix where he'd been for a week, David had heard that five residents were to be turned over to their families that day. David had been trying to reach his uncle in the US for three weeks, since fleeing threats against his life at home. His family had paid smugglers nearly $4,700 to get him to the Mexican border with Arizona, he said, where he'd walked through the desert and was caught by Border Patrol agents.

Now, maybe his journey was ending. "I was happy, because I thought, 'Oh, I'm going to be reunified with my family,'" David recalled.

But when he found himself the only child in a van to the airport, fear began to take hold.

"I asked, "Where am I going? Where are you taking me to? I thought, because of my experience in my country, that they might be kidnappers, that they might want to hurt me." All he could think was that he needed to find some way to escape and find a police officer, he said.

Only later would David discover that the Office of Refugee Resettlement (ORR) was moving him across the country to a higher-security facility for youths with behavioral issues or a history of violence -- without explanation, in the dead of night.

David, now 17, spent more than nine months caught up in the system of shelters and higher-security facilities run by the ORR. He is one of few children to emerge to describe this troubled American system, where undocumented youths and unaccompanied migrant minors -- a group that surged in number during the Obama years -- have recently been joined by more than 2,300 children separated from their parents in accordance with the Trump administration's "zero-tolerance" policy.

David, by his account, was assaulted by other detainees. He says he was given psychotropic medications that he felt he had no choice but to take. His accounts of the dangers he fled and the fears he felt were used against him, he alleges, to send him to higher-security facilities -- and ultimately to lock him up with dangerous offenders in a juvenile prison despite his record of good behavior. He says he witnessed residents being forcibly injected with drugs, and others being tied up in restraint chairs for hours with cowls over their heads. He was stuck in the final facility for months before his case reached an immigration judge, who found that David didn't pose a danger to himself or others.

To protect him against possible retaliation from immigration officials as his asylum case moves forward, CNN agreed not to use his full name, and to avoid certain details that would identify him too specifically. The relevant court records are sealed, and some details of his account could not be independently corroborated.

The biggest issue for David and other youths, said attorney Becky Wolozin of the Legal Aid Justice Center in Falls Church, Virginia, who works with undocumented minors in the system, is that "there is no confidentiality," when they speak with case workers or therapists. "They... almost never say 'anything you tell me can be used to put you into a secure [facility] or a jail," Wolozin said.

Attorney Becky Wolozin, of the Legal Aid Justice Center in Falls Church, Va., works with undocumented minors in the system.

ORR did not immediately respond to CNN's request for comment. ORR policy , updated this spring after a federal court ordered the release of a youth in custody, requires those providing care to tell each minor, before the initial intake assessment, "that self-disclosure of previously unreported criminal history or violent behavior to any other children, care provider, staff, ORR, or others, may result in the child's transfer to another care provider facility and may affect their release."

Asked about how counselors use information provided by minors, Southwest Key Programs, which operates 26 shelters, including the one David first entered, responded with a statement that read in part: "When a child arrives at our shelter, we immediately begin working to safely reunify them with a family member or a family sponsor. Any conversations between children and staff, including counselors and case managers, are to facilitate this process and to provide them with compassionate care while they are under our care." It directed further questions to ORR.

When David first entered an ORR-contracted shelter in Phoenix, he says the therapist he was assigned told him that, to speed up reunification, he should tell her in detail why he had fled from his small town in northern Guatemala and what had happened there that gave him such terrible nightmares.

"She told me she was going to help me, hopefully make things better for me," David said in an interview Monday. Instead, he would find out later, the therapist wrote a report to ORR. Based on his account of being exposed to deadly violence, officials at ORR decided to move him to what's termed a "staff secure" facility on the East Coast, one with many more restrictions.

Only once he was on the plane did David learn where he was going.

"The man who was accompanying me -- I said to him, 'look, can you, can't you tell me anything about where we're going, before I make a mistake and do something I shouldn't do. ... That was when he told me that his job was to move kids... and that's what he was doing, and that I was not going to be reunified with my family. That he was to take me to a higher-security facility."

At the second facility, David said he was assigned a case manager who told him that he should tell him everything about what had happened to him and how he felt. David told the case manager about how afraid he'd been when he was moved, how he had feared he was being kidnapped and had thought of trying to run to a police officer.

He was labeled a flight risk, he said, and immediately restricted for a week, not allowed to go outside with the other boys to play soccer or basketball. They were ages 12 to 17. Some had crossed the border unaccompanied, like him; others had lived in the US for years after being brought in illegally by their parents when they were much younger.

David still hoped he would be out and reunited with his uncle quickly.

"My case manager and my therapist told me that I was going to get out, that I was going to be reunified with my family. And that if I behaved well for 30 days, that they would be able to move me back down to a regular shelter," he said, "and that from there I'd be able to reunify with my family."

David, 17, who says he fled Guatemala after death threats, is speaking out about his months caught in the federal detention system for undocumented minors. CNN agreed not to use his full name to protect him from possible retaliation as his asylum case moves forward.

"I behaved well, but that never happened. They never moved me to a lower-level facility."

They explained to him that the process was complicated. His uncle, as his sponsor, would have to have home visits, a background check, submit fingerprints.

Meanwhile, David said, he was put on anti-anxiety medications. He added that, eight times in the four months he was there, he was taken to the infirmary to get injections. He said he wasn't told what they were for.

"I said that, 'I don't like injections.' And they said, 'Well, if we don't give you these injections, we're going to write a report to the government and that will affect your case.'"

David said he only discovered later, when he saw his records, that a case was being built against him.

"They would take very simple events and make them into something. They'd make these long reports about them. And it could be something very simple... at one point I had a pen and I drew on my hand. And they said that I was trying to cut my veins. I was writing a word, like, Dios mio (my God)."

The second shelter declined to respond to a query about the treatment of minors, referring any questions to ORR.

Four months on, David was moved without explanation again -- this time to one of the highest-security facilities in the ORR system. "It was like a prison," he said. The staff were uniformed guards with walkie-talkies and handcuffs on their belts. The teens were locked into individual cells that could only be opened from outside, each small room holding a bed, a toilet, and a small window with thick glass, he said.

David said he later learned the reason for the move. "When... they showed me my record, I saw that I had been accused of being a gang member, which was not true, because I had never been a gang member. I had never been in any kind of a gang. I don't know why this was in there, where that came from."

This facility housed two separate groups: undocumented migrant teens and US citizens sent to juvenile detention for criminal and violent behavior. Far more than at the other shelters, David said, he feared some of the other residents.

Assaults and fights were frequent, especially when the two groups mingled for activities, he said. He was assaulted and bloodied several times.

"When I was hit, I never defended myself," he said. He quickly saw what happened to those who did. "If they defended themselves -- the officials would just say, 'Oh, well, he was fighting.' And if you're fighting, then they would detain you for longer. They would put you in higher security. There would be other repercussions. So I just decided not to defend myself."

David continued the anti-anxiety medication from the staff secure facility. But he was given others, too, that he said made him feel sleepy much of the time.

"If you didn't take it, they could write you up," he said. Worried that might further delay his reunification, he took whatever drugs they gave him.

Often, teenagers frustrated by their detention, suffering from depression and anxiety, acted out in ways that got them in trouble, David said. If someone refused to come out of his cell, guards would force their way in and drag the boy out, he said.

"For those kids who were really acting out, they would tie them to a chair. They would bind their ankles. They would bind their wrists. They would have a belt that would go around the waist. They would put a mask over their head and they would forcibly give them injections," he said. Sometimes the youth would be left in the restraint in the hallway, in view of the boys in the other cells. Sometimes, the guards would carry the youth, restrained in the chair, out of sight. His account of the high-security facility's use of restraint chairs matched other first-hand statements made by minors in ORR facilities, in a recent legal motion arguing that the terms of the Flores agreement , a 1997 settlement about the treatment of detained immigrant minors, had not been upheld.

Asked about these allegations, a spokesperson for the facility responded that "[We] may not legally, nor do we practice forcibly medicating residents. A resident may refuse medical treatment, including medication, at any time." She also said that there have been no "incidents" between local and ORR residents since last fall, and that "[t]he current practice is that ORR and local residents receive separate programming; they do not intermingle. Incidents that take place among local residents or ORR residents are responded to immediately and in keeping with ensuring a safe environment for all residents in our care."

She added, "Decisions regarding security levels and placement of the ORR residents are made by ORR staff and leadership; they are not made by [our] staff."

Finally, this spring, after a lawyer got involved in his case, an immigration judge found that David didn't pose a danger to himself or others. David was released to his uncle, with whom he now lives.

Under the 2008 William Wilberforce Trafficking Victims Protection Reauthorization Act , the Department of Health and Human Services, which includes ORR, is required to ensure that unaccompanied children "be promptly placed in the least restrictive setting that is in the best interest of the child."

The Flores motion and legal challenges to Trump's restrictive immigration policies have shed light on a system that had seen numerous allegations of abuse even before his election. "This is a system that operates in the shadows," said Elissa Steglich, a clinical professor at the University of Texas Immigration Clinic in Austin, which primarily works with detained parents and families. "The agency and many of these facilities aren't used to working in a transparent way. They haven't even been pushed to do so."

It's no longer clear whether the death threats David says he faced would be sufficient grounds for asylum. On June 11, Attorney General Jeff Sessions issued legal guidance to immigration courts narrowing what kinds of claims qualify. He said that, "generally, claims by aliens pertaining to domestic violence or gang violence perpetrated by non-governmental actors will not qualify for asylum."

Whether or not Sessions' guidance will apply to cases already underway, such as David's, likely will itself have to be fought out in court, Wolozin said.

David himself is hopeful he'll be able to stay. He's studying English in summer school and looking forwarding to starting high school in August. He'd like, he said, to work toward becoming a DEA agent, and fight the drug trade corrupting Guatemala and its neighbors.

He pays attention to the debate over how the US should handle people like him and his family.

"You can't just let anybody in. You have to let people in who are really fleeing danger, and you also have to keep out people who are dangerous," he said. "But you can't just say to people who are fleeing danger that they can't come in."

As for those who want to close the door entirely? "They've never experienced the kinds of things that we are experiencing in Guatemala," David said. "They don't understand what it's like."