Described is a spring-loaded cartridge cap (100) for use in a drug infusion pump (150). The cap is ejected if it is not properly inserted into the pump. In one embodiment, the cap includes three detent pins (108) that mate with detents in a cartridge chamber (114) within the drug infusion pump. As the cap (100) is inserted into the cartridge chamber of the drug infusion pump, the distal end of the cartridge compresses a coil spring (116) within the cap (100). To secure the cap within the cartridge chamber (114), the cap is rotated such that each detent pin (108) moves within a slot (112) until a locking detent (164) is engaged.