As American security agencies increasingly take to Twitter, Facebook and other social networking sites in search of potential threats, two European travelers say the system lacks one important quality: a sense of humor.

The travelers, Leigh Van Bryan and Emily Bunting, said they were detained overnight after arriving in Los Angeles International Airport last Monday, questioned by agents from the Department of Homeland Security, and then sent back on a return flight to Europe. All because Mr. Bryan joked on Twitter that he was going to “destroy America” during his trip — an apparent reference to partying — as well as dig up the grave of Marilyn Monroe — a joke.

“The Homeland Security agents were treating me like some kind of terrorist,” Mr. Bryan, a 26-year-old Irish citizen, said in an interview published in the British tabloid The Daily Mail.

“‘You’ve really messed up with that tweet, boy,'” Mr. Bryan remembered one agent saying, using a more profane expression for messed up.

He was questioned under oath about his postings to Twitter, according to images of a document said to be from the agency. The document, posted by The Daily Mail and quoted by The Sun, appeared to demonstrate a less-than-full understanding of social media by agents explaining the reason for the questioning:

Mr. Bryan confirmed that he had posted on his Tweeter Web site account that he was coming to the United States to dig up the grave of Marilyn Monroe. Also on his tweeter account Mr. Bryan posted that he was coming to destroy America.

The authenticity of the document could not be independently verified. It was photographed by Small World News Service, an independent British news agency that frequently pays its sources for stories. Mr. Bryan and Ms. Bunting posed together for portraits by the SWNS news agency that appeared in tabloids on Monday, including the Daily Mail and the Sun.

A call to Donald Triner, acting director of the agency office overseeing an initiative on “Publicly Available Social Media Monitoring and Situational Awareness,” was directed to the press office.

The Department of Homeland Security provided the following statement, from U.S. Customs and Border Protection, on Monday afternoon:

Based on information provided by the LAX Port Authority Infoline – a suspicious activity tipline – CBP conducted a secondary interview of two subjects presenting for entry into the United States. Information gathered during this interview revealed that both individuals were inadmissible to the United States and were returned to their country of residence. CBP strives to treat all travelers with respect and in a professional manner, while maintaining the focus of our mission to protect all citizens and visitors in the United States. CBP denies entry to thousands of individuals each year on grounds of inadmissibility, some of which include: improper travel documents, prohibited activities or intent, traveling under the Visa Waiver Program without qualifying for participation in that program, smuggling of contraband or prohibited goods, criminal activity or history, immigration violations such as prior overstay, attempting to gain entry with fraudulent documents or posing as an imposter, and national security concerns, among others. We recognize that there is an important balance to strike between securing our borders while facilitating the high volume of legitimate trade and travel that crosses our borders every day, and we strive to achieve that balance and show the world that the United States is a welcoming nation.

The Department of Homeland Security and other federal agencies have recently taken steps to improve their monitoring of social media. The Federal Bureau of Investigation said in a document released this month that it was seeking help from developers on an application to scan and scrape information from a variety of public sites and from government terrorism data.

According to the document, the application would have the “ability to instantly search and monitor key words and strings in all ‘publicly available’ tweets across the Twitter site and any other ‘publicly available’ social networking sites/forums (i.e. Facebook, MySpace, etc.)” The F.B.I. outlined the goals of its “social media analysis” as:

Detecting potential threats developing threat profiles, outline possible courses-of-action, determine timeframe for action by bad actors, identify and develop tactical picture of the location for threat events, develop intelligence products for counter-measures.

The Air Force has expressed similar goals. The top Air Force scientist, Dr. Mark Maybury, told Foreign Policy’s Danger Room blog earlier this month that he would like to “see into the hearts and minds of people” with a kind of “social radar” that could provide advanced warning of enemy movements and other tactical intelligence. That involves reading people’s public expressions online.

The Department of Homeland Security released information this month on its program of monitoring “public reaction to major governmental proposals with homeland security implications” in 2009 and has also responded to privacy concerns regarding its ongoing social media scanning. According to the agency, personal information is not collected during these scrapes of online information, except in situations “involving potential life or death circumstances” or with public figures or people “known to have been involved in major crimes of Homeland Security interest.”

It was not clear whether Mr. Bryan’s apparently joking posts to Twitter were found as a part of this program. The agency document said to describe his situation indicated that he had been added to a “One Day Lookout” list, thus flagging him for further questioning. (According to the agency, the “lookout” list “is usually the result of analysis conducted on passenger information submitted by the airline prior to the aircraft’s arrival in the United States.”)

Mr. Bryan’s Twitter account is currently set to private, but screen shots of his earlier postings were republished on Monday by the tabloids. One post, sent on Jan. 16 and addressed to an acquaintance, read: “@MelissaxWalton free this week for a quick gossip/prep before I go and destroy America?”

To which the friend, apparently in on the joke, replied: