A US federal appeals court has upheld the constitutionality of gag orders that prevent companies from informing their customers about FBI surveillance.

The nondisclosure agreements often accompany national security letters (NSLs) issued by the FBI, compelling tech companies to turn over subscriber data while leaving the target unaware that they are being surveilled. No warrant is required for the data and the gag orders can remain in effect indefinitely.

Content distribution provider CloudFlare and mobile network operator CREDO sued the government to inform their customers of five NSLs received between 2011 and 2013, Reuters reports. The firms mounted a joint challenge to the gag orders on the grounds that they violated the First Amendment’s free speech protections. The FBI permitted the companies to reveal that they had received NSLs and identify themselves as appellants in the court case earlier this year in March.

A three-judge panel of the 9th US Circuit Court of Appeals in San Francisco unanimously rejected the argument that the nondisclosure orders violated the First Amendment. Writing on behalf of the panel, Judge Sandra Ikuta ruled that “national security is a compelling government interest” that justifies the gags. Ikuta also argued that the gag orders were narrowly tailored and that a 2015 law passed by Congress provided greater oversight of NSL use.

The FBI issues tens of thousands of NSLs each year to various tech companies. Apple revealed in its biannual transparency report that it had received between 5,750 and 5,999 NSLs in the second half of 2016 alone, which affected between 4,750 and 4,999 accounts.

Other major tech firms, including Microsoft and Twitter, have also launched legal challenges to gag orders surrounding surveillance orders. Earlier this month, Facebook sued the government to disclose three search warrants, arguing that gag orders have a chilling effect on free speech.

“We believe there are important First Amendment concerns with this case, including the government’s refusal to let us notify three people of broad requests for their account information in connection with public events,” Facebook said in a statement.

Facebook’s legal challenge has the support of eight tech companies including Google, Apple, Microsoft, and Twitter, as well as the ACLU and the Electronic Frontier Foundation.

Andrew Crocker, an attorney at the Electronic Frontier Foundation who also represented CloudFlare and CREDO, argued in support of Facebook that the government issues an unnecessary amount of gag orders.

“The government can only insulate its actions from public scrutiny in this way in the rarest circumstances, which likely do not apply here,” Crocker said.