Developer Guide · Updated April 2026

How to Send API Keys Safely

Every developer has done it: pasting an API key into Slack, texting a database password, or committing a secret to a repo "just for now." This guide covers the right way to share credentials across your team — and the tools that make it painless.

Why API Keys Leak (and Why It Matters)

In 2023, GitHub reported that they detected over 100 million secret leaksin public repositories in a single year. GitGuardian's State of Secrets Sprawl report found that 1 in 10 code authors exposed a secret in 2023.

A leaked API key can give attackers access to your cloud infrastructure, customer data, billing accounts, and third-party services. The average cost of a credential-related breach exceeds $4.5 million (IBM Security, 2023).

Real-world impact:In 2024, a startup lost $45,000 in AWS charges overnight when a developer accidentally committed AWS keys to a public repository. Bots scan GitHub continuously for exposed credentials.

The types of secrets developers commonly need to share:

  • API keys — Stripe, Twilio, SendGrid, OpenAI, Google Cloud
  • Database credentials — PostgreSQL connection strings, MongoDB URIs
  • OAuth tokens — Access tokens, refresh tokens, client secrets
  • SSH keys — Server access for deployments, CI/CD
  • Environment variables — .env files for local development
  • Webhook secrets — Stripe webhook signing secrets, GitHub webhook tokens

5 Places You Should Never Put API Keys

💬

Slack / Teams / Discord

Messages are searchable, logged, and persist even after deletion. Anyone added to the channel later can find your keys.

📧

Email

Emails are stored indefinitely on multiple servers, forwarded unpredictably, and included in backups. Keys in email are permanent.

📝

Git Commits

Even if you delete the file, git log preserves every commit forever. Force-pushing doesn't help if it's already been cloned or mirrored.

📋

Shared Documents

Google Docs, Notion, Confluence — these are indexed, searchable, and accessible to anyone with the link or workspace access.

📱

Text Messages / SMS

Unencrypted, stored by carriers, synced to iCloud/Google backups, and visible on lock screens.

Rule of thumb:If a channel stores message history, it's the wrong channel for secrets. Use ephemeral, self-destructing delivery instead.

3 Safe Methods for API Key Handoffs

2

Secret Managers (AWS, GCP, Azure, Vault)

Best for production systems

For secrets your applications consume at runtime, use a dedicated secret manager:

  • AWS Secrets Manager — built-in rotation, IAM-scoped access
  • Google Secret Manager — integrates with Cloud Run, GKE
  • Azure Key Vault — certificates, keys, and secrets in one place
  • HashiCorp Vault — open-source, self-hosted, dynamic secrets

Best for: Production applications, CI/CD pipelines, microservice architectures.

3

Password Manager Shared Vaults

Best for recurring team access

If your team already uses 1Password, Bitwarden, or LastPass, their shared vault features let you store and rotate API keys with audit trails. Both parties need accounts on the same platform.

Best for: Teams that need persistent, shared access to the same set of rotating credentials.

Long-Term Secret Management

Sharing a key safely is only half the battle. Secrets need to be managed throughout their lifecycle:

✓ Do This

  • Store secrets in environment variables, never code
  • Use .gitignore for .env files
  • Rotate keys regularly (90-day maximum)
  • Use scoped permissions (least privilege)
  • Enable GitHub secret scanning alerts
  • Audit who has access quarterly

✗ Avoid This

  • Hardcoding keys in source files
  • Sharing one key across all environments
  • Using the same key for dev and production
  • Keeping keys active after team members leave
  • Skipping rotation because "it still works"
  • Using root or admin-level API keys
Pro tip:Set calendar reminders to rotate keys every 90 days. Most API providers let you create new keys before revoking old ones, so there's no downtime.

API Key Rotation Checklist

Use this checklist when onboarding a new developer or rotating compromised credentials:

Frequently Asked Questions

Is it safe to send API keys over Slack?

No. Slack stores full message history and makes it searchable by anyone in the workspace. A key shared in January is still findable in December. Use a self-destructing link instead.

What's the safest way to share API keys with a contractor?

Use a self-destructing encrypted link. The contractor opens the link once, copies the key, and the link is permanently destroyed. You can add passphrase protection for an extra layer of security.

I accidentally committed a secret to GitHub. What do I do?

Rotate the key immediately— don't waste time trying to scrub Git history. Generate a new key, update your deployments, and revoke the old one. Then use git filter-repo or BFG Repo-Cleaner to remove the secret from history.

Should I use environment variables or a secret manager?

Both. Use environment variables as the interface your application reads from. Use a secret manager (AWS Secrets Manager, Vault, etc.) as the source of truth that populates those environment variables at deploy time.

Need to share an API key right now?

Encrypt it in your browser. Send a one-time link. No sign-up required.

Share a Secret Securely →