Conducting health and safety inspections was a part of the Treaty of Alliance between the Federation and the Klingon Empire.The Treaty allowed unrestricted passage for all Klingon starships in Federation space, and vice versa. Under normal circumstances, such vessels could not be boarded or searched without cause. The Treaty, however, did possess a clause allowing health and safety inspections of vessels to verify that they were free of hazards which could affect the well-being of any persons on board. An operator of a vessel so searched who believed it to be invalid could file a complaint against the searchers with the Starfleet Judge Advocate General's office.
The crew of the USS Enterprise-D conducted a health and safety inspection under the treaty in 2370 of a Klingon Toron-class shuttle operated by Koral. The use of the inspection clause was simply a ruse to gain access to the vessel to look for a portion of a missing Vulcan artifact, the Stone of Gol. The search did not turn up the artifact, as it was on Koral's person at the time. (TNG: "Gambit, Part II")
In 2372, Kasidy Yates tried to get Benjamin Sisko to allow her to skip a six hour health inspection of the SS Xhosa by promising to flood the cargo hold with baryon radiation. Unknown to Yates, the inspection was actually ruse to search for contraband. When Sisko asked Michael Eddington if they could speed it up, Eddington replied that they couldn't and continue to search for illegal goods while still appearing to perform a health inspection. Sisko reasoned that with Kasidy breathing down their necks, they probably wouldn't be able to make a thorough search in any case, and let her go. (DS9: "For the Cause")