| Crates.io | birch |
| lib.rs | birch |
| version | 0.1.1 |
| created_at | 2025-11-13 05:16:00.815992+00 |
| updated_at | 2025-11-13 05:29:56.355823+00 |
| description | Peel. Rotate. Renew. - Secret rotation tool for local .env and production hosts |
| homepage | |
| repository | https://github.com/plyght/birch |
| max_upload_size | |
| id | 1930426 |
| size | 518,070 |
Peel. Rotate. Renew.
Birch is an open-source CLI tool for safe, fast secret rotation. It updates local .env files and production host secrets by name, without proxying traffic. Your applications call provider APIs directly with their own keys.
.env files atomically with rollback supportcargo install birch
cargo install --path .
Or download pre-built binaries from releases.
birch config init
This creates ~/.birch/config.toml with default settings.
birch rotate MY_API_KEY --env dev
This updates MY_API_KEY in your .env file and saves a rollback copy to .birch-rollback.
export VERCEL_TOKEN="your-token"
export VERCEL_PROJECT_ID="your-project-id"
birch rotate MY_API_KEY --env prod --service vercel --redeploy
This updates the secret in Vercel and optionally triggers a redeploy.
birch daemon start
The daemon listens on 127.0.0.1:9123 for rotation signals from your application:
curl -X POST http://127.0.0.1:9123/rotate \
-H "Content-Type: application/json" \
-d '{"secret_name": "MY_API_KEY", "env": "prod", "service": "vercel"}'
birch rollback MY_API_KEY --env prod --service vercel
birch audit MY_API_KEY --env prod
Set up a pool of API keys for automatic rotation when rate limits are hit:
# Create a pool with multiple keys
birch pool init TIKTOK_API_KEY --keys "sk_key1,sk_key2,sk_key3"
# Check pool status
birch pool status TIKTOK_API_KEY
# Rotate (automatically uses next available key from pool)
birch rotate TIKTOK_API_KEY --env prod --service vercel
When your app hits a rate limit (HTTP 429), it can trigger automatic rotation:
if (response.status === 429) {
await fetch('http://localhost:9123/rotate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
secret_name: 'TIKTOK_API_KEY',
env: 'prod',
service: 'vercel'
})
});
}
See Key Pool Documentation for details.
For even simpler integration, use the @inaplight/birch-client SDK that automatically handles rate limits:
npm install @inaplight/birch-client
import '@inaplight/birch-client/auto';
const response = await fetch('https://api.tiktok.com/v1/videos', {
headers: {
Authorization: `Bearer ${process.env.TIKTOK_API_KEY}`
}
});
That's it! The SDK automatically:
Works with Next.js, Express, vanilla Node.js, and any framework. See SDK Documentation for details.
Edit ~/.birch/config.toml:
audit_log_path = "/Users/you/.birch/logs"
cooldown_seconds = 60
rollback_window_seconds = 3600
daemon_bind = "127.0.0.1:9123"
pool_low_threshold = 2
[[maintenance_windows]]
start_hour = 2
end_hour = 6
days = ["Saturday", "Sunday"]
[connector_auth]
vercel_token = "optional-token-here"
Environment variables override config file settings:
BIRCH_AUDIT_LOG_PATHBIRCH_COOLDOWN_SECONDSBIRCH_ROLLBACK_WINDOW_SECONDSBIRCH_POOL_LOW_THRESHOLDVERCEL_TOKEN, NETLIFY_AUTH_TOKEN, RENDER_API_KEY, etc.VERCEL_TOKEN and VERCEL_PROJECT_IDNETLIFY_AUTH_TOKEN and NETLIFY_SITE_IDRENDER_API_KEY and RENDER_SERVICE_IDCLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID, and CLOUDFLARE_WORKER_NAMEFLY_API_TOKEN and FLY_APP_NAMEAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGIONGOOGLE_APPLICATION_CREDENTIALS and GCP_PROJECT_IDAZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID, and AZURE_VAULT_NAMENote: Cloud secret managers update secrets directly but do not automatically trigger application restarts. Restart your services manually or use the hosting provider connectors for automatic redeployment.
--dry-run to preview changes without applying them*** or last 4 chars)Complete documentation is available in the docs directory, powered by Fumadocs.
Quick links:
To run the documentation locally:
cd docs
bun install
bun run dev
Then open http://localhost:3000
Birch is a single Rust binary with:
No traffic proxying. No central secret storage. Just direct updates to your .env files and provider APIs.
MIT