> ## Documentation Index
> Fetch the complete documentation index at: https://core.anylayer.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks Guide

> Setting up and using ZKScore webhooks for real-time notifications

## Overview

Webhooks enable real-time notifications when scores, achievements, or attestations change. This guide covers webhook setup and best practices.

## Setting Up Webhooks

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api-mainnet.onzks.com/api/v1/webhooks \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "url": "https://your-app.com/webhooks/zkscore",
      "events": ["score.updated", "achievement.claimed"],
      "secret": "your_webhook_secret"
    }'
  ```

  ```javascript JavaScript theme={null}
  // Handle webhook
  app.post('/webhooks/zkscore', (req, res) => {
    const signature = req.headers['x-zkscore-signature'];
    
    // Verify signature
    const isValid = verifyWebhookSignature(req.body, signature, webhookSecret);
    
    if (!isValid) {
      return res.status(401).send('Invalid signature');
    }
    
    // Process event
    const { event, data } = req.body;
    
    if (event === 'score.updated') {
      console.log(`Score updated for ${data.address}: ${data.newScore}`);
    }
    
    res.status(200).send('OK');
  });
  ```
</CodeGroup>

## Best Practices

1. **Verify Signatures**: Always verify webhook signatures
2. **Idempotency**: Handle duplicate events
3. **Async Processing**: Process webhooks asynchronously
4. **Monitoring**: Monitor webhook delivery
5. **Error Handling**: Retry failed webhooks

## Related Documentation

* [API Keys](/guides/api-keys)
* [Advanced Webhooks](/advanced/webhooks-advanced)
