# Webhooks

Webhooks send an HTTP POST to your endpoint when something happens in a campaign, for example an SMS is delivered, an email is opened or a call is answered. Use them instead of polling the API.

## Get started

1. Build an endpoint that accepts POST requests (see [Create a handler](#create-a-handler))
2. Test it locally
3. [Create the webhook in Wiraya](#create-the-webhook-in-wiraya) with your URL, a secret and the events you want
4. [Verify the signature](#verify-webhook-signatures) of every request


One webhook can receive several event types, or you can create one webhook per event type.

## Create the webhook in Wiraya

You need administrator rights in your organization to manage webhooks.

1. Log in to Wiraya.
2. In the left menu, under **Settings**, click **Organizational Settings**.
3. Open the **Integration** tab.
4. In the **Webhooks** section, click **New Webhook**.
5. Fill in the form:
  - **Name of the webhook**: a name that tells you where events go, for example `CRM`.
  - **Secret**: a shared secret of your choice. Wiraya uses it to sign every request, and your endpoint uses it to [verify the signature](#verify-webhook-signatures). Store it where your endpoint can read it.
  - **HTTPS URL**: the public address of your endpoint. It must start with `https://`.
  - **Event Types**: the events to send to this URL. See [List of supported events](#list-of-supported-events).
6. Click **Create Webhook**.


To change or remove a webhook later, open the menu (⋮) on its row in the same list and choose **Edit** or **Delete**. When you edit a webhook, leave **Secret** blank to keep the current secret.

## Events

### List of supported events

Event
Description
email_delivered
The email has been sent and was successfully received and accepted by the recipient's email server.
email_bounced
The email could not be delivered to the recipient's email server due to permanent issues. These issues may encompass factors such as bounced, or complained addresses, or addresses rejected by an Email Service Provider.
email_failed
The email could not be delivered to the recipient's email server due to permanent issues.
email_clicked
The email recipient has clicked on a link within the email.
email_opened
The email recipient has opened the email.
sms_delivered
The SMS message has been delivered.
sms_failed
The SMS message failed to be delivered.
voice_call_answered
The call was answered.
voice_call_unanswered
The line called was busy or failed to answer.
voice_call_failed
The call failed.
frequency_rate_limit_reached
The contact attempt could not be made because the specified phone number or email address reached the frequency rate limit. The frequency rate limit can be configured at the campaign level to restrict how often a phone number or email address can be contacted within a certain period.
### Create a handler

Your endpoint must accept POST requests over HTTPS: the webhook URL must start with `https://`. To test a handler on your own machine, expose it through a tunnel (see [Testing your webhooks](#testing-your-webhooks)).

Set up your endpoint function so that it:

1. Handles POST requests with a JSON payload consisting of an event object
2. Returns `2xx` before any slow work. Any other status, `4xx` included, makes Wiraya retry the request (see [Delivery and retries](#delivery-and-retries))
3. Verifies the webhook signature to ensure the request is coming from Wiraya
4. Processes the event based on the event type


#### Example endpoint

Node.js/Express
```javascript
const express = require('express');
const bodyParser = require('body-parser');
const crypto = require('crypto');

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

// Secret key for webhook verification
const WEBHOOK_SECRET = 'My Super Secret'; // Replace with your actual secret key

// Verify the signature
function verifySignature(payload, signature) {
const calculatedSignature = crypto
    .createHmac('sha256', WEBHOOK_SECRET)
    .update(payload.timestamp + payload.data)
    .digest('hex');

const expected = Buffer.from(calculatedSignature);
const received = Buffer.from(String(signature));
// timingSafeEqual throws if the lengths differ
return received.length === expected.length && crypto.timingSafeEqual(received, expected);
}

// Webhook endpoint
app.post('/webhook', (req, res) => {
try {
    const { signature, timestamp, data } = req.body;

    if (!signature || !timestamp || !data) {
      console.log('Missing required webhook parameters');
      return res.status(400).send('Bad Request');
    }

    // Verify signature
    if (!verifySignature(req.body, signature)) {
      console.log('Invalid webhook signature');
      return res.status(401).send('Unauthorized');
    }

    // Optional: Verify timestamp to prevent replay attacks
    const currentTime = Date.now() * 1000; // Convert to microseconds
    const timeDifference = currentTime - timestamp;
    // Retries keep the original timestamp, so allow 10 minutes
    if (timeDifference > 600000000) { // 10 minutes in microseconds
      console.log('Webhook timestamp too old');
      return res.status(400).send('Bad Request');
    }

    // Parse the data string to JSON
    const parsedData = JSON.parse(data);

    // Process the webhook based on event type
    switch (parsedData.event) {
    case 'email_delivered':
        console.log(`Email delivered to ${parsedData.profile.email_address}`);
        // Add your custom logic here
        break;
    case 'sms_delivered':
        console.log(`SMS delivered to ${parsedData.profile.phone_number}`);
        // Add your custom logic here
        break;
    case 'voice_call_answered':
        console.log(`Voice call answered by ${parsedData.profile.phone_number}`);
        // Add your custom logic here
        break;
    // Add other event types as needed
    default:
        console.log(`Unhandled event type: ${parsedData.event}`);
    }
    
    // Return a success response immediately, before performing any time-consuming tasks
    res.status(200).json({ received: true });
} catch (error) {
    console.error('Webhook processing error:', error);
    res.status(500).json({ error: 'Internal server error' });
}
});

// Start the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`Webhook server running on port ${PORT}`);
});
```

Python/Flask
```python
from flask import Flask, request, jsonify
import hmac
import hashlib
import json
import time

app = Flask(__name__)

# Secret key for webhook verification
WEBHOOK_SECRET = 'My Super Secret'  # Replace with your actual secret key

# Verify the signature
def verify_signature(payload, signature):
    # Convert timestamp to string if it's not already
    timestamp_str = str(payload['timestamp'])
    data_str = payload['data']
    
    calculated_signature = hmac.new(
        WEBHOOK_SECRET.encode('utf-8'),
        (timestamp_str + data_str).encode('utf-8'),
        hashlib.sha256
    ).hexdigest()
    
    return hmac.compare_digest(signature, calculated_signature)

@app.route('/webhook', methods=['POST'])
def webhook():
    try:
        payload = request.json
        
        signature = payload.get('signature')
        timestamp = payload.get('timestamp')
        data = payload.get('data')
        
        if not signature or not timestamp or not data:
            print('Missing required webhook parameters')
            return 'Bad Request', 400
        
        # Verify signature
        if not verify_signature(payload, signature):
            print('Invalid webhook signature')
            return 'Unauthorized', 401
        
        # Optional: Verify timestamp to prevent replay attacks
        current_time = time.time() * 1000000  # Convert to microseconds
        time_difference = current_time - float(timestamp)
        # Retries keep the original timestamp, so allow 10 minutes
        if time_difference > 600000000:  # 10 minutes in microseconds
            print('Webhook timestamp too old')
            return 'Bad Request', 400
        
        # Parse the data string to JSON
        parsed_data = json.loads(data)
        
        # Process the webhook based on event type
        event_type = parsed_data.get('event')
        if event_type == 'email_delivered':
            print(f"Email delivered to {parsed_data['profile']['email_address']}")
            # Add your custom logic here
        elif event_type == 'sms_delivered':
            print(f"SMS delivered to {parsed_data['profile']['phone_number']}")
            # Add your custom logic here
        elif event_type == 'voice_call_answered':
            print(f"Voice call answered by {parsed_data['profile']['phone_number']}")
            # Add your custom logic here
        else:
            print(f"Unhandled event type: {event_type}")
        
        # Return a success response immediately, before performing any time-consuming tasks
        return jsonify({'received': True}), 200
    
    except Exception as e:
        print(f'Webhook processing error: {e}')
        return jsonify({'error': 'Internal server error'}), 500

if __name__ == '__main__':
    PORT = 3000
    app.run(port=PORT)
    print(f"Webhook server running on port {PORT}")
```

### Request format

Wiraya sends a `POST` with `Content-Type: application/json` and this body:

```json
{
  "signature": "802eb2c0d5f1749c22fc8ca6cfff8d4a19c73653c4a1d27622637eb1473b198d",
  "timestamp": 1794467722000000,
  "data": "{\"id\":\"01JVC8K6XDBHG3Q1KYQTTYYBDV\",\"event\":\"email_delivered\",\"date\":\"2026-11-12T09:15:22.000000Z\",\"group\":{\"uuid\":\"ac7b9988-86ff-4451-91fd-e6c8e2f9ea27\",\"name\":\"Company A\"},\"campaign\":{\"uuid\":\"995e0e81-c79f-41a7-aadc-a113d6087230\",\"name\":\"Basic Campaign\"},\"action\":{\"uuid\":\"995e0e82-06ff-4f7d-85b0-1a39375bb0d9\",\"name\":\"Email Action 1\"},\"profile\":{\"uuid\":\"995e0e82-454c-416c-95a1-f6a726192062\",\"external_id\":\"67482930\",\"first_name\":\"Jane\",\"last_name\":\"Doe\",\"email_address\":\"jane.doe@example.com\",\"phone_number\":\"+46701234567\"},\"profile_tag\":{\"uuid\":\"754f6305-786f-4ac3-8d7d-7cfa35f594eb\",\"name\":\"Contact list name\"},\"attributes\":[{\"name\":\"HasPaid\",\"value\":\"Yes\"}],\"email\":[]}"
}
```

- `signature`: HMAC-SHA256 of `timestamp` + `data`, hex. The example above is signed with the secret `My Super Secret`.
- `timestamp`: when the delivery was prepared, in **microseconds** since the Unix epoch.
- `data`: the event as a JSON **string**. Verify the signature on this exact string before you parse it.


Parsed, `data` looks like this:

```json
{
    "id": "01JVC8K6XDBHG3Q1KYQTTYYBDV",
    "event": "email_delivered",
    "date": "2026-11-12T09:15:22.000000Z",
    "group": {
        "uuid": "ac7b9988-86ff-4451-91fd-e6c8e2f9ea27",
        "name": "Company A"
    },
    "campaign": {
        "uuid": "995e0e81-c79f-41a7-aadc-a113d6087230",
        "name": "Basic Campaign"
    },
    "action": {
        "uuid": "995e0e82-06ff-4f7d-85b0-1a39375bb0d9",
        "name": "Email Action 1"
    },
    "profile": {
        "uuid": "995e0e82-454c-416c-95a1-f6a726192062",
        "external_id": "67482930",
        "first_name": "Jane",
        "last_name": "Doe",
        "email_address": "jane.doe@example.com",
        "phone_number": "+46701234567"
    },
    "profile_tag": {
        "uuid": "754f6305-786f-4ac3-8d7d-7cfa35f594eb",
        "name": "Contact list name"
    },
    "attributes": [
        {
            "name": "HasPaid",
            "value": "Yes"
        }
    ],
    "email": []
}
```

- `id`: unique per delivery. Retries of the same delivery keep the same `id`, so use it to skip duplicates.
- `date`: when the webhook was sent, not when the event happened.
- `profile`: the contact the event is about.
- `profile_tag`: the contact list the contact was scheduled from. Can be `null`.
- `attributes`: the contact's attributes. For object-type attributes, `value` is a list of `{"name", "value"}` pairs.
- One channel field named after the step type, with extra data for that channel: `email`, `sms`, `two_way_sms`, `voice` or `frequency` (see below). When there is nothing to add it is an empty array, `[]`.


#### Voice call events

Voice events have a `voice` field:

- `initiated_at`: when the call was started
- `duration`: call length in seconds
- `direction`: `outbound`, `inbound` or `forwarded`
- `status`: `answered`, `busy`, `no-answer`, `failed` or `queued`
- `operator_number`: the number the call was made from
- `attempt`: which attempt this was
- `answers`: answers given during the call, keyed by step name. Includes option answers, numeric answers and transcripts of open questions.


```json
{
    "voice": {
        "initiated_at": "2002-06-22T09:00:00.000000Z",
        "duration": 30,
        "direction": "outbound",
        "status": "answered",
        "operator_number": "+35812345678",
        "attempt": 1,
        "answers": {
            "Consent": "Yes",
            "Bank": "2"
        }
    }
}
```

#### SMS events

SMS events have an `sms` or `two_way_sms` field, depending on the step type. For SMS sent by Wiraya it is `[]`. For a reply in a Two-Way SMS step it holds the answer, keyed by step name:

```json
{
    "two_way_sms": {
        "answer": {
            "Consent": "Yes"
        }
    }
}
```

`sms_failed` always has an empty field.

#### Frequency limit events

`frequency_rate_limit_reached` has a `frequency` field with the limit that stopped the step:

```json
{
    "frequency": {
        "limit": 2,
        "duration": 1,
        "unit": "days"
    }
}
```

`unit` is `minutes`, `hours` or `days`.

## Delivery and retries

- Any response other than `2xx`, including `4xx`, is retried: up to 10 attempts, 1 second apart. Every attempt has the same `id`, `timestamp` and `signature`.
- Each attempt waits up to 30 seconds for your response. Return `2xx` fast and do the work afterwards.
- Redirects are followed.
- If deliveries to a webhook fail 1000 times within 30 minutes, with no successful delivery in between, the webhook is disabled and the user who created it gets an email. Turn it back on under **Organizational Settings → Integration → Webhooks**.


Headers on every request:

| Header | Value |
|  --- | --- |
| `Content-Type` | `application/json` |
| `X-Optimized-Webhook-256` | `1` |


## Ensuring Security

### Verify webhook signatures

To verify that incoming webhook requests are genuinely from Wiraya and not from a third party, we recommend implementing signature verification. Wiraya signs webhook events by including a signature in each webhook's payload.

The signature is generated using HMAC-SHA256, with your webhook secret as the key and the concatenation of the timestamp and data as the message. This allows you to verify the authenticity and integrity of each webhook request.

#### Example of verifying the HMAC signature:

JavaScript
```javascript
const crypto = require('crypto');

// Secret key shared between the sender and receiver
const secretKey = 'My Super Secret'; // Replace with your actual secret key
const receivedTimestamp = '1794467722000000' // Replace with the received timestamp
const receivedSignature = '802eb2c0d5f1749c22fc8ca6cfff8d4a19c73653c4a1d27622637eb1473b198d'; // Replace with the received signature
const receivedData = '{"id":"01JVC8K6XDBHG3Q1KYQTTYYBDV","event":"email_delivered","date":"2026-11-12T09:15:22.000000Z","group":{"uuid":"ac7b9988-86ff-4451-91fd-e6c8e2f9ea27","name":"Company A"},"campaign":{"uuid":"995e0e81-c79f-41a7-aadc-a113d6087230","name":"Basic Campaign"},"action":{"uuid":"995e0e82-06ff-4f7d-85b0-1a39375bb0d9","name":"Email Action 1"},"profile":{"uuid":"995e0e82-454c-416c-95a1-f6a726192062","external_id":"67482930","first_name":"Jane","last_name":"Doe","email_address":"jane.doe@example.com","phone_number":"+46701234567"},"profile_tag":{"uuid":"754f6305-786f-4ac3-8d7d-7cfa35f594eb","name":"Contact list name"},"attributes":[{"name":"HasPaid","value":"Yes"}],"email":[]}'; // Replace with the received data

// Create an HMAC-SHA256 hash using the secret key
const hmac = crypto.createHmac('sha256', secretKey);

// Update the hash with the received timestamp and received data
hmac.update(receivedTimestamp + receivedData);

// Calculate the HMAC signature
const calculatedSignature = hmac.digest('hex');

// Compare the received signature with the calculated one
const received = Buffer.from(receivedSignature);
const expected = Buffer.from(calculatedSignature);
if (received.length === expected.length && crypto.timingSafeEqual(received, expected)) {
  console.log('HMAC signature is valid. Data is authentic.');
} else {
  console.log('HMAC signature is invalid. Data may be tampered with.');
}
```

Python
```python
import hmac
import hashlib

# Secret key shared between the sender and receiver
secret_key = 'My Super Secret'  # Replace with your actual secret key
received_timestamp = '1794467722000000'  # Replace with the received timestamp
received_signature = '802eb2c0d5f1749c22fc8ca6cfff8d4a19c73653c4a1d27622637eb1473b198d'  # Replace with the received signature
received_data = '{"id":"01JVC8K6XDBHG3Q1KYQTTYYBDV","event":"email_delivered","date":"2026-11-12T09:15:22.000000Z","group":{"uuid":"ac7b9988-86ff-4451-91fd-e6c8e2f9ea27","name":"Company A"},"campaign":{"uuid":"995e0e81-c79f-41a7-aadc-a113d6087230","name":"Basic Campaign"},"action":{"uuid":"995e0e82-06ff-4f7d-85b0-1a39375bb0d9","name":"Email Action 1"},"profile":{"uuid":"995e0e82-454c-416c-95a1-f6a726192062","external_id":"67482930","first_name":"Jane","last_name":"Doe","email_address":"jane.doe@example.com","phone_number":"+46701234567"},"profile_tag":{"uuid":"754f6305-786f-4ac3-8d7d-7cfa35f594eb","name":"Contact list name"},"attributes":[{"name":"HasPaid","value":"Yes"}],"email":[]}'  # Replace with the received data

# Create an HMAC-SHA256 hash using the secret key
calculated_signature = hmac.new(
    secret_key.encode('utf-8'),
    (received_timestamp + received_data).encode('utf-8'),
    hashlib.sha256
).hexdigest()

# Compare the received signature with the calculated one
if hmac.compare_digest(received_signature, calculated_signature):
    print('HMAC signature is valid. Data is authentic.')
else:
    print('HMAC signature is invalid. Data may be tampered with.')
```

PHP
```php
  <?php
  // Secret key shared between the sender and receiver
  $secretKey = 'My Super Secret'; // Replace with your actual secret key
  $receivedTimestamp = '1794467722000000'; // Replace with the received timestamp
  $receivedSignature = '802eb2c0d5f1749c22fc8ca6cfff8d4a19c73653c4a1d27622637eb1473b198d'; // Replace with the received signature
  $receivedData = '{"id":"01JVC8K6XDBHG3Q1KYQTTYYBDV","event":"email_delivered","date":"2026-11-12T09:15:22.000000Z","group":{"uuid":"ac7b9988-86ff-4451-91fd-e6c8e2f9ea27","name":"Company A"},"campaign":{"uuid":"995e0e81-c79f-41a7-aadc-a113d6087230","name":"Basic Campaign"},"action":{"uuid":"995e0e82-06ff-4f7d-85b0-1a39375bb0d9","name":"Email Action 1"},"profile":{"uuid":"995e0e82-454c-416c-95a1-f6a726192062","external_id":"67482930","first_name":"Jane","last_name":"Doe","email_address":"jane.doe@example.com","phone_number":"+46701234567"},"profile_tag":{"uuid":"754f6305-786f-4ac3-8d7d-7cfa35f594eb","name":"Contact list name"},"attributes":[{"name":"HasPaid","value":"Yes"}],"email":[]}'; // Replace with the received data

  // Create an HMAC-SHA256 hash using the secret key
  $calculatedSignature = hash_hmac('sha256', $receivedTimestamp . $receivedData, $secretKey);

  // Compare the received signature with the calculated one using a timing-safe comparison
  if (hash_equals($receivedSignature, $calculatedSignature)) {
      echo 'HMAC signature is valid. Data is authentic.';
  } else {
      echo 'HMAC signature is invalid. Data may be tampered with.';
  }
```

Go
```go
package main

import (
  "crypto/hmac"
  "crypto/sha256"
  "encoding/hex"
  "fmt"
)

func main() {
  // Secret key shared between the sender and receiver
  secretKey := "My Super Secret" // Replace with your actual secret key
  receivedTimestamp := "1794467722000000" // Replace with the received timestamp
  receivedSignature := "802eb2c0d5f1749c22fc8ca6cfff8d4a19c73653c4a1d27622637eb1473b198d" // Replace with the received signature
  receivedData := `{"id":"01JVC8K6XDBHG3Q1KYQTTYYBDV","event":"email_delivered","date":"2026-11-12T09:15:22.000000Z","group":{"uuid":"ac7b9988-86ff-4451-91fd-e6c8e2f9ea27","name":"Company A"},"campaign":{"uuid":"995e0e81-c79f-41a7-aadc-a113d6087230","name":"Basic Campaign"},"action":{"uuid":"995e0e82-06ff-4f7d-85b0-1a39375bb0d9","name":"Email Action 1"},"profile":{"uuid":"995e0e82-454c-416c-95a1-f6a726192062","external_id":"67482930","first_name":"Jane","last_name":"Doe","email_address":"jane.doe@example.com","phone_number":"+46701234567"},"profile_tag":{"uuid":"754f6305-786f-4ac3-8d7d-7cfa35f594eb","name":"Contact list name"},"attributes":[{"name":"HasPaid","value":"Yes"}],"email":[]}` // Replace with the received data

  // Create an HMAC-SHA256 hash using the secret key
  h := hmac.New(sha256.New, []byte(secretKey))
  
  // Update the hash with the received timestamp and received data
  dataToSign := receivedTimestamp + receivedData
  h.Write([]byte(dataToSign))
  
  // Calculate the HMAC signature as bytes
  calculatedSignatureBytes := h.Sum(nil)
  
  // Convert the received signature from hex to bytes for comparison
  receivedSignatureBytes, err := hex.DecodeString(receivedSignature)
  if err != nil {
    fmt.Println("Error decoding received signature:", err)
    return
  }
  
  // Compare the received signature with the calculated one using a timing-safe comparison
  if hmac.Equal(receivedSignatureBytes, calculatedSignatureBytes) {
    fmt.Println("HMAC signature is valid. Data is authentic.")
  } else {
    fmt.Println("HMAC signature is invalid. Data may be tampered with.")
  }
}
```

### Preventing replay attacks

A replay attack occurs when an attacker intercepts a valid webhook request and its signature, then re-transmits them. To mitigate such attacks:

1. Verify the webhook signature as shown above
2. Reject old timestamps. Retries keep the original timestamp, so allow at least 10 minutes.
3. Store the `id` of processed webhooks and skip ids you have already seen


### Ensure your endpoint is publicly accessible

Your webhook endpoint needs to be publicly accessible for Wiraya to deliver events. For production usage, ensure:

1. Your endpoint uses HTTPS with a valid SSL certificate
2. Your server is configured to accept POST requests
3. Any firewalls or security rules allow incoming connections from Wiraya


## Testing your webhooks

1. Run your handler locally
2. Use a tool like [ngrok](https://ngrok.com/) to create a temporary public URL for your local endpoint
3. [Create a webhook in Wiraya](#create-the-webhook-in-wiraya) with this temporary URL
4. Trigger events from your Wiraya account
5. Check that your handler receives and processes the requests


## Best Practices

### Handle events asynchronously

Return `200` right away, put the event on a queue and process it in the background. Slow handlers cause timeouts and retries.

```javascript
// Example of asynchronous processing
app.post('/webhook', (req, res) => {
  try {
    const { signature, timestamp, data } = req.body;
    
    // Verify signature
    if (!verifySignature(req.body, signature)) {
      return res.status(401).send('Unauthorized');
    }
    
    // Return 200 immediately
    res.status(200).json({ received: true });
    
    // Process the event asynchronously
    processEventAsync(JSON.parse(data)).catch(err => {
      console.error('Error processing event:', err);
    });
  } catch (error) {
    console.error('Webhook error:', error);
    res.status(500).json({ error: 'Internal server error' });
  }
});

async function processEventAsync(eventData) {
  // Time-consuming operations here
  // Store in database, update CRM, etc.
}
```

### Handle duplicate events

Webhook endpoints might occasionally receive the same event more than once due to retries or other delivery mechanisms. To prevent processing duplicates:

1. Store processed event IDs in a database or cache
2. Check if an incoming event ID has already been processed before handling it


```javascript
async function isEventProcessed(eventId) {
  // Check if the event has already been processed
  const result = await db.query('SELECT 1 FROM processed_events WHERE event_id = ?', [eventId]);
  return result.length > 0;
}

async function markEventAsProcessed(eventId) {
  // Mark the event as processed
  await db.query('INSERT INTO processed_events (event_id, processed_at) VALUES (?, NOW())', [eventId]);
}

app.post('/webhook', async (req, res) => {
  try {
    // Verify signature, etc.
    
    const eventData = JSON.parse(req.body.data);
    const eventId = eventData.id;
    
    // Check for duplicates
    if (await isEventProcessed(eventId)) {
      return res.status(200).json({ received: true, duplicate: true });
    }
    
    // Return 200 immediately
    res.status(200).json({ received: true });
    
    // Process event and mark as processed
    await processEventAsync(eventData);
    await markEventAsProcessed(eventId);
  } catch (error) {
    console.error('Webhook error:', error);
    res.status(500).json({ error: 'Internal server error' });
  }
});
```

### Exempt webhook routes from CSRF protection

Frameworks with CSRF protection reject webhook POSTs unless you exempt the route:

Django
```python
# Django example
@csrf_exempt
def webhook_handler(request):
    # Process webhook
```

Rails
```ruby
# Rails example
class WebhooksController < ApplicationController
  skip_before_action :verify_authenticity_token, only: [:handle]
  
  def handle
    # Process webhook
  end
end
```

Laravel
```php
// For Laravel 11+
// In app/Providers/RouteServiceProvider.php
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;

// In boot() method
$this->app->singleton(VerifyCsrfToken::class, function () {
    return new VerifyCsrfToken([
        'webhook/*',
        'api/stripe/webhook',
        // other routes to exclude
    ]);
});

// For Laravel 10 and earlier
// In app/Http/Middleware/VerifyCsrfToken.php
protected $except = [
    'webhook/*',
    'api/stripe/webhook',
    // other routes to exclude
];
```

## Troubleshooting

### Common issues and solutions

| Issue | Possible Causes | Solutions |
|  --- | --- | --- |
| Not receiving webhooks | Endpoint not publicly accessibleIncorrect URL configured | Verify your endpoint is accessible from the internetCheck the URL under **Organizational Settings → Integration → Webhooks** |
| Invalid signature errors | Incorrect secret keyModified payload | Confirm you're using the correct webhook secretEnsure the payload isn't modified before verification |
| Duplicate event processing | Retries from WirayaMissing duplicate detection | Implement idempotent event processingStore and check event IDs before processing |
| Timeouts | Long-running operations in webhook handler | Return 200 immediately, then process asynchronously |


## Need help?

Contact [support@wiraya.com](mailto:support@wiraya.com).