API Keys
Understanding API Keys
Section titled “Understanding API Keys”API keys let a server-side sensor (the Node SDK, the PHP sensor, the WordPress plugin, or your own code) report to WebDecoy’s ingest service without a user login.
API Key Use Cases
Section titled “API Key Use Cases”| Use Case | Description |
|---|---|
| SDK Authentication | @webdecoy/node and its framework adapters, or the PHP sensor |
| WordPress Plugin | Connect the plugin to your account |
| Custom Integrations | Send detections from your own code to the ingest API |
API Key Format
Section titled “API Key Format”WebDecoy API keys follow this format:
sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxsk_- Secret key prefixlive_- Environment (live = production)xxxx...- 32-character random secret
Key Security
Section titled “Key Security”| Aspect | Best Practice |
|---|---|
| Storage | Environment variables, not code |
| Access | Principle of least privilege |
| Rotation | Rotate periodically |
| Monitoring | Track key usage |
| Revocation | Revoke compromised keys immediately |
Creating API Keys
Section titled “Creating API Keys”Step-by-Step Guide
Section titled “Step-by-Step Guide”-
Navigate to API Keys
- Click API Keys in the sidebar (
/settings/api-keys)
- Click API Keys in the sidebar (
-
Click “Create API Key”
- The create key dialog opens
-
Configure the Key
Field Description Key Name Descriptive name (e.g., “Production SDK”) Property Scope (Optional) Limit to one property, or All Properties Scopes What the key can access Expiration Never, 30, 90 or 180 days, or 1 year -
Click “Create”
- The full API key is displayed
- Copy it now - it won’t be shown again!
-
Store Securely
- Add to your environment variables
- Never commit to source control
Scopes
Section titled “Scopes”Scopes limit what an API key can do:
| Scope | Permissions |
|---|---|
detections:read |
Read detection data |
detections:write |
Submit detections |
domains:read |
List domains |
domains:write |
Create/modify domains |
decoy-delivery:write |
Report acknowledged decoy delivery from one explicitly selected property |
New keys default to detections:read + detections:write. Detection, violation and AI referral endpoints require detections:write. The decoy delivery receipt endpoint requires decoy-delivery:write and a property belonging to the key’s organization; the key dialog and backend refuse an unbound delivery reporter. Select only that scope for a dedicated delivery key. See decoy delivery accounting.
Scope Recommendations
Section titled “Scope Recommendations”| Use Case | Recommended Scopes |
|---|---|
| WordPress Plugin | detections:read, detections:write (the default) |
| Node SDK or PHP sensor | detections:read, detections:write (the default) |
| Controlled decoy response writer | decoy-delivery:write plus one registered property |
Property Scoping
Section titled “Property Scoping”Optionally limit an API key to a specific property:
| Setting | Behavior |
|---|---|
| No property (default) | Access to all organization resources |
| Specific property | Only that property’s data accessible |
Use property scoping when:
- Different teams manage different properties
- Limiting blast radius of key compromise
- Client isolation (agencies)
Expiration
Section titled “Expiration”Set automatic expiration:
| Setting | When to Use |
|---|---|
| Never | Permanent keys for production |
| 30 days | Temporary testing |
| 90 days | Short-term integrations |
| 180 days | Semi-annual rotation |
| 1 year | Annual rotation |
Managing API Keys
Section titled “Managing API Keys”Viewing API Keys
Section titled “Viewing API Keys”Click API Keys in the sidebar to see:
| Column | Description |
|---|---|
| Name | Your key name, with an Expired or Revoked chip when that applies |
| Key | The key prefix, first 16 characters (for identification) |
| Scopes | Assigned permissions |
| Last Used | Most recent authenticated request |
| Created | Creation timestamp |
| Actions | Delete (revoke) the key |
Identifying Keys
Section titled “Identifying Keys”Since you can’t see the full key after creation, use:
- Name: Choose descriptive names
- Key Prefix: First 16 chars visible (e.g.,
sk_live_abc12345) - Last Used: Timestamp helps identify active keys
Revoking API Keys
Section titled “Revoking API Keys”To revoke (permanently disable) a key:
- Click API Keys in the sidebar
- Find the key in the list
- Click the delete (trash) icon, Delete API key
- Confirm the revocation
What happens:
- Key stops working immediately
- All API calls with that key fail
- Key cannot be re-enabled
- Create a new key if needed
When to revoke:
- Key may be compromised
- Employee leaving
- Project completed
- Rotating keys
Key Rotation Best Practices
Section titled “Key Rotation Best Practices”- Create new key with same scopes
- Update your application with new key
- Test that new key works
- Revoke old key after confirming
- Document the rotation
Monitoring Key Usage
Section titled “Monitoring Key Usage”Track API key activity:
- Last Used column shows recent activity
- Inactive keys may indicate configuration issues
Using API Keys
Section titled “Using API Keys”In Environment Variables
Section titled “In Environment Variables”# .env fileWEBDECOY_API_KEY=sk_live_your_key_hereconst apiKey = process.env.WEBDECOY_API_KEY;// PHP$apiKey = getenv('WEBDECOY_API_KEY');In HTTP Requests
Section titled “In HTTP Requests”Include the API key in the Authorization header of requests to the ingest API:
Authorization: Bearer sk_live_your_key_hereExample cURL (checks a key and returns its organization, property and scopes):
curl https://ingest.webdecoy.com/api/v1/auth/validate-key \ -H "Authorization: Bearer sk_live_your_key_here"In SDKs
Section titled “In SDKs”// Node.js SDKimport { WebDecoy } from '@webdecoy/node';
const webdecoy = new WebDecoy({ apiKey: process.env.WEBDECOY_API_KEY,});// PHP sensor (webdecoy/sensor)use WebDecoy\Sensor\{Sensor, Config};
$sensor = new Sensor(new Config( apiKey: getenv('WEBDECOY_API_KEY'),));API Key Security Checklist
Section titled “API Key Security Checklist”- Store keys in environment variables
- Use minimal required scopes
- Rotate keys periodically
- Revoke unused keys
- Use descriptive key names
- Monitor key usage
- Set expiration for temporary keys
Don’ts
Section titled “Don’ts”- Commit keys to Git repositories
- Share keys in chat/email
- Use production keys in development
- Grant more scopes than needed
- Use same key for multiple purposes
- Ignore unused/old keys
If a Key Is Compromised
Section titled “If a Key Is Compromised”- Revoke immediately - Don’t wait
- Create new key with same scopes
- Update applications with new key
- Review logs for unauthorized access
- Assess damage from compromised period