Back to Documentation
Documentation / Developer Tools / Webhooks & Events

Webhooks & Events

Real-time event notifications for your applications

Webhooks Overview

Subscribe to events and receive HTTP POST notifications in real-time

Creating Webhooks

  1. Navigate to Settings → Developers → Webhooks
  2. Click + Create Webhook
  3. Enter your endpoint URL
  4. Select events to subscribe to
  5. Save and receive a webhook secret

Example POST request:

POST https://api.cognexiaai.com/v1/webhooks
Authorization: Bearer YOUR_API_KEY

{
  "url": "https://yourapp.com/webhook",
  "events": ["contact.created", "deal.closed"],
  "description": "Production webhook"
}

Available Events

CRM Events

  • contact.created
  • contact.updated
  • deal.created
  • deal.stage_changed
  • deal.closed

Finance Events

  • invoice.created
  • invoice.paid
  • payment.received
  • expense.submitted

HR Events

  • employee.created
  • attendance.logged
  • leave.requested
  • payroll.processed

System Events

  • user.logged_in
  • api_key.created
  • export.completed

Webhook Payload

{
  "id": "evt_123456",
  "type": "contact.created",
  "created": 1706543400,
  "data": {
    "object": {
      "id": "cnt_789",
      "firstName": "Jane",
      "lastName": "Doe",
      "email": "jane@example.com",
      "company": "Acme Corp",
      "createdAt": "2026-01-29T15:30:00Z"
    }
  }
}

Verifying Webhooks

Node.js Example

const crypto = require('crypto');

app.post('/webhook', (req, res) => {
  const signature = req.headers['x-cognexia-signature'];
  const secret = process.env.WEBHOOK_SECRET;
  
  const hmac = crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(req.body))
    .digest('hex');
  
  if (signature === hmac) {
    // Process event
    const event = req.body;
    console.log('Event:', event.type);
    res.sendStatus(200);
  } else {
    res.sendStatus(401);
  }
});

Python Example

import hmac
import hashlib

@app.route('/webhook', methods=['POST'])
def webhook():
    signature = request.headers.get('X-Cognexia-Signature')
    secret = os.environ.get('WEBHOOK_SECRET')
    
    computed = hmac.new(
        secret.encode(),
        request.data,
        hashlib.sha256
    ).hexdigest()
    
    if signature == computed:
        event = request.json
        print(f"Event: {event['type']}")
        return '', 200
    return '', 401

Best Practices

Respond Quickly

Return 200 status within 5 seconds. Process asynchronously.

Handle Retries

Events retry up to 3 times with exponential backoff

Idempotency

Use event ID to prevent duplicate processing

Next Steps