The Fourth Amendment to the U.S. Constitution protects against random and arbitrary searches and seizures. But courts have reduced this protection when it comes to people traveling through and near U.S. borders. These courts have justified their rulings by citing the U.S. government's interest in securing its borders from both "illegal aliens" and the smuggling of contraband.
Generally, the closer one is to the border, the less one is entitled to travel freely and the more one can expect stops, questions, and even searches by customs officials.
(Note: Federal law typically decides border-search issues, but state law can sometimes come into play.)
To learn about detention, questioning, and searches at the actual border or its "functional equivalent," see When can officials, stop, question, and search travelers at the U.S. border?
The rules that govern stops and searches at the actual border (or its equivalent) differ somewhat from those that apply near the border. In short, customs officials are held to a higher standard at immigration stops along inland routes within 100 miles of the U.S. border. Such stops include detentions:
Despite the higher standard, U.S. Customs and Border Protection (CBP) officials ("customs officials") have authority for certain warrantless detentions and searches in these situations. (At least one court has held that the authority applies even beyond 100 miles from the border, where officials have reasonable suspicion.)
In these removed-from-the-border settings, CBP must use the least restrictive type of stop structure that still allows them to determine travelers' immigration statuses. For example, roving patrols are less restrictive than checkpoints because patrolling officials can stop only cars about which they have individualized suspicion. If a road is sparsely populated, therefore, roving patrols should be deployed rather than checkpoints; it's not impractical for roving officials to develop individualized suspicion when there are few cars on the road. (U.S. v. Vasquez-Guerrero, 554 F. 2d 917 (9th Cir. 1977); U.S. v. Sandoval-Ruano, 436 F. Supp. 734 (S.D. Cal. 1977).)
The law on searches and seizures at and near the U.S. border is constantly evolving. And it's complex, to say the least. So, if you have a question about your rights or need advice, make sure to consult an attorney experienced in this area.