Authorization header, and control access with scopes. This page explains the full lifecycle: creating a key, using it in code, choosing the right permissions, and rotating it when needed.
Get an API Key
- Sign in to the Moonshadow dashboard.
- Open Settings > API Keys.
- Click Generate Key.
- Enter a descriptive name (for example, “production-deploy” or “ci-runner”).
- Select the scopes you need (see the scopes table below).
- Copy the token immediately. Moonshadow shows it only once.
Treat API keys like passwords. Do not expose them in client-side code, public repositories, or browser extensions.
Pass the API Key in Requests
Include the key in theAuthorization header as a Bearer token on every call to https://api.moonshadow.dev/v1.
Scopes
Scopes restrict what an API key can do. Choose the minimum set required for your integration.
A key with
write scope implicitly includes read. A key with admin scope includes read and write. You can assign scopes per workspace if you generate the key from a workspace settings page.
Key Rotation
Rotate keys regularly to limit exposure from leaks or employee offboarding.- In the dashboard, go to Settings > API Keys.
- Click Rotate next to the key you want to replace.
- Moonshadow creates a new key with the same scopes and deactivates the old one after a 24-hour grace period.
- Update your environment variables and redeploy during the grace period.
Environment Keys
Moonshadow supports separate API keys for production and staging environments. Prefixes help you tell them apart:- Production keys start with
ms_live_. - Staging keys start with
ms_test_.
Security Best Practices
- Never commit API keys to version control. Use
.envfiles and secret managers. - Use read-only keys for monitoring dashboards and write keys for automation services.
- Rotate keys every 90 days or immediately after a team member leaves.
- Restrict keys to the smallest set of workspaces and scopes possible.
