Rotate an API key
Rotate an active local API key when the current generation needs to be replaced. Beacon API increments the key's generation and keeps its identifier. The request allowance follows the project's plan and stays unchanged after rotation.
Before changing an API key, keep a recovery credential in a secure location. Confirm the key name and project before continuing. Use a disposable fixture key for these exercises; never paste a live secret into a terminal transcript or documentation example.
Prerequisites #
Create key-demo by following Create an API key. Run the following command from the same fixture repository with Node 24. Keep a recovery credential in a secure location before rotating an API key. Confirm the intended key identifier and project. Use only disposable local fixture data in this rehearsal.
Rotate the key #
Run node src/beacon.mjs key rotate --id key-demo.
The result is rotated API key key-demo (generation 2). The identifier remains key-demo. If the key has already been rotated, its next generation is greater than 2.
On Linux, run the command in a terminal from the repository root. Use Beacon CLI for the local exercise. Read API key limits to confirm the current plan allowance.