DocsBest practices

Securing your service

Protect your tokens, your account and your users.

Best practices 5 min read

A leaked token is the number one cause of compromised bots and APIs. Most incidents are avoidable with a few simple rules.

Do

  • Store every secret as an environment variable.
  • Rotate a token immediately if you think it leaked.
  • Enable two-factor authentication on your DIGITALYCloud and GitHub accounts.
  • Create one API key per tool, with a clear name.
  • Update dependencies regularly.

Don't

  • Commit .env files or paste tokens in your code.
  • Share your account password with teammates — invite them instead.
  • Print secrets in logs, even temporarily.
  • Reuse the same API key across every script.
  • Ignore security warnings from your package manager.

If a token leaks

  • Regenerate it at the source (Discord Developer Portal, Stripe, etc.).
  • Update the variable in Environment; the service restarts with the new value.
  • Remove it from your Git history — deleting the file in a new commit is not enough.
  • Review recent activity in your logs for anything unusual.

Keep dependencies healthy

bash
npm audit
npm outdated
npm update
GitHub scans public repositories for leaked tokens within minutes. Assume anything pushed publicly is compromised.
Was this article helpful?