Webhooks

A webhook allows our system to send event notifications to your application automatically. You provide a URL where you want to receive updates, and our system will send event data as a JSON payload with POST method whenever something happens.

Adding a Webhook

To add a webhook, go to the API Addon and provide the URL of your server. After saving, a secret key will be generated for security purposes.

You can have up to 10 webhooks active at a time.

Deleting or Deactivating a Webhook

You can delete or deactivate a webhook if you no longer wish to receive events. Deactivating allows you to pause notifications without deleting the webhook.

Event Management

Choose specific events (e.g., client created, match updated) that trigger your webhook. You can manage these in the Webhook Events in Webhook actions by selecting or deselecting event types. No events chosen by default.

Supported Events:

Client Events:

client_created - Client Created

client_updated - Client Updated

client_deleted - Client Deleted

client_profile_updated - Client Profile Updated

client_preferences_updated - Client Preferences Updated

Match Events:

match_added - Match Added

match_updated - Match Updated

match_deleted - Match Deleted

match_group_changed - Match Group Changed

Verification Event:

verification - This event is triggered when you initially validate the webhook.

These events can be configured to trigger the webhook based on your business requirements.

Webhook Examples:

{
    "event": "client_created",
    "payload": {
        "id": 1
    }
}

{
    "event": "client_updated",
    "payload": {
        "id": 1,
        "is_archived": True
    }
}

{
    "event": "client_profile_updated",
    "payload": {
        "id": 1,
        "prof_1": "1992-08-12"
    }
}

{
    "event": "client_preferences_updated",
    "payload": {
        "id": 1,
        "pref_1": "1992-08-12"
    }
}

{
    "event": "client_preferences_updated",
    "payload": {
        "id": 1,
        "pref_235": {
            "start": "2023-04-13",
            "end": "2024-10-26"
        }
    }
}

{
    "event": "match_added",
    "payload": {
        "id": 482,
        "client": {"id": 2},
        "match": {"id": 1},
        "group": {
            "id": 1,
            "name": "Group 1"
        }
    }
}

{
    "event": "match_updated",
    "payload": {
        "id": 482,
        "status": {
            "id": 3,
            "name": "Prepared for date "
        }
    }
}
Verifying Your Webhook

When you add a webhook, it is not active by default. To activate it, click on the Verify button in webhook actions. Our system sends a special event called "verification" to your webhook URL. This event contains a "challenge" string that your server must respond to via JSON {"challenge": <code>}, confirming that the webhook is correctly set up.

If you make any changes to the webhook URL, the webhook will be automatically deactivated, and you will need to verify it again.

Example verification payload:

{
    "event": "verification",
    "challenge": "FtvnJ1ULgKRNsqEg"
}
Webhook Response:

Your endpoint must quickly return a successful status code 200 before any complex logic that could cause a timeout.

Securing Webhook Data with X-Signature and Timestamp

Each webhook request includes an X-Signature and X-Timestamp header to help you verify the authenticity of the request and ensure that it has not been tampered with. The signature is generated using a combination of the webhook secret key, the timestamp, and the payload.

Signature Generation Process:

The signature is computed using the following steps:

  • Timestamp: We generate a Unix timestamp (seconds since epoch) at the time the request is made.
  • Payload: The payload is the actual data being sent to your server, formatted as JSON.
  • Message: We create a message by concatenating the timestamp and the payload, separated by a dot (.).
  • HMAC Signature: We compute the HMAC SHA-256 signature using the message and your webhook's secret key.

Verifying the Signature on Your Side:

To verify the signature and timestamp on your server:

  • Retrieve the X-Signature and X-Timestamp headers from the webhook request.
  • Recreate the message by concatenating the X-Timestamp and the request body (payload), separated by a dot (.).
  • Compute the signature using HMAC SHA-256 with your webhook’s secret key.
  • Compare the computed signature with the received X-Signature. They must match.

Python Example for Verifying Signature:

import hmac
import hashlib

def verify_webhook_signature(payload, received_signature, received_timestamp, webhook_secret):
    message = f'{received_timestamp}.{payload}'  # Recreate the message with the timestamp and payload

    # Recompute the signature using HMAC SHA-256
    computed_signature = hmac.new(
        webhook_secret.encode(),
        message.encode(),
        hashlib.sha256
    ).hexdigest()

    # Compare the received signature with the computed one
    return hmac.compare_digest(computed_signature, received_signature)
Retry Mechanism

If a webhook request fails, we will retry delivery up to 5 times with the following intervals:

  • 1st retry: 4 minutes after the initial attempt.
  • 2nd retry: 16 minutes after the first retry.
  • 3rd retry: 64 minutes after the second retry.
  • 4th retry: 256 minutes after the third retry.
  • 5th retry: Final attempt, 1024 minutes after the fourth retry.
  • The retries will stop once the request is successfully delivered (status code 200) or after all 5 attempts fail.
Cancellation Mechanism

For each failed webhook, the system checks how many requests have been made in the past 24 hours. Specifically, it counts:

  • Webhooks that failed and had 3 or more retry attempts.
  • Webhooks that were successfully delivered.

If more than 40% of the webhook requests in the last 24 hours have failed after 3 or more retry attempts, the system will:

  • Cancel all pending or retry attempts for that webhook.
  • Deactivate the webhook to prevent further requests.
  • Send system notification to the agency.
Webhooks Usage

Check the Webhooks Usage for a history of webhook events, including their delivery status (accepted, failed, retry, canceled), sent date, retry count, payload.

If a webhook has the status failed, retry, or canceled, you also have the option to manually resend the webhook. This allows you to attempt delivery again without waiting for the automated retry process.