Learn how to authenticate with the PhishFortress API using API keys and OAuth 2.0
PhishFortress API supports two authentication methods: API Keys for server-to-server communication and OAuth 2.0 for user-facing applications. All API requests must be authenticated to ensure security and proper access control.
API keys are the recommended method for server-to-server integrations and automated scripts.
OAuth 2.0 is recommended for user-facing applications that need to access PhishFortress on behalf of users.
https://auth.phishfortress.com/oauth/authorizehttps://auth.phishfortress.com/oauth/tokenHere are examples of how to authenticate with the PhishFortress API in different programming languages.
const axios = require('axios');
const apiKey = 'your_api_key_here';
const baseURL = 'https://api.phishfortress.com/v1';
const client = axios.create({
baseURL,
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
});
// Example: Get all campaigns
async function getCampaigns() {
try {
const response = await client.get('/campaigns');
console.log(response.data);
} catch (error) {
console.error('Error:', error.response.data);
}
}The PhishFortress API uses standard HTTP status codes to indicate the success or failure of requests.
| Status Code | Description | Common Causes |
|---|---|---|
| 200 | OK | Request successful |
| 401 | Unauthorized | Invalid or missing API key |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource doesn't exist |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server-side issue |
{
"error": {
"code": "INVALID_API_KEY",
"message": "The provided API key is invalid or has expired",
"details": {
"timestamp": "2024-01-15T10:30:00Z",
"request_id": "req_abc123"
}
}
}Use this simple endpoint to verify that your authentication is working correctly.
GET https://api.phishfortress.com/v1/auth/verify{
"authenticated": true,
"user": {
"id": "user_123",
"email": "admin@company.com",
"organization": "Acme Corp"
},
"permissions": ["campaigns:read", "campaigns:write", "users:read"]
}