Skip to content

Webhooks

Overview

The webhook api allows managing receiving events from knolyx.

Existing event types

EventDescription
PINGSent when creating a new webhook or manually to test the webhook integration
COURSE_COMPLETEDThe event is sent when a student completes a course
COURSE_STARTEDThe event is sent when a student starts a course
COURSE_PAYMENT_RECEIVEDThe event is send when a student buys a course

Event message

All events are sent as json in the following format:

 {
 "id": "{{uuid}}",
 "type": "{{eventType}}",
 "data": "{{eventBody}}"
}

PING
The ping event will have a body like:

{
    "id": "af46ec07-de79-40b5-916c-0058b54b2d2b",
    "type": "PING",
    "data": {
        "message": "PING"
    }
}

COURSE_COMPLETED
The course completed event will have a body like:

{
    "id": "af46ec07-de79-40b5-916c-0058b54b2d2b",
    "type": "COURSE_COMPLETED",
    "data": {
        "user": {
          "id": {{user-id-as-long-value}},
          "name": "{{student-name}}",
          "email": "{{student-email}}"
        },
       "course": {
          "id": {{course-id-as-long-value}},
          "name": "{{completed-course-name}}",
       }
    }
}

COURSE_STARTED
The course started event will have a body like:

{
    "id": "af46ec07-de79-40b5-916c-0058b54b2d2b",
    "type": "COURSE_STARTED",
    "data": {
        "user": {
          "id": {{user-id-as-long-value}},
          "name": "{{student-name}}",
          "email": "{{student-email}}"
        },
       "course": {
          "id": {{course-id-as-long-value}},
          "name": "{{completed-course-name}}",
       }
    }
}

COURSE_PAYMENT_RECEIVED
The course payment received event will have a body like:

{
    "id": "af46ec07-de79-40b5-916c-0058b54b2d2b",
    "type": "COURSE_PAYMENT_RECEIVED",
    "data": {
        "user": {
          "id": {{user-id-as-long-value}},
          "name": "{{student-name}}",
          "email": "{{student-email}}"
        },
       "course": {
          "id": {{course-id-as-long-value}},
          "name": "{{course-name}}",
       }
    }
}

BUNDLE_PAYMENT_RECEIVED
The bundle payment received event will have a body like:

{
    "id": "af46ec03-de79-40b5-916c-0058b54b2d2b",
    "type": "BUNDLE_PAYMENT_RECEIVED",
    "data": {
        "user": {
          "id": {{user-id-as-long-value}},
          "name": "{{student-name}}",
          "email": "{{student-email}}"
        },
       "bundle": {
          "id": {{bundle-id-as-long-value}},
          "slug": {{bundle-slug-as-string-value}},
          "name": "{{bundle-name}}",
       }
    }
}

Webhook API

Create webhook

POST /public/api/v1/webhook
Content-Type: application/json
X-Api-Key: {{apiKey}}
X-Project-Id: {{projectId}}
 
{
  "name": "Webhook name",
  // url that accepts a PUT request
  "url": "https://valid-domain/hook",
  "securityToken": "token-generated-client-side"
}

The security token will be created client side and passed to the create webhook api. It will be sent on any webhook calls made by knolyx, and it will be found in the header “X-Webhook-Security-Token”. The platform should check every time that the token is the correct one.

On create, an event of type PING will be sent to platform to validate that the connection is good.

Get all GET /public/api/v1/webhook

Get one GET /public/api/v1/webhook/{{wehbookId}}

Delete DELETE /public/api/v1/webhook/{{wehbookId}}

Ping all POST /public/api/v1/webhook/ping

Ping one POST /public/api/v1/webhook/{{wehbookId}}/ping