Webhooks
Webhooks allow AMS to push real-time notifications to your systems whenever specific events occur in the platform. Instead of polling the API, your endpoint receives an HTTP POST request the moment something happens — a new member joins, a payment is received, or a job is applied for.
Setting Up a Webhook
Create a webhook subscription by POSTing to the webhooks endpoint with your target URL and the list of events you want to subscribe to:
curl -X POST https://yourdomain.ams.hkus1.s4s.host/api/v1/webhooks \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "url": "https://yourapp.example.com/webhooks/ams", "events": ["member.created", "payment.received", "event.created"], "secret": "your-webhook-signing-secret", "active": true, "description": "Main app webhook" }'
Supported Events
| Event | Trigger |
|---|---|
member.created | A new member profile is created |
member.updated | A member's profile data is changed |
member.deleted | A member is deleted or deactivated |
event.created | A new event is published |
event.updated | Event details are modified |
event.cancelled | An event is cancelled |
registration.created | A member registers for an event |
registration.cancelled | A registration is cancelled |
payment.received | A payment is successfully processed |
payment.failed | A payment attempt fails |
job.posted | A new job listing is published |
job.applied | A member applies for a job |
Webhook Payload Structure
All webhook deliveries share the same envelope structure regardless of event type:
{
"id": "whe_01HXYZ",
"event": "member.created",
"created_at": "2026-03-14T10:23:45Z",
"tenant_id": "ten_pasha",
"data": {
"id": "mem_01HABC",
"first_name": "Sarah",
"last_name": "Ahmed",
"email": "sarah.ahmed@example.com",
"membership_type": "full",
"status": "active",
"joined_at": "2026-03-14T10:23:44Z"
}
}
Signature Verification
Every webhook delivery includes an X-AMS-Signature header containing an HMAC-SHA256 signature of the raw request body, signed with your webhook secret. Always verify this signature before processing the payload to ensure the request is genuine.
function verifyWebhook(string $payload, string $secret, string $header): bool { $signature = hash_hmac('sha256', $payload, $secret); $expected = 'sha256=' . $signature; return hash_equals($expected, $header); } // Usage in Laravel controller $payload = $request->getContent(); $secret = config('services.ams.webhook_secret'); $header = $request->header('X-AMS-Signature'); if (!verifyWebhook($payload, $secret, $header)) { return response('Unauthorized', 401); }
const crypto = require('crypto'); function verifyWebhook(payload, secret, header) { const signature = 'sha256=' + crypto .createHmac('sha256', secret) .update(payload) .digest('hex'); return crypto.timingSafeEqual( Buffer.from(signature), Buffer.from(header) ); }
Retry Logic
AMS considers a webhook delivery successful if your endpoint returns an HTTP 2xx status code within 10 seconds. If the delivery fails, AMS will retry up to 3 times using exponential backoff:
| Attempt | Delay After Failure |
|---|---|
| 1st retry | 5 minutes |
| 2nd retry | 30 minutes |
| 3rd retry | 2 hours |
After 3 failed retries, the webhook delivery is marked as failed. You can manually re-trigger failed deliveries from the webhook logs page or via the API.
Webhook Logs
View delivery history for a webhook subscription:
curl -X GET https://yourdomain.ams.hkus1.s4s.host/api/v1/webhooks/wh_01HXYZ/logs \
-H "Authorization: Bearer $TOKEN"
Testing Webhooks
Send a test payload to your webhook endpoint without triggering a real event:
curl -X POST https://yourdomain.ams.hkus1.s4s.host/api/v1/webhooks/wh_01HXYZ/test \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"event": "member.created"}'
Local Development with ngrok
To receive webhooks during local development, use ngrok to expose your local server to the internet:
# Install ngrok, then start a tunnel on your local port ngrok http 3000 # ngrok will output a public URL like: # https://abc123.ngrok-free.app # Use this URL when creating your webhook # "url": "https://abc123.ngrok-free.app/webhooks/ams"