# Events & Webhooks

Lingk moves your periodic, scheduled integration processes to data-driven events that fit into your business process. Lingk's Event Broker connects real-time data and events with monitoring, analysis, communication, and learning systems.

Here are a few scenarios:

* A Lingk real-time recipe is triggered based on a learning event consumed by another HTTP endpoint.
* As files are transformed, an error occurs due to a schema change in the file. In real-time, a specific event that is subscribed to by a email notification engine and the bug tracking system is created.
* As education data is transformed by the Transformer Engine, events are added to queues for grading, retention, and alerting purposes.

To see an example Node.js project go to: <https://github.com/lingkio/event-triggered-recipe-nodejs>

## **Create a subscription**

```
curl -X POST  
-H "date: Wed, 27 Jul 2016 02:38:11 UTC"  
-H 'Authorization: Signature keyId="asfsdfaf",algorithm="hmac-sha1",headers="date (request-target)",signature="WCIW%2F%2B0WG8tIvpQ0W7t34kksj5Q%3D"' 
-d @subscription.json
https://www.lingkapis.com/v1/@self/webhooks/subscriptions

{
 "tenantKeyFilter": "lingkuni",
 "appKeyFilter": "peoplesoftsis",
 "objectTypeFilter": "*",
 "verbFilter": "*",
 "deliveryUrl": "http://some.lingkto.com/test/webhookdelivery"
}
```

## **Delete a subscription**

```
curl -X DELETE  
-H "date: Wed, 27 Jul 2016 02:39:44 UTC"  
-H 'Authorization: Signature keyId="dfsadfasf",algorithm="hmac-sha1",headers="date (request-target)",signature="wBRwzLuW%2BCXblCFEJtjO9YSjXgw%3D"' 
https://www.lingkapis.com/v1/@self/webhooks/subscriptions/e029485bf8ba4c6ba11b2a62ec208af7
```

## **Get subscriptions**

```
curl -X GET  
-H "date: Wed, 27 Jul 2016 02:41:42 UTC"  
-H 'Authorization: Signature keyId="dfsadfasf",algorithm="hmac-sha1",headers="date (request-target)",signature="oDEh0diKNuzzHSBYXW3tAVywd0g%3D"' 
https://www.lingkapis.com/v1/@self/webhooks/subscriptions
```

## **Post an event**

```
curl -X POST  
-H "date: Wed, 27 Jul 2016 02:43:21 UTC"  
-H 'Authorization: Signature keyId="dfsadfasf",algorithm="hmac-sha1",headers="date (request-target)",signature="V3dgtmkNLvxq7QNPx4kXcSuFU0k%3D"' 
-d @event.json https://www.lingkapis.com/v1/@self/events

 {
    "verb":"create",
    "objectType":"fileUpload",
    "eventObject": { "file":
      { "path": "/path.zip" } 
    }
}

 {
    "verb":"add",
    "objectType":"learningEvent",
    "eventObject": { 
    ... Capliper/xAPI statement ...
    }
}
```

## **Consume Events via a Webhook**

After an event is triggered through the Event Broker, all subscribed endpoints are *pushed* a JSON payload for the event.

The eventObject property contains the data associated with the event. Lingk has a specific eventObject format for files imported into a Data Repository.

Example Webhook Payload

```
{
  "appKey": "courserosters",
  "eventGuid": "538c8a6e2e44477a84e85dbeb921bef9",
  "eventObject": {
    "course": {
      "courseCode": "24617.1101"
    }
  },
  "objectType": "integration.courserosters.testevent",
  "tenantKey": "integration",
  "timestamp": "2016-10-21T06:11:40.267817769Z",
  "verb": "finish"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.lingk.io/lingk-apis/eventsandwebhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
