A federal court ruled this week that sweeping policies permitting U.S. Customs and Border Protection (CBP) and U.S. Immigration and Customs Enforcement (ICE) to search personal cell phones, laptops, and other electronic devices without reasonable suspicion are unconstitutional.

The policies that the court rejected authorized CBP and ICE officers to search the contents of electronic devices of people arriving at U.S. borders, including U.S. airports, without reasonable suspicion that those devices might have evidence of illegal activity and without a court order. Immigration officers could randomly search the cell phones and laptops of anyone arriving in the United States, including U.S. citizens and lawful permanent residents.

In Alasaad v. McAleenan, ten U.S. citizens and one lawful permanent resident challenged these policies, arguing, in part, that they violate the Fourth Amendment to the U.S. Constitution. On Tuesday, the court agreed.

Generally, the Fourth Amendment protects against unlawful searches or seizures and requires that law enforcement officers have a warrant before they can search someone or their property. However, there is an exception to this warrant requirement for searches at a U.S. border. Law enforcement officers can conduct “routine” searches at the border without a warrant and without any suspicion at all.

But searching someone’s cell phone or laptop is not a “routine” search, the federal court concluded. As the court explained, even a basic search “may reveal a wealth of personal information,” including medical and employment history, family relationships, and personal contacts.

For example, CBP officers asked one plaintiff in the case—a journalist—about photographs, emails, and contacts found on his phone. CBP returned a phone to another plaintiff having apparently removed a video of her daughter’s graduation. CBP officers questioned a third plaintiff—a graduate student and founder of a media website—about one of her blog posts while searching her phone and laptop.

These invasive searches are widespread. Available data shows that in fiscal year 2017 alone, CBP conducted over 30,000 searches of electronic devices.

Under the federal court’s decision, in order to comply with the Fourth Amendment, CBP and ICE must have reasonable suspicion that an electronic device contains illegal material before it can be searched. This means immigration officials cannot engage in fishing expeditions at the expense of the privacy of all international travelers.