CNN  — 

If you’re entering or returning to the US soon – even if you’re a US citizen – you may be confused about your legal rights in the wake of President Trump’s contested travel ban.

Can officers detain you at airports or other border checkpoints? Can they scroll through your phone? What happens if you say no?

To learn the answers to these and other questions, we spoke to three experts in immigration and privacy law: Danielle Rizzo and Leslie Holman of the American Immigration Lawyers Association, and Nathan Freed Wessler, a staff attorney with the ACLU.

Can I be stopped or searched at the border?

Yes. It doesn’t matter if you’re an American citizen, a green card holder or a visa holder, Customs and Border Protection (CBP) officers can stop you or take you to secondary inspection. This might happen because officers need more information about you or your immigration status to decide whether you should be allowed into the country. It could also be a random search.

According to Holman, even if you have a visa to enter the United States, CBP agents are ultimately deciding your “admissibility” into the United States.

A Customs and Border Protection officer checks IDs as people enter the US from Mexico in San Ysidro, California.

Do I have the same legal rights at the border that I would elsewhere?

No. The Fourth Amendment, which protects people from searches and seizures without probable cause of a crime being committed, doesn’t apply in the same way at the border, Rizzo said.

According to Holman, probable cause and reasonable suspicion are not needed to search people – Americans or foreign visitors – at the border.

Am I allowed to speak with a lawyer?

It depends.

If you’re a US citizen:

According to the ACLU, US citizens are allowed to request a lawyer be present for any questioning.

If you’re a permanent resident or other foreign national with a visa:

If you’re not American you generally don’t have the right to an attorney unless you have been charged with a criminal offense or the questions relate to something other than your immigration status, Rizzo says.

Once the questioning goes past the basics – like where you traveled or what you’re bringing into the country with you – to things like your political beliefs or the contents of your electronic devices, Wessler believes that all travelers, including non-citizens, have the right to counsel.

Can CBP officers take my green card away and not allow me back in the country?

No. Officers at the border cannot make you sign a form that would abandon your permanent resident status.

According to Rizzo, in most cases (unless you’ve committed a serious crime and are being deported), legal permanent residents have a right to a hearing before an immigration judge. So you would be allowed back into the country to wait until that hearing.

An air traveler is cleared by a Customs and Border Protection Officer at Dulles International Airport outside Washington.

Can my things be searched?

Yes, all people and their luggage and belongings entering the country are subject to search.

What if I bring prohibited or restricted items with me?

You will be asked to declare what items you’re bringing into the country. If you have prohibited items, such as fruit that could carry pests or diseases, they will be confiscated and destroyed.

Could my laptop, phone or other electronic devices be searched?

Yes, even if you’re a green card holder or an American citizen.

On January 31, Sidd Bikkannavar, a US citizen and NASA engineer, was stopped by customs officers at Houston airport when he was returning from a vacation in Chile. He wasn’t from any of the seven countries listed in Trump’s executive order. But CBP officers asked for his phone and his PIN to access the phone.

According to CBP, your devices could be searched for many reasons, including incomplete travel documents or because your name matches a person of interest. It also could be a random search.

US Customs agents typically ask travelers to declare what items they're bringing into the country.

Could I be asked for access to my social media profiles or email?

Yes, even if you’re American. But whether you’re legally required to share this information is unclear.

“It’s a really tricky area to determine,” Rizzo says. Wessler agrees: “The state of the law is so unsettled because the government claims such broad power at the border.”

In December, the US government started asking certain foreign visitors for access to their social media profiles. That request, while voluntary, is now included on a form which visitors from certain countries – including the UK, France, and Spain – need to fill out.

What about my data on my phone?

This is where it can get complicated.

Border agents are allowed to swipe through your phone or look through the documents on your laptop.

The government can also copy the data on your device.

But courts are still grappling with this issue, Wessler says. A federal appellate court ruled in 2013 that if border agents wanted to conduct a “forensic search” they have to suspect you of criminal wrongdoing.

Passengers wait at a customs checkpoint at Atlanta's Hartsfield-Jackson International Airport.

What if I decline to hand over my passwords or PIN?

Rizzo and Wessler both say that this is where people have to start making practical judgments about what the implications could be for them:

If you’re a foreign national:

If a foreign national is perceived as not being cooperative, Rizzo warns “there could be severe repercussions.” If someone chooses not to hand over the information asked of them, she says CBP can deny them entry.

If you’re a green card holder:

You have more rights, but not as many as a US citizen, according to Rizzo.

Officers at the border cannot make you sign a form that would relinquish your permanent resident status. According to Rizzo, in most cases, legal permanent residents have a right to a hearing before an immigration judge. So you would likely be allowed back into the country to wait until that hearing.

If you’re a US citizen:

You cannot be denied entry into the United States, but you might be delayed.

“For citizens, and likely for many green card holders, border agents can inconvenience you, but eventually, they’re going to have to let you back into the country,” Wessler says.

“There’s a risk you could be held, detained … for hours in an unpleasant, windowless secondary inspection room,” he says. There’s also a chance that authorities will seize your phone or laptop, he says, adding that he’s seen cases in which phones were held for months.

Arriving international air travelers head to Passport Control at Dulles International Airport.

Can border agents keep my phone or laptop?

Yes. They could keep your device for further examination, which could include copying your data.

How can I safeguard my device when traveling internationally?

“If you don’t want it searched, don’t carry it across the border,” Rizzo says.

Wessler’s advice is similar: “The best advice may be to be really careful on how many devices and what kind of data you’re carrying with you,” he says. “In terms of devices, government can’t search what you don’t have.”

People who are concerned should leave their primary phone or laptop at home and travel with another device, he says.

Or, you could back up your data to a secure server, wipe it from your phone and then restore the data after you pass through customs, Wessler says. But this also could raise suspicions at the border.