Tech companies including Facebook, Twitter and Microsoft are fighting gag orders from US courts preventing them from talking about government surveillance of their users, arguing it has a chilling effect on free speech.

Facebook, Twitter and Microsoft all have policies to notify users of government requests for account information unless they are prohibited by law from doing so in exceptional circumstances such as life-threatening emergencies, child sexual exploitation and terrorism.

However, it seems that the US government is attaching gag orders – many with no time limit – to their data requests in about half of all cases. This means that people are having their digital lives ransacked without their knowledge and with no chance for public scrutiny or appeal.

Tech companies and civil liberties campaigners argue that the gag orders are unconstitutional, violating the fourth amendment, which gives people the right to know if the government searches or seizes their property, and the first amendment, which protects the companies’ right to talk to their customers and discuss how the government conducts its investigations.

Facebook is challenging a court order that prevents the company from notifying three of its users about government search warrants in relation to “potential felony charges” seeking all communication, identifying information and other records from their social media profiles for a three-month period.

Most of the details of the investigation are sealed, although one filing suggests the warrants are linked to mass arrests of protesters during Donald Trump’s inauguration in January.

“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,” said a company spokesman.

Facebook has, according to amicus briefs filed by the end of June, the support of Google, Apple, Microsoft, Twitter, Dropbox, Yelp and Avvo as well as civil liberties groups including the American Civil Liberties Union, the Electronic Frontier Foundation, Access Now and the Reporters Committee for Freedom of the Press.

“Absent an overriding interest in secrecy, which appears to be absent here, the government should not be permitted to impose a non-disclosure order on an internet service provider that would effectively prevent the ISP’s users from asserting their constitutional rights,” said the ACLU.

Separately, Twitter has been fighting to speak more openly about surveillance requests it receives from the US and foreign governments’ intelligence agencies.

Twitter filed its lawsuit in 2014 after revelations by the NSA whistleblower Edward Snowden about the extent of US spying. This case is not about notifying individual users that their accounts are being surveilled, but about allowing Twitter to be transparent about the number of national security requests it receives.

Currently, companies cannot reveal specific numbers, only that they received requests within a broad range, such as “0-499 requests within a six-month period”.

“Twitter wants to be able to report the precise number so that users understand it’s not a continuing stream of hundreds of accounts being monitored,” said Albert Gidari, director of privacy at the Stanford Center for Internet and Society.

On Thursday, the California district judge Yvonne Gonzalez Rogers ruled that the US government had failed to show the kind of “clear and present danger” that could justify restricting Twitter’s constitutional rights to talk about surveillance requests.

Microsoft is challenging gag orders at a higher level, bringing a lawsuit that calls into question the provision in the Electronic Communications Privacy Act that allows for courts to order the company to keep its customers in the dark when the government seeks their email content or other private information stored in the cloud.

Microsoft wants the statute to be updated to require the government to provide evidence that disclosure of the warrant might hinder an investigation. It also wants to ensure that every gag order comes with a specified time limit. As it stands, many gag orders are indefinite, as opposed to restricted to 90 or 180 days, which Microsoft argues is unconstitutional.

These legal battles highlight an awkward tension for technology companies. On one hand, they are under great pressure from governments to assist in investigations, but at the same time they are duty bound to protect their users’ data from government intrusion.

“The government is plainly over-enthusiastic with gag orders,” said Gidari, adding that in many cases the government backed down when challenged.

Legal battles from large internet service providers have helped to reduce the stealthy data pillage, he said, but not all service providers have the resources to challenge the government.

“You never want to impugn the motives of law enforcement but there are many cases where law enforcement has used these requests improperly,” said Gidari.