CAGE stands for Commercial and Government Entity code, a five character code the government uses to identify a specific location, your facility, rather than your business as a whole. Where a UEI names the company, a CAGE code names the place, and most small businesses only ever need the one that gets assigned automatically at registration.
What it actually identifies
Think of the UEI as answering "which company" and the CAGE code as answering "which address." Government contracting, logistics, and payment systems use CAGE codes to track exactly where equipment ships, where a facility sits, and which physical location a contract or a security record actually refers to. If your business operates from a single address, you will only ever have one CAGE code, tied to that address, for as long as you are registered there. A business with more than one physical location can end up with more than one CAGE code, one per address, though most small businesses never run into that.
How you get one
You do not apply for a CAGE code on its own, and there is no separate form, fee, or approval step. It gets generated automatically as part of SAM.gov entity registration, once your registration validates, and it appears in your entity record alongside your UEI. If you have completed SAM registration, you already have one, whether or not you have ever gone looking for it. There is no renewal notice to watch for and no certificate to print. It simply exists in the background from that point forward.
NCAGE for entities outside the United States
Businesses located outside the United States that need to do business with the US government get an NCAGE code instead, through a separate international process. If your business is US based, this does not apply to you.
Where you will actually use it
Past the moment it is assigned, a CAGE code mostly sits quietly in the background of your registration. You will type it into capability statements, some contract paperwork, and occasionally a form that asks for it right alongside your UEI and NAICS codes. It does not expire on its own schedule, but it depends entirely on your SAM registration staying active, so if that lapses, treat your CAGE code as on hold along with everything else the registration covers.
There is nothing to optimize here and nothing worth shopping around for. The one thing actually worth doing is keeping your registered address current, because that is the fact the code is tied to. If your business moves, update SAM.gov, and your CAGE record follows automatically.