API: Subscribe To Event

To subscribe to an event the event name must be given along with a callback URL (which must be a fully-qualified domain name with a uri segment) that Elucidat will contact when the event is triggered.

Please note that only one subscription can be made per event per set of application keys. The following events are currently available:

release_course

Release course is triggered when a new release of a course is made by one of the account's authors.

project_created

Project created is triggered when a new course is created.

project_deleted

Project deleted is triggered when a a project is deleted.

The payload delivered when this is triggered will resemble the following:

{
    "name": "Webhooks",
    "project_code": "620cc5c653c5c",
    "created": "2022-02-16 09:37:10",
    "event": "project_deleted"
}

 

release_deleted

Release deleted is triggered when a a project is deleted.

The payload delivered will resemble the following:

{
    "release_code": "620cd45a833d9",
    "created": "2022-02-16 10:39:06",
    "modified": "2022-02-16 10:39:23",
    "status": "complete",
    "description": "February release",
    "release_views": "0",
    "release_views_this_month": "0",
    "release_passes": "0",
    "release_fails": "0",
    "release_last_view": null,
    "version_number": "1",
    "release_mode": "online-public",
    "lrs_endpoint": "",
    "lrs_endpoint_username": "",
    "learner_access": "any",
    "release_type": "standard",
    "project": {
        "name": "Webhooks",
        "project_code": "620cc5c654c5e"
    },
    "timezone": "UTC",
    "user": {
        "name": "Joe Bloggs",
        "email": "joe.bloggs@elucidat.com"
    },
    "download_url": null,
    "launch_url": "https://elucidat.com/course/620cc5c653c5f-620gd44a833f4",
    "edit_url": "https://elucidat.com/projects/edit/620cc5c653c5f",
    "event": "release_deleted"
}

Before using this call, you'll need to authenticate against the API as detailed in Making your first call to the Project API.

All of these examples have simulation mode turned on. Once you are ready to use in a production environment, you can remove the simulation parameter. Any changes will then affect your account.

 

PHP

Ruby

Python

Response

 

PHP

$nonce = get_nonce('https://api.elucidat.com/v2/event/subscribe', 'PUBLIC_KEY', 'PRIVATE_KEY');
$headers = auth_headers('PUBLIC_KEY', $nonce);
$fields = array(
    'simulation_mode' => 'simulation',
    'event' => $arg1,
    'callback_url' => $arg2
);
$result = call_elucidat($headers, $fields, 'POST', 'https://api.elucidat.com/v2/event/subscribe', 'PRIVATE_KEY');
echo ("HTTP status code: " . $result['status'] . "\n");
print_r($result['response']);

Ruby

nonce = client.get_nonce;
headers = client.auth_headers(nonce)
fields = {'event' => arg1,
	'callback_url' => arg2,
	'simulation_mode' => 'simulation'
}
pp client.call_elucidat(headers, fields, 'POST', '/v2/event/subscribe')

Python 2

nonce = get_nonce(
    "https://api.elucidat.com/v2/event/subscribe",
    "PUBLIC_KEY",
    "PRIVATE_KEY",
)
headers = auth_headers("PUBLIC_KEY", nonce)
fields = [("event", arg1), ("callback_url", arg2), ("simulation_mode", "simulation")]
print call_elucidat(
    headers,
    fields,
    "POST",
    "https://api.elucidat.com/v2/event/subscribe",
    "PRIVATE_KEY",
)

Response

{
  "message": "Subscribed to event"
}

Was this article helpful?
0 out of 0 found this helpful

Articles in this section

Request support
Access support that’s tailored to you by getting in touch with our Support Team.
Send us feedback
Do you have a new feature request, or want to tell us about something that works well (or not so well) for you? Get in touch!