A federal judge in Brooklyn ruled on Thursday that prosecutors could not force Facebook to remain silent about 15 grand-jury subpoenas involving the company’s customers.

The judge, James Orenstein, said that the prosecutors had legitimate concerns that their investigations might be compromised, but he added that the government’s boilerplate requests, made in identical language in each of the 15 applications for a gag order, were insufficiently detailed.

“Government prosecutors and agents have a difficult job investigating crime, and one that is made more difficult by the fact that some of the investigative techniques they must rely on can backfire by alerting criminals to the fact of the investigation,” Judge Orenstein wrote. But he went on to say that law-enforcement officers cannot “obtain an order that constrains the freedom of service providers to disclose information to their customers without making a particularized showing of need.”

A handful of cases have emerged in recent months laying bare the tensions between the government’s desire to conduct criminal inquiries, sometimes secretly, and the rights of companies like Facebook to have autonomy over their businesses.