About api key generator
An API key identifies and authorises a client of your service. A readable prefix such as sk_live_ makes keys easy to recognise and helps secret scanners find leaks.
Design tips
- Use a prefix that shows the key type and environment (test or live).
- Make the random part long, at least 24 characters.
- Store keys hashed, and show the full key only once at creation.
If a key leaks
Revoke it at once and issue a new one. Rate limits and per-key permissions limit the damage.
Handle real secrets with care
Keep production keys and secrets in a secrets manager or environment variables, never in source code or chat messages, and rotate them if they may have leaked.
A worked example
A key such as sk_live_9fA3kQ2mZp7xL4vB8nR1tYc6 has a prefix that shows its type (secret key, live mode) and a random part. Because the prefix is recognisable, secret scanners can find leaked keys in code and alert you.
Key hygiene
- Give each integration its own key.
- Allow keys to be limited to specific actions or IP addresses.
- Log which key made a request so you can spot misuse.
