Overview
Magpipe supports two authentication methods. Both use Bearer token authentication via theAuthorization header.
| Method | Format | Expiration | Best For |
|---|---|---|---|
| API Key | mgp_... | Never (until revoked) | Server-side integrations, scripts, CI/CD |
| Session Token | eyJ... (JWT) | 1 hour | Browser apps, short-lived sessions |
We recommend API keys for most integrations. They don’t expire and are easier to manage.
API Keys (Recommended)
API keys are long-lived tokens that persist until you revoke them. They start with themgp_ prefix.
Generating an API Key
- Log in to magpipe.ai
- Go to Settings → API
- Click Generate New Key
- Give the key a descriptive name (e.g., “Production Server”, “CI Pipeline”)
- Copy the key immediately — it won’t be shown again
Using an API Key
Node.js
Python
Key Properties
- Prefix: All keys start with
mgp_followed by 40 hex characters - Display: In the dashboard, keys show as
mgp_abc12345...(first 8 characters only) - Tracking: Each key tracks its
last_used_attimestamp - Limit: Maximum 10 active keys per account
Revoking a Key
- Go to Settings → API
- Find the key you want to revoke
- Click Revoke
- Confirm the action
Session Tokens
Session tokens are short-lived JWTs obtained by authenticating with email and password. They expire after 1 hour and can be refreshed.Obtaining a Session Token
Using a Session Token
Refreshing Session Tokens
Session tokens expire after 1 hour. Use the refresh token to get a new one:Error Responses
If authentication fails, you’ll receive a401 response:
- Missing
Authorizationheader - Invalid or expired token
- Revoked API key
Security Best Practices
Use environment variables
Use environment variables
Never hardcode tokens in source code. Use environment variables instead.
Use API keys for server-side code
Use API keys for server-side code
API keys are ideal for backend services and scripts. Use session tokens only for browser-based apps where you authenticate with user credentials.
Name your keys descriptively
Name your keys descriptively
Use names like “Production Server” or “Staging CI” so you know which key is used where.
Rotate keys periodically
Rotate keys periodically
Generate new keys and revoke old ones regularly to limit exposure.
Monitor usage
Monitor usage
Check your API key
last_used_at timestamps in the dashboard to detect unauthorized usage.