Skip to content

Webhooks

Integrate CloudSync with your workflow using webhooks. Get notified when files change, users join, or other events occur.

Setting Up Webhooks

Via Dashboard

  1. Go to Workspace Settings > Webhooks
  2. Click Add Webhook
  3. Enter your endpoint URL
  4. Select events to subscribe to
  5. Click Create

Via API

typescript
const webhook = await client.webhooks.create({
  workspace: 'my-project',
  url: 'https://your-app.com/webhooks/cloudsync',
  events: ['file.created', 'file.modified', 'file.deleted'],
  secret: 'whsec_your_secret_key'
})

Event Types

EventTrigger
file.createdNew file uploaded
file.modifiedFile contents changed
file.deletedFile removed
file.movedFile renamed/moved
workspace.member_addedNew member joined
workspace.member_removedMember left/removed
sync.completedSync operation finished
sync.errorSync error occurred

Webhook Payload

All webhooks include a standard payload structure:

json
{
  "id": "evt_abc123",
  "type": "file.modified",
  "timestamp": "2026-01-06T10:30:00Z",
  "workspace": {
    "id": "ws_xyz789",
    "name": "My Project"
  },
  "data": {
    "path": "/documents/report.pdf",
    "size": 1048576,
    "modifiedBy": "user@example.com",
    "version": 42
  }
}

Verifying Webhooks

All webhooks are signed with HMAC-SHA256. Verify the signature to ensure authenticity:

typescript
import crypto from 'crypto'

function verifyWebhook(payload: string, signature: string, secret: string): boolean {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex')
  
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(`sha256=${expected}`)
  )
}

// In your webhook handler
app.post('/webhooks/cloudsync', (req, res) => {
  const signature = req.headers['x-cloudsync-signature']
  const payload = JSON.stringify(req.body)
  
  if (!verifyWebhook(payload, signature, process.env.WEBHOOK_SECRET)) {
    return res.status(401).send('Invalid signature')
  }
  
  // Process the webhook
  handleWebhook(req.body)
  res.status(200).send('OK')
})

Retry Policy

Failed webhooks are retried with exponential backoff:

AttemptDelay
1Immediate
21 minute
35 minutes
430 minutes
52 hours

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

Testing Webhooks

Use the CLI to send test events:

bash
cloudsync webhooks test --workspace my-project --event file.created

Or trigger a test from the dashboard under Workspace Settings > Webhooks > Test.

Best Practices

Webhook Tips

  • Always verify webhook signatures
  • Respond quickly (within 5 seconds) to avoid timeouts
  • Use a queue for time-consuming processing
  • Log webhook payloads for debugging
  • Monitor webhook delivery in the dashboard

Released under the MIT License.