Cliq Docs
Developers

Webhooks

Receive real-time updates from Cliq with webhooks

Webhooks

Webhooks allow you to receive real-time notifications when events occur in your Cliq workspace.

Overview

Instead of polling the API for changes, webhooks push updates to your server as they happen. This is more efficient and provides near-instant notifications.

Setting Up Webhooks

Create a Webhook Endpoint

First, create an endpoint on your server to receive webhook events:

// Express.js example
import express from 'express';
import crypto from 'crypto';

const app = express();
app.use(express.json());

app.post('/webhooks/cliq', (req, res) => {
  // Verify the webhook signature
  const signature = req.headers['x-cliq-signature'];
  const isValid = verifySignature(req.body, signature);
  
  if (!isValid) {
    return res.status(401).send('Invalid signature');
  }
  
  // Process the event
  const event = req.body;
  console.log('Received event:', event.type);
  
  // Respond quickly
  res.status(200).send('OK');
  
  // Process asynchronously
  processEvent(event);
});

Register Your Webhook

  1. Go to SettingsWebhooks
  2. Click Create Webhook
  3. Enter your endpoint URL
  4. Select the events you want to receive
  5. Click Create

Event Types

Issue Events

EventDescription
issue.createdA new issue was created
issue.updatedAn issue was updated
issue.deletedAn issue was deleted
issue.status_changedAn issue's status changed
issue.assignedAn issue was assigned

Comment Events

EventDescription
comment.createdA new comment was added
comment.updatedA comment was edited
comment.deletedA comment was deleted

Project Events

EventDescription
project.createdA new project was created
project.updatedA project was updated
project.deletedA project was deleted

Member Events

EventDescription
member.joinedA new member joined
member.leftA member left the workspace
member.role_changedA member's role was changed

Webhook Payload

All webhook payloads follow this structure:

{
  "id": "evt_123456789",
  "type": "issue.created",
  "created_at": "2025-01-15T10:30:00Z",
  "workspace_id": "ws_abc123",
  "data": {
    "id": "issue_xyz789",
    "title": "New feature request",
    "status": "backlog",
    "priority": "medium",
    "created_by": "user_456"
  }
}

Verifying Webhooks

Always verify webhook signatures to ensure requests are from Cliq:

import crypto from 'crypto';

function verifySignature(payload: any, signature: string): boolean {
  const secret = process.env.CLIQ_WEBHOOK_SECRET;
  
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(payload))
    .digest('hex');
  
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expectedSignature)
  );
}

Retry Policy

If your endpoint doesn't respond with a 2xx status code, Cliq will retry:

AttemptDelay
1Immediate
21 minute
35 minutes
430 minutes
52 hours

After 5 failed attempts, the webhook is marked as failing and you'll receive an email notification.

Best Practices

1. Respond Quickly

Return a 200 response immediately, then process the event asynchronously:

app.post('/webhooks/cliq', async (req, res) => {
  // Respond immediately
  res.status(200).send('OK');
  
  // Process in background
  await queue.add('process-webhook', req.body);
});

2. Handle Duplicates

Webhooks may be delivered more than once. Use the event id to deduplicate:

const processedEvents = new Set();

async function processEvent(event: WebhookEvent) {
  if (processedEvents.has(event.id)) {
    return; // Already processed
  }
  
  processedEvents.add(event.id);
  // Process the event
}

3. Use a Queue

For high-volume webhooks, use a message queue:

import { Queue } from 'bullmq';

const webhookQueue = new Queue('webhooks');

app.post('/webhooks/cliq', async (req, res) => {
  await webhookQueue.add('process', req.body);
  res.status(200).send('OK');
});

// Worker processes events
const worker = new Worker('webhooks', async (job) => {
  const event = job.data;
  // Process event
});

Testing Webhooks

Using the Dashboard

  1. Go to SettingsWebhooks
  2. Select your webhook
  3. Click Send Test Event
  4. Choose an event type
  5. View the response

Using ngrok for Local Development

# Start ngrok
ngrok http 3000

# Use the ngrok URL as your webhook endpoint
# https://abc123.ngrok.io/webhooks/cliq

Troubleshooting

Webhook Not Receiving Events

  1. Check the webhook is enabled in Settings
  2. Verify your endpoint URL is correct
  3. Check your server logs for errors
  4. Ensure your endpoint responds with 200

Invalid Signature Errors

  1. Verify you're using the correct webhook secret
  2. Ensure you're verifying the raw request body
  3. Check for any middleware modifying the body

Events Delayed or Missing

  1. Check the webhook delivery logs in Settings
  2. Look for failed delivery attempts
  3. Verify your endpoint is responding quickly