His career is in the toilet.

The highest-ranking official at New Zealand’s embassy in DC hid a camera in a bathroom there — hoping to make intimate videos of staffers, authorities said at the start of his trial Monday.

Former New Zealand naval Cmdr. Alfred Keating is accused of planting the micro-device in the unisex bathroom in 2017.

But while having reached some of the highest levels of professional success, Keating was a failure as a perverted spy, officials said.

The camera he planted quickly slipped out of position — leaving it to record mostly people’s feet, authorities said.

New Zealand Crown Prosecutor Henry Steele said Monday that the camera was placed in a heating duct in the bathroom but that Keating’s plan was thwarted when the motion-activated device fell out. An embassy staffer spotted the camera on a radiator and alerted a co-worker.

DNA found on the camera’s SD card was allegedly matched to Keating, who has pleaded not guilty to the charge of attempting to intentionally make an intimate video. Searches for BrickHouse Security, the company that made the camera, were found on Keating’s laptop.

According to court documents, Keating had futilely sought continued name suppression during the trial. He resigned from the Royal New Zealand Navy last March.