CNN sued President Donald Trump and several top administration officials on Tuesday after days worth of intense behind-the-scenes negotiations in which network officials repeatedly attempted to convince Team Trump to restore their top White House reporter’s credentials.

Last week, the White House press office announced it would revoke CNN White House correspondent Jim Acosta’s “hard pass”—the security credential granted to all prominent journalists who regularly cover the White House—after the reporter engaged in a tense back-and-forth with President Trump during a press conference.

In the following days, the White House’s justifications for such action constantly shifted. At one point, White House Press Secretary Sarah Huckabee Sanders shared a doctored video to falsely suggest Acosta violently “laid his hands on” a White House intern who attempted to grab away his microphone during his confrontation with the president.

And on Tuesday, CNN responded by suing the Trump administration in a Washington, D.C. district court, claiming that the White House had violated the network and Acosta’s First and Fifth Amendment rights to free speech and due process.

But that decision came after other options failed.

“This is not a step we have taken lightly. But the White House action is unprecedented,” CNN chief Jeff Zucker said in a note to staff. “The first amendment grants the right of all journalists to hold those in power accountable and ask tough questions. It’s what Jim and all of his colleagues who cover the White House and the administration do with integrity and professionalism.”

According to the complaint, CNN head Jeff Zucker privately appealed to White House Chief of Staff John Kelly regarding the Acosta situation. According to CNN sources, the network also reached out to members of the White House press office in the days leading up to Tuesday’s announced suit.

The network warned West Wing officials that if a resolution was not reached, then CNN would file a lawsuit. A White House source with knowledge of the standoff told The Daily Beast that CNN had reached out to Kelly and other senior aides, but declined to go into further detail.

Sources familiar with the network’s conversations additionally said the White House seemed uninterested in changing its decision. “We could have continued this back and forth, which was more of a forth,” a senior-level CNN source told The Daily Beast.

A second source involved with filing the lawsuit said, “We tried very hard to work it out but got no response.”

In the lawsuit, the cable-news network named Trump, Kelly, Sanders, communications chief Bill Shine, the U.S. Secret Service, and an unnamed Secret Service agent as defendants.

The Secret Service was named not only for initially revoking Acosta’s pass, but because, according to CNN, Acosta was credentialed by French authorities to cover Trump’s appearances in Paris this weekend.

But when Acosta arrived to do his job, he was turned away by U.S. Secret Service.

“Without his press credentials, Acosta’s ability to perform his duties as CNN’s Chief White House correspondent is effectively eliminated,” the network wrote in its complaint. “Because CNN’s chief White House correspondent has effectively been prohibited from reporting from the White House and the President’s trips, its newsgathering and reporting abilities have been significantly hampered, causing harm not just to CNN, but also to its many viewers and readers who rely on CNN as an essential news source.”

The White House did not immediately respond to requests for comment on this story. The Secret Service, meanwhile, simply told The Daily Beast, “We will refer you to the White House for comment.”

A West Wing official told The Daily Beast that President Trump, who has nicknamed the reporter “Crazy Jim Acosta” and makes no secret of his personal disdain for him, is aware of the lawsuit and “isn’t going to be losing any sleep over this.”

The West Wing’s cavalier response to CNN’s legal action reflects its broader attitude toward Acosta and his confrontational style that’s earned him scorn from Trumpworld and marquee treatment from outlets like Hollywood trade magazine Variety.

Numerous Trump White House officials, current and former, have said that they privately celebrate whenever a Trump vs. Acosta narrative emerges in the national press, because they view CNN—and Acosta in particular—as a useful foil in their sparring with mainstream media reporters..

In a Politico profile published late last year, cheekily titled, “Jim Acosta Is the White House’s Favorite Reporter,” the publication asked Trump’s former White House chief strategist Steve Bannon whether Acosta played right into Team Trump’s hands.

Bannon messaged back a one-word reply: “Yes!!!!!!!”

First Amendment attorney Floyd Abrams told The Daily Beast that CNN may have a strong case.

“It’s not that the president lacks authority to bar individuals who have misbehaved in a manner that substantially interferes with the ongoing process of a press conference,” he explained.“But what the President cannot do is to bar someone who disagrees with the substance of the questions he asks or because he chooses to retaliate against him because of prior questions he asks.”

The Reporters Committee for Freedom of the Press partnered with Georgetown University Law Center's Institute for Constitutional Advocacy and Protection to file an amicus brief in support of CNN's lawsuit.

In a conference call Tuesday morning, Georgetown Law's Joshua Geltzer and the Reporter's Committee's Bruce Brown argued that the White House violated the First Amendment by retaliating against Acosta and CNN for the critical content of his questions—not because of his behavior or, as Sanders suggested in her statement, in order to preserve decorum and a businesslike atmosphere in the White House Press Room.

“The arguments of decorum are pretty rich coming from folks who turned the Oval Office over to the Kanye West show,” Brown said.

Both men dismissed Sanders’ argument that CNN as a news organization has dozens of hard passes that allow its journalists to cover the White House, saying that ample legal precedent over many decades prohibits government officials from picking and choosing which reporters are allowed to cover them.

They cited the 1977 case Sherrill v. Knight, in which the courts ruled that the government could not arbitrarily deny White House press credentials to Nation columnist Robert Sherrill without violating his constitutional rights under the First and Fifth amendments.

It was unclear, as of early Tuesday, if other news organizations would join or support CNN’s lawsuit.

—Lloyd Grove contributed reporting.