The ultimate code or ultimate override was a distress call signal in use in the United Federation of Planets that overrode all other communications and missions of a Starfleet starship, and required them to respond.
The code was so highly classified that starship commanding officers were forbidden to submit an ultimate code to computer for decoding, rather commanders had to memorize a key which allowed them to decode the message into a coherent form. Nor could the starship commander keep a computer record of the code.
The ultimate code was only to be used in the most extreme of circumstances. This included attack by an alien force, a disaster, or an unforeseen scientific development, and also a provision for a danger that had not yet been anticipated. Misuse of the ultimate code was a crime in the Federation. Starships operating under the ultimate code were required to observe radio silence, and were required to approach at battle stations.
In an alternate timeline, the USS Enterprise was summoned to the Aleph Prime colony in 2270 by the ultimate override code. When the Enterprise arrived, Captain James T. Kirk learned that there was no emergency, and that the colony prosecutor wanted to have Doctor Georges Mordreaux shipped to a rehabilitation colony. Kirk was furious that the ultimate code was misused to call his ship in to transport a prisoner, and was about to refuse the request, but Commander Spock intervened and Kirk agreed to transfer Dr. Mordreaux on the Enterprise. This set in motion a series of events in which Kirk was murdered by a future version of Dr. Mordreaux.
Spock later traveled back in time to the point just before Dr. Mordreaux had begun to send people back in time to convince him not to proceed with his experiments. With the help of a future version of Dr. Mordreaux, Spock was able to convince Dr. Mordreaux not to proceed. Traveling back to the present, Spock found that the Enterprise had never received an ultimate summons to Aleph Prime, and that there was no increase in the rate of entropy as he had documented in the previous timeline. (TOS novel: The Entropy Effect)