The Secret Service has formally adopted new policies on the use of alcohol and social media, banning excessive drinking and the sharing of work-related information on sites including Facebook five months after more than a dozen employees were accused of drunken partying with prostitutes in Colombia.

The written policies, obtained by The Washington Post, were released to most agency employees this week. They make clear what Secret Service leaders say were always part of the unwritten code of conduct for the federal law enforcement agency, which protects the president and other dignitaries.

Agency Director Mark Sullivan and members of Congress concluded that the rules had to be codified to prevent incidents like the one in Cartagena in April from occurring. They also sought to make such behavior a fireable offense: A handful of the agents implicated in taking prostitutes to their hotel rooms had fought the agency’s attempt to dismiss them, saying that they had broken no existing rules by drinking and fraternizing with women during off-duty hours.

The incident was the most embarrassing ethics scandal the Secret Service has faced in its history, and it led to a dozen employees involved in the president’s security being flown home hours before President Obama arrived in South America for an economic summit. For weeks after the incident became public, more unflattering revelations trickled out about the actions of other employees at an agency that typically prides itself on its unified front and silent professionalism.

Last month, the agency appears to have taken a formal step to clamp down on public leaks about its employees’ super-secret work protecting the president and others and to also stop possible gossip about the personal lives of those under the agency’s protection. According to records reviewed by The Post, agents for the first time are required to sign a nondisclosure agreement, which warns they could be terminated, prosecuted or both if they share security-sensitive information or personal details about their “protectees.”

Secret Service spokesman Ed Donovan said the alcohol policy is a formal adoption of rules proposed and discussed at length in the wake of the Cartagena investigation. He declined to comment on the social media policy or nondisclosure agreement.

The alcohol policy requires agents not to have any alcoholic drinks in the 10 hours before reporting for work. During official trips, it bans drinking alcohol in the hotel where the president or any other protected person is staying.

“Alcohol may only be consumed in moderate amounts while off-duty on a [temporary duty] assignment and alcohol use is prohibited within 10 hours of reporting for duty,” a copy of the policy reads. “Alcohol may not be consumed at the protectee hotel once the protective visit has begun.”

Some Secret Service agents and officers had complained that managers in the past had tolerated considerable drinking and partying with women on presidential trips overseas and outside Washington. Most of the men implicated in the Colombia scandal did not have to report for any work assignments until the next morning, many hours before Obama was scheduled to arrive.

The stain of Cartagena spread to other federal agencies. A dozen members of the military were also accused of hiring prostitutes on the trip, and one agent told investigators that Drug Enforcement Administration agents stationed in Colombia had taken prostitutes to their apartments. The Department of Homeland Security’s inspector general last month told Congress that he had concluded that Secret Service employees on the April trip interacted with 13 women and paid six for sex and that White House and Defense Department staff members may have been involved.

The social media policy appears to be designed to prevent problems that can arise when government employees use Facebook and other social sharing sites for work or personal reasons. In the wake of the Cartagena scandal, The Post revealed that one of the supervisory agents implicated had previously joked on Facebook about “checking out” Sarah Palin while assigned to protect the Republican vice presidential nominee in 2008.

That supervisor was David Chaney, whose father had a storied career as a Secret Service agent and supervisor. The son retired under pressure in April immediately after investigators questioned him and discovered his role in the scandal.