API keys are passwords that don't expire, don't have two-factor authentication, and often grant far more access than anyone intended. And developers share them constantly: onboarding a teammate, setting up a contractor, handing a key to CI, or giving one to an AI coding agent.
Here's how to do that without leaving a trail of live keys behind you.
Where API keys actually leak
Leaked keys rarely come from sophisticated attacks. They come from ordinary places:
- Chat history. A key pasted into Slack or Teams is stored indefinitely and is searchable by everyone in the channel, including future members.
- Git repositories. A key committed once stays in the history even after you delete it. Automated scanners watch public repositories for keys within minutes of a push.
- Tickets and docs. Jira tickets, Notion pages and Google Docs get shared and exported far beyond their original audience.
- Logs and screenshots. Keys printed by scripts end up in CI logs, terminal recordings and screenshots in bug reports.
- AI transcripts. Keys pasted into an AI chat sit in the conversation history.
The common thread: the key gets copied somewhere persistent and searchable.
Rule 1: Give people their own key when you can
The best way to share a key is not to. Most providers (AWS, Stripe, OpenAI, GitHub, Google Cloud) let you create separate keys or users per person or per service. Separate keys mean:
- You can revoke one without breaking everyone else.
- Usage logs show who did what.
- Each key can have only the permissions it needs.
Rule 2: Store shared keys in a secrets manager
Keys that services and teams use over time belong in a secrets manager: AWS Secrets Manager, Google Secret Manager, HashiCorp Vault, Doppler, Infisical, 1Password, or your hosting platform's environment variables. These give you access control, audit logs and rotation.
Rule 3: Hand off keys with a one-time link
There's always a moment where a key has to move from one place to another: from the provider's dashboard to a teammate, from you to a contractor, from one machine to another. That's where keys usually get pasted into chat.
Use a one-time link instead. With Dropzone:
- Paste the key (or upload a
.envfile) at dropzone.sh. - Send the link over Slack, email or anywhere else.
- Your teammate opens it once. The key is shown, then deleted from Dropzone's servers.
What's left in Slack is a link that no longer works. If someone searches the channel next year, they find nothing useful.
From a terminal, the Dropzone CLI encrypts on your machine, so the key never touches Dropzone in readable form:
curl -fsSO https://dropzone.sh/dropzone.mjs
echo "sk_live_..." | node dropzone.mjs send # prints a one-time link
node dropzone.mjs open "$LINK" # recipient: prints the key, onceRule 4: Scope and rotate
- Give each key the least access it needs. A key for reading analytics shouldn't be able to issue refunds.
- Set expiry dates where your provider allows it.
- Rotate keys when someone leaves or when a key may have been exposed.
- Rotate immediately if a one-time link shows "already opened" before your recipient got to it. Someone else saw the key.
Sharing keys with AI coding agents
Coding agents like Claude Code and Cursor often need keys to run code. Pasting a key into the chat puts it in the transcript. Instead, let the agent open a one-time link and write the key straight to a file, so it never appears in the conversation:
node dropzone.mjs open "$LINK" -o .envDropzone also runs an MCP server so agents can create and open links directly. See Give your coding agent a .env file for a full walkthrough.
Checklist
- Separate keys per person or service where possible
- Shared keys live in a secrets manager, not in chat or docs
- Handoffs use one-time links
-
.envfiles are in.gitignore - Keys are scoped and have expiry dates where supported
- Keys are rotated when people leave or exposure is suspected
Related: How to share .env files with your team · Why developers still share secrets in plaintext