Overview
Pwnbook API authentication uses API keys. API keys are long-lived credentials scoped to an organization with fine-grained permission scopes. Every API request must include a valid API key in theAuthorization header.
Generating an API key
API keys are created per organization. You need Admin or Owner access to generate an API key.Create a new key
Click New API Key.Enter a descriptive name for the key. Choose a name that identifies what it will be used for, such as “CI Pipeline”, “SIEM Integration”, or “Custom Dashboard”.
Select scopes
Choose the permission scopes for this key. Select only the scopes needed for the key’s intended purpose (principle of least privilege).See Scopes and permissions below for a full list.
Using API keys in requests
Include the API key in theAuthorization header of every request:
pwbk_live_ for production keys and pwbk_test_ for test keys.
Example with curl
Example with JavaScript (fetch)
Example with Python (requests)
Scopes and permissions
API keys are restricted to the scopes selected at creation time. Attempting an action not covered by the key’s scopes returns a403 Forbidden response.
Available scopes
| Scope | Description |
|---|---|
engagements:read | List and read engagement details |
engagements:write | Create, update, and archive engagements |
engagements:delete | Delete engagements |
targets:read | Read recon targets and scan results |
targets:write | Add and update targets, trigger scans |
tasks:read | Read tasks across engagements |
tasks:write | Create, update, and close tasks |
wiki:read | Read wiki pages |
wiki:write | Create and edit wiki pages |
reports:read | Read generated reports |
reports:write | Create and update reports |
organizations:read | Read organization details and member list |
organizations:write | Update organization settings, invite members |
api-requests:read | Read saved API requests |
api-requests:write | Create and execute API requests |
Recommended scopes by use case
| Use case | Recommended scopes |
|---|---|
| Read-only dashboard integration | engagements:read, tasks:read, reports:read |
| CI/CD pipeline integration | engagements:read, targets:write, tasks:write |
| Report automation | engagements:read, reports:read, reports:write, wiki:read |
| Full automation | All scopes relevant to your use case |
Viewing and managing API keys
To view all API keys for your organization:- Go to Organization Settings → API Keys.
- The list shows all keys with their names, scopes, creation date, and last-used timestamp.
Rotating API keys
To rotate an API key:- Generate a new API key with the same scopes as the key being rotated.
- Update your integration to use the new key.
- Verify the integration is working with the new key.
- Delete the old key from Organization Settings → API Keys.
Revoking API keys
To immediately invalidate an API key:- Go to Organization Settings → API Keys.
- Click the … menu next to the key.
- Select Delete Key.
- Confirm the deletion.
401 Unauthorized response.
Security best practices
- Never commit API keys to version control. Use environment variables or a secrets manager.
- Use the minimum required scopes. Don’t grant
engagements:deleteto a key that only needs to read data. - Rotate keys regularly. Especially for long-lived integrations, rotate keys every 90 days.
- Monitor last-used timestamps. Delete keys that haven’t been used in 30+ days.
- Use separate keys per integration. This makes it easy to revoke a single integration without affecting others.