Deploy key get deleted automatically on site delete | Deploy key lifetime

Hi there!

I’ve noticed a weird behavior with the deploy API and would like to know about the site deploy key lifetime.

The deploy key automatically gets deleted on site delete.

I’m using a template git repository to deploy sites on Netlify. Deploy key is generated once and added to the repo deploy keys on GitHub. Everything works fine but when I try to delete the site, it also deletes the deploy key if the site is the last one. And the deploy console shows could not read Username for ‘’ error on new site deploys.

Hey @fmunirdev,
Yes, we do that! It’s a security measure to ensure that we don’t leave deploy keys hanging out when they’re no longer associated with sites. Can you say more about what you would want/expect to happen instead?

Ahh, that’s great.

Actually, the deploy keys still exist on the GitHub repository (and the database) and the same deploy key will be used for the new deploys. But I think Netlify has nothing to do with it. I’ll have to handle it on my side.

Thanks for the clarification. Appreciate it. :clap:

1 Like