We need to build a system where communities can create and manage webhooks.
This system allows users to:
Register webhook URLs
Select events to listen to
Set secrets for security
Define permissions
Enable/disable webhooks
π This is only setup/config layer, not delivery.
π― Goals
System must be:
- Secure (SSRF-safe, secret protected)
- Flexible (multi-event support)
- Scalable (multiple webhooks per community)
- Production-ready (validation + management APIs)
π§± CORE FEATURES
1οΈβ£ CREATE WEBHOOK
Endpoint
Payload
{
"name": "Discord Notifications",
"url": "https://discord.com/api/webhooks/xxx",
"events": [
"member.created",
"event.created",
"hackathon.created"
],
"secret": "optional-secret-key",
"permissions": ["read", "notify"]
}
Validations
URL Validation
-
must be HTTPS
-
valid domain
-
block:
- localhost
- 127.0.0.1
- internal IPs (SSRF protection)
Events Validation
Allowed events:
member.created
member.activated
event.created
event.updated
hackathon.created
community.approved
github.push
github.pr.opened
Secret Validation
- optional
- min length: 8
- must be hashed before storing
Flow
validate input
β validate URL
β validate events
β hash secret
β store webhook
β return success
2οΈβ£ LIST WEBHOOKS
Endpoint
Features
3οΈβ£ GET SINGLE WEBHOOK
4οΈβ£ UPDATE WEBHOOK
Endpoint
PATCH /api/v1/webhooks/:id
Allowed Updates
- name
- URL
- events
- permissions
- secret (re-hash)
5οΈβ£ DELETE WEBHOOK
DELETE /api/v1/webhooks/:id
6οΈβ£ ENABLE / DISABLE WEBHOOK
PATCH /api/v1/webhooks/:id/toggle
Purpose
- temporarily stop webhook without deleting
7οΈβ£ WEBHOOK TEST ENDPOINT
Endpoint
POST /api/v1/webhooks/:id/test
Purpose
- send test payload to URL
- verify integration works
Payload Example
{
"event": "test",
"message": "Webhook setup successful"
}
π SECURITY (VERY IMPORTANT)
1. SSRF Protection
Block:
localhost
127.0.0.1
internal IP ranges
2. Secret Handling
- hash using SHA256 or bcrypt
- never return secret in API
3. Authentication
- only authenticated users
- must belong to community
4. Authorization (RBAC)
Only allowed roles:
π§Ύ DATABASE DESIGN
Webhook Schema
communityId
name
url
events
secretHash
permissions
active
createdBy
createdAt
updatedAt
Indexes
communityId
events
active
β οΈ ERROR HANDLING
Standard Format
{
"success": false,
"message": "Invalid webhook URL"
}
Common Errors
- invalid URL
- invalid event type
- unauthorized
- webhook not found
π§ͺ TESTING
Unit Tests
- URL validation
- event validation
- secret hashing
Integration Tests
- create webhook
- update webhook
- delete webhook
Security Tests
- SSRF attempts
- invalid input
𧨠EDGE CASES
invalid URL
duplicate webhook
invalid events
large payload
malicious URL
π OBSERVABILITY
Logs
- webhook created
- webhook updated
- webhook deleted
Metrics
webhooks created
active webhooks
failed test requests
βοΈ PERFORMANCE
- indexed queries
- pagination for list API
π ENVIRONMENT
β
ACCEPTANCE CRITERIA
β Webhook can be created
β Events selection works
β Secret stored securely
β URL validation works
β SSRF protection active
β Webhook test endpoint works
β RBAC enforced
β APIs fully functional
π₯ FINAL SUMMARY
This system is:
Webhook configuration system (like Stripe / GitHub setup UI backend)
We need to build a system where communities can create and manage webhooks.
This system allows users to:
π This is only setup/config layer, not delivery.
π― Goals
System must be:
π§± CORE FEATURES
1οΈβ£ CREATE WEBHOOK
Endpoint
Payload
{ "name": "Discord Notifications", "url": "https://discord.com/api/webhooks/xxx", "events": [ "member.created", "event.created", "hackathon.created" ], "secret": "optional-secret-key", "permissions": ["read", "notify"] }Validations
URL Validation
must be HTTPS
valid domain
block:
Events Validation
Allowed events:
Secret Validation
Flow
2οΈβ£ LIST WEBHOOKS
Endpoint
Features
list all webhooks for community
pagination
filter by:
3οΈβ£ GET SINGLE WEBHOOK
4οΈβ£ UPDATE WEBHOOK
Endpoint
Allowed Updates
5οΈβ£ DELETE WEBHOOK
6οΈβ£ ENABLE / DISABLE WEBHOOK
Purpose
7οΈβ£ WEBHOOK TEST ENDPOINT
Endpoint
Purpose
Payload Example
{ "event": "test", "message": "Webhook setup successful" }π SECURITY (VERY IMPORTANT)
1. SSRF Protection
Block:
2. Secret Handling
3. Authentication
4. Authorization (RBAC)
Only allowed roles:
π§Ύ DATABASE DESIGN
Webhook Schema
Indexes
Standard Format
{ "success": false, "message": "Invalid webhook URL" }Common Errors
π§ͺ TESTING
Unit Tests
Integration Tests
Security Tests
𧨠EDGE CASES
π OBSERVABILITY
Logs
Metrics
βοΈ PERFORMANCE
π ENVIRONMENT
β ACCEPTANCE CRITERIA
β Webhook can be created
β Events selection works
β Secret stored securely
β URL validation works
β SSRF protection active
β Webhook test endpoint works
β RBAC enforced
β APIs fully functional
π₯ FINAL SUMMARY
This system is: