Authentication
API authentication and key management
Authentication
All API requests require authentication using API keys.
API Keys
Creating Keys
- Go to Settings > API Keys
- Click Generate New Key
- Add a description (e.g., "CI/CD Pipeline")
- Select permissions scope
- Click Create
Your API key is only shown once. Copy it immediately and store it securely.
Key Permissions
| Scope | Capabilities |
|---|---|
| Read | View applications, pentests, and reports |
| Write | Create and modify applications |
| Scan | Trigger and manage pentests |
| Admin | Full access including key management |
Key Management
- List keys - View all active API keys
- Revoke key - Immediately disable a key
- Rotate key - Generate new key, old key expires in 24h
Using API Keys
Authorization Header
Include your API key in the Authorization header:
curl -X GET https://api.modernpentest.com/v1/applications \
-H "Authorization: Bearer YOUR_API_KEY"Request Example
const response = await fetch('https://api.modernpentest.com/v1/applications', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
});Security Best Practices
Do
- Store keys in environment variables
- Use secrets management (Vault, AWS Secrets Manager)
- Create separate keys per environment
- Rotate keys regularly
- Use minimum required permissions
Don't
- Commit keys to version control
- Share keys via email or chat
- Use production keys in development
- Give admin scope unnecessarily
- Log API keys
Environment Variables
Shell
export MODERNPENTEST_API_KEY="mp_live_xxxxx".env File
MODERNPENTEST_API_KEY=mp_live_xxxxxAdd .env to .gitignore:
.env
.env.localCI/CD
Store as secret in your CI/CD platform:
GitHub Actions:
env:
MODERNPENTEST_API_KEY: ${{ secrets.MODERNPENTEST_API_KEY }}GitLab CI:
variables:
MODERNPENTEST_API_KEY: $MODERNPENTEST_API_KEYKey Format
API keys follow this format:
mp_{environment}_{random_string}| Prefix | Environment |
|---|---|
mp_live_ | Production |
mp_test_ | Development/Staging |
Error Responses
401 Unauthorized
{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}Causes:
- Missing Authorization header
- Invalid API key format
- Revoked API key
403 Forbidden
{
"error": {
"code": "FORBIDDEN",
"message": "Insufficient permissions for this action"
}
}Causes:
- Key lacks required scope
- Attempting cross-organization access
- Resource-level restrictions
Last updated: December 8, 2025