How to rotate a Hetzner Cloud API token
Reissue a Hetzner Cloud API token: generate a second token in the same project with the same permission, switch your tools, test it, then delete the old token.
Part of the guide
HetznerCloud API token
- Where to issue a new one
- console.hetzner.com/projects
- What a leaked key reaches
- Every resource in one project: GET requests only for a Read token, or GET, POST, PUT and DELETE for a Read & Write token.
- Can be scoped
- Partly
Some key types can be limited, others carry full rights.
- Expires
- No expiry option in Hetzner's documentation
- Switching keys
- Overlap windowRevocation time unknown
The provider doesn't say how fast a revoked key stops working.
What Crunu does here
Crunu doesn't reissue keys at providers. It shows which values to replace and keeps the new one.
Build the list for a departure with the offboarding checklistOn this page
Open the project in Hetzner Console, generate a second API token with the same permission as the old one, switch your tools to it, check a request, and then delete the old token. The two tokens work in parallel while you switch, so servers and pipelines keep running. Tokens are bound to the project they were created in, so the replacement must come from the same project (Hetzner docs). Hetzner's documentation doesn't say how quickly a deleted token stops working, so the last step includes checking for yourself.
Crunu doesn't generate or delete Hetzner tokens, and it has no Hetzner integration. It finds which Hetzner values a departing person could read, keeps the new token as a new version of the environment, and passes it to the tools that manage your project.
A token is a key to a whole project
A Hetzner Cloud token has very few settings, which is exactly why its reach is wide:
- Project. Each token belongs to one project and works only there. Hetzner advises creating a separate token for each project. Since the token alone decides which project a request runs in, a mix-up between two tokens means changes land in the wrong project.
- Permission. There are two levels (generating a token). Read allows only GET requests. Read & Write allows GET, DELETE, PUT and POST, so it can change or delete anything the API manages in that project.
- No expiry and no second look. The documentation describes no expiry setting, and once you close the window after creating a token, you can't view it again.
With no finer scopes available, your main controls are the project boundary and the number of tokens. Keep production in its own project, give each tool its own token, and use Read for anything that only watches, such as monitoring. A departure or a leak then touches one token in one project.
Reissue without downtime
- In Hetzner Console, open the project and go to Security, then API tokens, and choose Generate API token. Enter a description that names the tool using it, choose Read or Read & Write, and copy the token before closing the window.
- Save it in Crunu as
HETZNER_CLOUD_TOKENin the environment for that project, for exampledata-pipeline / production. Each save adds a version to the environment's history, with the author and time. - Switch every tool that manages the project. Terraform runs and deploy scripts launched with
crunu runread the latest version at start; a long-running controller started with--restart on-changerestarts on its own. - Send a read request with the new token, like the one below, and make sure it lists the resources of the right project.
- Delete the old token: in the same project, open Security, API tokens, select the token and delete it. A deleted item in Hetzner Console can't be restored. Then watch the tools for a while, and if one starts failing, it was still on the old token.
crunu run --env data-pipeline/production -- sh -c \
'curl -s https://api.hetzner.cloud/v1/servers -H "Authorization: Bearer $HETZNER_CLOUD_TOKEN"'The token travels in the Authorization: Bearer header, as in Hetzner's own examples. Running the request through crunu run keeps the value out of your shell history. Keeping one Crunu environment per Hetzner project mirrors the token boundary: the production token never sits next to the token of a staging project, people get access to each separately, and a reissue touches exactly one environment.
When to reissue a Hetzner token
- A departure. Reissue every Read & Write token the person could read, starting with production projects, and end their access to Hetzner Console. In Crunu, removing the person produces a reissue checklist of the values they received, by name.
- A leak. Delete the leaked token first and accept that its tools stop, then generate and deploy the replacement. A Read & Write token can delete servers and volumes, so a short outage is the cheaper side of the trade. Afterwards, check the project for resources you don't recognize.
- A schedule. Since nothing in Hetzner's documentation makes a token expire, nothing forces a reissue. Set your own interval, and use each round to delete tokens nothing uses.
What to rotate when a developer leaves covers the order for a full departure, including access to the servers themselves, and the offboarding checklist builds the list for your stack. Creating and deleting tokens is done in Hetzner Console (deleting a token); Crunu holds the new value and the record of when it changed.
Frequently asked questions
Something else? Write to support@crunu.com
Can one Hetzner Cloud token work in several projects?
No. Each API token is bound to the project it was created in and can't be used for other projects. Hetzner recommends a separate token for each project, so a reissue happens project by project.
Do Hetzner Cloud API tokens expire?
Hetzner's documentation describes no expiry setting for Cloud API tokens, so treat a token as valid until you delete it. Plan regular reissues yourself, and delete tokens no tool uses any more.
What can a Read & Write token do?
It may send GET, POST, PUT and DELETE requests, so it can make any change the API allows in its project, including deleting resources. A Read token is limited to GET requests.
Does Crunu reissue Hetzner tokens?
No. Crunu doesn't call the Hetzner API or Console. It shows which Hetzner values a departing person received, stores the new token as a new environment version and passes it to your tools through crunu run.
Sources
Every source this page relies on, with the date we last checked it.
- Hetzner Docs: Generating an API token · checked October 30, 2026
- Hetzner Docs: Using the API · checked October 30, 2026
- Hetzner Docs: Cancellations on Hetzner Console · checked October 30, 2026