Webhooks
Last updated 21 November 2026.
Klass can notify other systems when something happens, by sending a webhook to an address you choose.
- Eleven events are available.
- Every delivery is signed with HMAC-SHA256.
- Failed deliveries are retried.
- You can send a test delivery.
- A delivery log shows every attempt and its result.
Add a webhook
- In the Klass administrator, open Integrations.
- Enter the address that should receive the webhooks, tick the events it wants, and click Add webhook.
- Klass shows the webhook's secret once, with a copy button. Copy it into the receiving system. If it is lost, open the webhook and click New signing secret; the old secret stops working.
Use Send a test to check the address. A test sends the event webhook.test and shows the status the address answered.
Events
| Event | Sent when | data holds |
|---|---|---|
enrolment.created |
A learner is enrolled | enrolment (id, status, source), learner, course |
lesson.completed |
A learner completes a lesson | lesson (id, title), learner, course |
course.completed |
A learner completes a course | enrolment (id, completed), learner, course |
certificate.issued |
A certificate is issued | certificate (code, issued, expires), learner, course |
quiz.submitted |
A quiz attempt is submitted | attempt (id, status, percent, passed), learner, lesson |
assignment.submitted |
Assignment work is submitted | submission (id, status), learner, lesson, course |
grade.posted |
Assignment work is graded | submission (id, status, score, max_score, percent), learner, lesson, course |
order.paid |
An order is paid | order (id, number, status, currency, total, refunded, org_id), learner |
order.refunded |
An order is refunded, in full or in part | the same as order.paid, with the amount refunded in refunded |
subscription.started |
A membership starts | subscription (id, status, plan), learner |
subscription.cancelled |
A membership ends | subscription (id, status, plan), learner |
learner is {id, name, email}, course is {id, code, title} and lesson is {id, title}.
What a delivery looks like
Each delivery is a POST with a JSON body:
{
"id": "6f1c2a9e-4b7d-4c1a-9e2f-0d3b5a7c8e11",
"event": "course.completed",
"created": "2026-11-21T09:30:00+00:00",
"data": {
"enrolment": {"id": 412, "completed": "2026-11-21 09:30:00"},
"learner": {"id": 318, "name": "Ada Obi", "email": "ada@example.com"},
"course": {"id": 7, "code": "PY-101", "title": "Data analysis with Python"}
}
}
and these headers:
| Header | Value |
|---|---|
X-Klass-Event |
The event name |
X-Klass-Delivery |
The delivery's id, the same as id in the body. A retry keeps the same id, so use it to ignore a delivery you have already handled |
X-Klass-Timestamp |
When the delivery was sent, in Unix seconds |
X-Klass-Signature |
sha256= followed by the signature |
Checking the signature
The signature is the HMAC-SHA256, in hexadecimal, of the timestamp, a full stop and the raw request body, keyed with the webhook's secret. Compute it yourself, compare it with the header using a constant-time comparison, and reject the request if they differ. Reject old timestamps too, for example more than five minutes old, so a captured request cannot be replayed.
$secret = 'whsec_...'; // the webhook's secret
$body = file_get_contents('php://input');
$timestamp = $_SERVER['HTTP_X_KLASS_TIMESTAMP'] ?? '';
$signature = $_SERVER['HTTP_X_KLASS_SIGNATURE'] ?? '';
$expected = 'sha256=' . hash_hmac('sha256', $timestamp . '.' . $body, $secret);
if (!hash_equals($expected, $signature) || abs(time() - (int) $timestamp) > 300) {
http_response_code(401);
exit;
}
$event = json_decode($body, true);
// Handle $event['event'] and $event['data'] here.
http_response_code(200);
Retries
Answer with any 2xx status to accept a delivery. Any other answer, or no answer, counts as a failure, and Klass tries again 5, 30, 120 and 480 minutes later. After that, the delivery is marked failed in the log.
A webhook that fails 20 times in a row is paused, so a broken address does not fill the log. Click Resume on Integrations once the address works again.
Retries are sent by the Klass: webhook retries scheduled task, which Klass adds when it is installed and runs every 5 minutes. See Scheduled tasks.