Skip to main content

Webhooks

Webhooks are automated HTTP JSON requests sent by Sticitt to your server whenever a significant event occurs. They are the most reliable way to keep your system in sync with the Sticitt platform.

Webhook Configuration

Send through the endpoints you want to receive the various webhooks to technology@sticitt.co.za. You can specify an endpoint for each event type, and for each environment. We will provide you with the webhook key for each environment.

1. Handling Requests

Sticitt sends webhooks as POST requests with a JSON body.

Response Requirement

To acknowledge receipt, your endpoint must return an HTTP 200 OK status code.

Retry Logic

If your server returns any other status code (e.g., 400, 500, or 503), or if the request times out, Sticitt will treat delivery as failed.

  • Retry Interval: The webhook will retry every 15 seconds.
  • Best Practice: Your application should catch internal errors and still respond with 200 OK if the payload is malformed or irrelevant, unless you specifically want the system to retry (e.g., if your database is temporarily down).

2. Security & Verification

To ensure requests actually come from Sticitt and have not been tampered with, every webhook includes a cryptographic signature.

The Pay-Signature Header

Each request includes a custom header: Pay-Signature: <Base64 Encoded String>

Verifying the Signature

You must calculate the HMAC-SHA256 signature of the raw request body using your webhook_key as the key, and compare it to the header value.

Verify Every Request

If the calculated signature does not match the Pay-Signature header, ignore the request. It may be a malicious attempt to spoof a payment.

Example: Calculating Signature

using System.Security.Cryptography;
using System.Text;

public class Program
{
private static string CalculateSignature(string message, string webhookKey)
{
//Retrieve key from client secret.
var encoding = new UTF8Encoding();
var key = encoding.GetBytes(webhookKey);
var payload = encoding.GetBytes(message);
//Sign request
var pen = new HMACSHA256(key);
var signature = pen.ComputeHash(payload);
//Encode signature as base64
var base64Signature = Convert.ToBase64String(signature);
return base64Signature;
}

public static void Main(string[] args)
{
var message = "YOUR_MESSAGE_TO_BE_SIGNED";
var key= "YOUR_WEBHOOK_KEY";
Console.WriteLine("Calculated Signature: " + CalculateSignature(message, key));
}
}