Skip to content

Best Practices for Sharing API Keys and Credentials

By Mor, Web DeveloperPublished Updated

Store API keys in a secrets manager, load them through environment variables, and when you have to hand a key to a person, send it once through a self-destructing link rather than chat or email. Every developer has pasted a key into a Slack message or dropped credentials into a shared document. It feels harmless in the moment, but these habits are one of the most common sources of security incidents in software teams.

Why API Keys End Up in Unsafe Places

The root cause is friction. Proper secrets management requires setup, tooling, and process. When a teammate needs a key right now to unblock their work, the path of least resistance is to paste it into chat. Development moves fast, and security practices that slow people down tend to get bypassed.

This is especially common during onboarding. New developers need access to staging environments, third-party services, and internal APIs. The quickest way to get them unblocked is often a DM with the credentials they need. The problem is that those credentials now live in a chat log indefinitely.

The Real Risks

Credentials Left Where Attackers Look

Once an attacker is inside, stored secrets turn a small breach into a large one. In the 2022 Uber breach, the attacker found a PowerShell script on a network share containing hardcoded admin credentials for Uber's privileged access management system, which opened up much of the rest of the company. In January 2023, CircleCI disclosed that malware on an engineer's laptop had stolen a logged-in session, which attackers used to take customer environment variables, tokens, and keys. These are not edge cases -- secrets stored where they are easy to reach represent a systemic pattern.

Secrets in Version Control

API keys that start in chat messages often end up hardcoded in source files or committed in .env files to version control. GitGuardian's State of Secrets Sprawl 2026 report counted 28.6 million new secrets leaked in public GitHub commits in 2025, a 34% increase on the year before, with keys for AI services growing fastest. The same report found that 64% of secrets leaked in 2022 were still valid four years later. Even in private repositories, credentials in commit history persist through git's immutable log.

Uncontrolled Access Scope

When credentials are shared informally, there is no audit trail of who has access. If a team member leaves or a contractor's engagement ends, there is no systematic way to know which credentials they received through chat messages. This leads to stale credentials with unknown access scope.

Best Practices for Credential Management

1. Use a Secrets Manager

Tools like HashiCorp Vault, AWS Secrets Manager, or Doppler are purpose-built for storing and distributing secrets. They provide access control, audit logging, automatic rotation, and encrypted storage. If your team is not using one, this should be a priority.

2. Environment Variables, Not Code

Never hardcode API keys in source files. Use environment variables loaded from .env files (excluded from version control via .gitignore) or injected by your deployment platform. This separates credentials from code and prevents accidental commits. A pre-commit secret scanner catches the mistakes that slip through anyway.

3. Self-Destructing Links for One-Time Transfers

Secrets managers solve the storage problem, but you still need a way to get credentials to someone for the first time -- especially during onboarding or when sharing with external collaborators who do not have access to your vault. This is where self-destructing links fill the gap.

Instead of pasting a key into Slack, create an encrypted note with the credential and send the link. The recipient opens it, copies the key into their local environment, and the note is destroyed. No persistent copy exists in any chat log.

4. Rotate After Sharing

Treat every credential share outside your normal tooling as temporary. Once the recipient has configured their environment, or once their access should end, rotate the key if the service supports it. This limits the window during which a leaked or intercepted credential remains valid.

5. Use Scoped and Short-Lived Tokens

Whenever possible, issue credentials with the minimum required permissions and the shortest practical expiration. A read-only API key that expires in 24 hours is far less dangerous if compromised than a full-access key with no expiration.

Fitting SneakNote Into Your Workflow

SneakNote is not a replacement for a secrets manager. It fills a specific gap: the moment when you need to transmit a credential to someone who cannot yet access your vault. Create a note with the API key, set an optional password for additional security, and send the link. The recipient reads the note once, and it is permanently deleted.

This works particularly well for sharing credentials with contractors, open-source collaborators, or new team members during their first day -- situations where setting up vault access takes time but the person needs to start working immediately. See SneakNote for teams for more ways teams use it.

Stop Pasting Keys Into Chat

The next time a colleague asks you for an API key, take ten seconds to create an encrypted, self-destructing note on SneakNote instead of pasting it into Slack. It is a small change that eliminates a significant and common security risk.