Are there any precedents for U.S. presidents having served in other official government roles after the ends of their terms. Conceivably they could become ambassadors or Supreme Court judges, for example.
I am aware that some former presidents served on special government commissions (true e.g. for President Hoover under President Truman) or as official envoys on foreign policy occasions (true e.g. for Presidents Carter and Nixon, I believe), but these are not official roles in the sense of this question. It is about regular and permanent roles in the executive branch, legislature, or judiciary.
The background of my question is of course that e.g. Presidents Clinton and Obama held (hold) office at a relatively young age, and they and their contemporaries normally go on to run their own foundations. I am wondering about conceivable alternatives.