You’re at a United States border or in customs at the airport. A Customs and Border Protection (CBP) agent halts you and begins to ask you questions. It doesn't seem that you're free to leave, and a government official is asking you questions. Are you entitled to the Miranda warning?
Miranda typically applies when someone is in custody and subject to interrogation. If, in this situation, an officer doesn’t “read you your rights” and you talk, your statements will generally be inadmissible in court. (See Statements Obtained When Police Violate Miranda.)
But customs questioning is different from your typical “custodial interrogation.” Courts have decided that the government’s interest in controlling and protecting U.S. borders justifies what is essentially an exception to the Miranda rule. According to this exception, officials may—without providing the Miranda warning—stop people at U.S. borders (airports included) and ask them routine questions. Such questioning is designed to determine whether the traveler is allowed to enter the country or is smuggling something. (U.S. v. Hudson, 210 F. 3d 1184 (10th Cir. 2000).)
(For related reading, see Search and Seizure at and Around the U.S. Border.)
There are, however, circumstances in which routine border-crossing questioning becomes something more. For example, an official moving a traveler into a holding cell or interrogation room might create a “custodial interrogation” situation that requires the Miranda warning.
It’s sometimes tough to anticipate whether a court will consider an interaction “custodial interrogation.” Courts have to analyze the precise circumstances of each situation to make the call. (Thompson v. Keohane, 516 U.S. 99 (1995);Chavez-Martinez v. U.S., 407 F. 2d 535 (9th Cir. 1969).)
For much more detail on this topic, including interplay between Miranda and deportation proceedings, see Miranda and Border or Customs Questioning.