Keys / Prefect
PREFECT_API_KEY
The API key your workers, flows and scripts connect to Prefect Cloud with. User keys start with pnu_; service account keys with pnb_.
- Expires
- you choose; service account keys can never expire
- API
- create, rotate and delete service account keys, on Pro and Enterprise
Get it
Create one on app.prefect.cloud/my/api-keys. The steps aren't recorded yet.
Set it
PREFECT_API_KEY=...
The Prefect Python SDK and CLI read it from this variable, together with PREFECT_API_URL. Or keep it out of .env with keypin: keypin run -- npm run dev
Replace it
- For a service account, click Rotate API Key and keep the old key active for a while. For a user key, create a new one under API Keys.
- Deploy it everywhere that reads
PREFECT_API_KEY. - Check that workers and flows connect with the new key, then delete the old one.
Set rotate_every on the key in keypin.toml and a rotated date on its vault item, and keypin status shows when it's due.