When the Department of Homeland Security’s attempt to unmask an irksome Twitter account imploded last year, few within the agency were surprised, according to newly released records. “Why would we do this?” one official asked in early April 2017 after Twitter filed a complaint in federal court, according to the heavily redacted emails.

The short-lived investigation into @ALT_USCIS, an anonymous account that claims it’s run by a U.S. Citizenship and Immigration Services employee, sparked an uproar over First Amendment encroachments and potential abuses of power last year, including from members of Congress.

The new documents, released last week by the Reporters Committee for Freedom of the Press after it sued the DHS and Customs and Border Protection, reveal a partial timeline of the abortive investigation. But more importantly, the emails show how a seemingly unsupervised CBP agent improperly attempted to force Twitter to produce records on a particular user without a court order — completely disregarding whether the summons was legal.

“These documents make clear that the CBP needs to focus on real security issues, rather than abusing its authority to discover the identity of a whistleblower,” said Sen. Ron Wyden, D-Ore., who demanded answers from CBP Commissioner Kevin McAleenan last year.

The investigation into @ALT_USCIS started in late February 2017, according to the emails. On February 22, McAleenan saw a tweet in which @ALT_USCIS encouraged anyone with “personal dirt” on dishonest CBP and ICE agents to get in touch. The tweet offered payment and anonymity for tipsters.

A senior CBP official named Patrick Flanagan asked the agency’s Office of Professional Responsibility to look into this tweet and another in which @ALT_USCIS shared an “email dump” allegedly from five CBP officers celebrating Trump’s election. @ALT_USCIS quickly deleted the email tweet, saying the emails “could be bogus.”

A technical staffer searched agency accounts for emails to and from the tip account, as well as for messages containing keywords from the email dump, according to the released emails. The staffer was aware of the legal sensitivity of the search. Before reporting results, the staffer looped in another official, writing in one email, “I wanted to make you aware of this request for its legality.” It’s unclear if these searches turned up anything useful.

It’s also unclear when such concerns over legality faded away, as leadership pressed to find out the identity behind @ALT_USCIS.

“I wanted to confirm your staff is running this to ground,” Flanagan wrote to OPR in early March. The same day, he pressed the technical staff on whether they had any luck “identifying individuals” via the searched emails.

On March 14, 2017, CBP agent Adam Hoffman faxed a four-page summons to Twitter’s legal office in San Francisco. A supervising special agent, Stephen P. Caruso, signed the summons, which ordered Twitter to turn over a broad swath of information, including “all records regarding the twitter [sic] account @ALT_USCIS to include, User names, account login, phone numbers, mailing addresses, and I.P. addresses.”

The trouble was that the order lacked any grounding in law.

One agent wanted agency lawyers to press Twitter to comply, despite acknowledging the summons had wobbly legal support.

In phone calls and emails with Hoffman, Twitter’s attorneys pointed out that the underlying legal authority for this “1509 summons” — which is named for the authorizing law — pertains solely to records about imported merchandise.

Hoffman clearly had no justification for slapping a 1509 summons on Twitter to compel them to provide information about @ALT_USCIS.

“It looks like no one discussed the summons with OPR or legal, the dude just filled it out, got a supervisor to sign it and sent it out,” @ALT_USCIS told The Intercept over Twitter chat. “That is how casual they are about civil liberties.”

An OPR official said investigators should “actually research all the citations of law to ensure the document is applicable,” as word spread around the agency in April 2017. Another worried that the agency’s “admin legal request documents are lacking.”

A subsequent review by the Homeland Security inspector general’s office found that OPR staff were generally confused about how to properly use the 1509 summons; they found that at least 1 in 5 such orders issued by Hoffman’s colleagues were in violation of either legal authority or DHS policy.

But the newly released emails show a CBP agent — presumably Hoffman, based on Twitter’s detailed summary of their correspondence in the federal complaint — doubled down when challenged. The agent asserted, despite clear statutory limitations, that the requested information was well “within the scope” of the summons.

“That is because if a person or group is using Twitter to release controlled information or message ways around laws that CBP is responsible to enforce it would fall under that summons,” the agent wrote to Twitter.

This creative reading was plainly incorrect, and Twitter’s lawyers let Hoffman know that they would challenge it in court if CBP didn’t withdraw the summons within 48 hours. When Twitter followed through on April 6, some of Hoffman’s fellow investigators were concerned — but not over the attempt at getting Twitter records.

They were galled that Hoffman had used the wrong form.

“Too bad the rest of our organization doesn’t have a better understanding of the Customs Summons,” one wrote. Another suggested that Hoffman should have partnered with a prosecutor to get a grand jury subpoena.

As agency attorneys briefed top leadership and managed press coverage around the lawsuit, others at CBP were confused by why Hoffman was in the wrong even on procedure.

One OPR agent wanted agency lawyers to press Twitter to comply, despite acknowledging that the summons had wobbly legal support.

“I never really thought they applied either, but in a round about way it can be articulated how these cases affect trade. … Something for the legal beagles,” wrote the assistant special-agent-in-charge in Miami.

“This push back is nothing new with these summonses,” wrote a colleague on the same email chain. “ICE tried it with several tech companies in 2016 and some complied, but Google pushed back with a similar argument.”

“Maybe they have been able to justify its use in the past,” another OPR official wrote. “Would be interested to know.”

Such discussions hint, of course, at potentially wider misuse of summonses, not only by CBP, but also by ICE and other agencies as well. And not only have these summonses been misused, but “several tech companies” haven’t bothered to oppose them as Twitter did here.

“They are used to abusing that subpoena power,” @ALT_USCIS said. “Most of the time it is sent to small businesses who do not seek legal advice. They just see DHS, they get scared and give them what they need.”

The day after Twitter filed its federal complaint, the government withdrew Hoffman’s summons and Twitter dropped its lawsuit.

The Homeland Security inspector general launched its investigation the same day and quickly determined no classified information was released via @ALT_USCIS. The inspector general’s November 2017 report found a widespread “lack of understanding” on the limitations on the 1509 summons, such that CBP agents have used them in “a wide range of cases having no nexus” to imported merchandise.

In one case, OPR investigators issued a 1509 summons to Craigslist for information about a Border Patrol agent selling government-issued night vision goggles. In other cases, investigators inappropriately used a summons to vet sick leave claims.

CBP told the inspector general it would revise policies about 1509 summonses and retrain staff on their proper usage. In May 2017, as CBP worked on a new policy, the agency chided OPR employees by email, reminding them that they must consult with an attorney before sending one.

The inspector general also recommended a review of how agents across CBP — and not just within the Office of Responsibility — have used the 1509 summons to obtain information and records. A CBP spokesperson, Daniel Hetlage, said the agency conducted “a comprehensive review of its use of the 1509 summons authority,” resulting in new policies “designed to strengthen existing internal controls and approval protocols.” Hetlage did not answer whether this agency-wide review uncovered additional summons abuses.

Top photo: A U.S. Customs and Border Protection patch is displayed on the sleeve of Ronald D. Vitiello, Acting Deputy Commissioner of U.S. Customs and Border Protection (CBP) on December 5, 2017 in Washington, DC.