Sky Ledge Docs
Search…
⌃K

Creating Events (aka Alerts or Notifications)

Recap: What are Events?
Previously we looked at Event Types, these are templates describing the different types of insights/notifications a business might want to see. They describe the structure of what needs to be displayed as part of a given Event Type along with any placeholders (e.g. {{location}} or {{customerFirstName}}.
Events are the actual, literal alerts/notifications that flow into your Control Room.
So using the Event Type we created previously (Customer Flying), actual events would look something like this:
Event Alert appearing in our Event Stream
You can see this is based on the same Event Type we created earlier. But they contain actual information inside of the placeholders.
We can create Events in two ways, via UI or API. In some cases, it makes sense to allow users to post Events via a UI, in other (and most cases) it makes sense to stream events via APIs. We’ll walk you through both.

Creating Events - Using the interface

The Hero Regulator expects Pharmacies to register customers who take the Hero Flight potion and take flight successfully. In this case, Pharma’s simply open their Control Room and raise an alert within the system.
The process is quite straightforward:
  1. 1.
    Open the Control Room you created in the previous step (Heroes Flying Potion - Real-time Monitoring)
  2. 2.
    In the side panel, click ‘Post an Event’
  3. 3.
    Select the Event Type we’d like to post to, in this case “Customer Flying”
  4. 4.
    Fill in the placeholders with the actual location and name
  5. 5.
    Post the event!
Now you can go into your Control Room and see the events in your event stream.
Here’s a quick visual walk through:
Click 'Post an Event' button
Click on 'Customer Flying' Event Type
Create Event page with placeholders previously designated in Event Type

Creating Events - Using the API

The process is essentially the same. Instead of selecting Event Types from a list as we did previously, we need to reference our Event Type’s Unique Identifier.
Getting this is easy:
  1. 1.
    Head over to ‘Manage Event Types’ in your Control Room
  2. 2.
    Open the Event Type of interest (e.g. Customer Flying)
  3. 3.
    Navigate to the ‘Event Type Schema’ tab
  4. 4.
    Here you’ll find a bunch of useful information for developers, for example, the endpoint you can POST events to, as well as the schema to use when posting events
Here’s a visual walk through of how to get this:
Click 'Event Type Schema' to get Schema and POST request
Now we’re ready to make some calls and push events via API:

Creating Event - Flying Person Detected in Central Park

POST api.skyledge.com/event-types/{eventTypeIdentifier}/events
{
"dynamicAttributes":{
"location":"Central Park"
},
"location":{
"type":"Point",
"coordinates":[
"-73.9752",
"40.7687"
]
}
}
cURL
NodeJs
Python
curl --location --request POST 'https://api.skyledge.com/event-types/EVENT_TYPE_ID/events' \
--header 'X-Authorization: API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"dynamicAttributes":{
"location":"Central Park"
},
"location":{
"type":"Point",
"coordinates":[
"-73.9752",
"40.7687"
]
}
}'
import { Configuration, EventRequest, EventsApi } from '@skyledge/sdk';
const configuration = new Configuration({
apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
basePath: 'https://api.skyledge.com',
});
const data: Partial<EventRequest> = {
dynamicAttributes: {
location: 'Central Park',
} as any,
location: {
type: 'Point',
coordinates: [[-73.9752, 40.7687]],
},
};
const eventTypeIdentifier = EVENT_TYPE_IDENTIFIER;
const eventsApi = new EventsApi(configuration);
const createEvent = await eventsApi.createEvent(eventTypeIdentifier, data);
console.log(createEvent.status);
import requests
import json
url = "https://api.skyledge.com/event-types/EVENT_TYPE_ID/events"
payload = json.dumps({
"dynamicAttributes": {
"location": "Central Park"
},
"location": {
"type": "Point",
"coordinates": [
"-73.9752",
"40.7687"
]
}
})
headers = {
'X-Authorization': 'API_KEY',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
The output within the Sky Ledge control room should look like this:
Event Alert in Event Stream appearing in Control Room
When creating an event, it’s expected that an empty response is returned. If you consider situations such as streaming real-time data from an ioT device, it’s doesn’t make much sense to wait for the device to respond before setting up the event in our account

Creating Event - Customer Flying in Garment District

POST api.skyledge.com/event-types/{eventTypeIdentifier}/events
{
"dynamicAttributes":{
"customerFirstName":"Harry",
"location":"Garment District"
},
"location":{
"type":"Point",
"coordinates":[
"-73.9951",
"40.7541"
]
}
}
cURL
NodeJs
Python
curl --location --request POST 'https://api.skyledge.com/event-types/EVENT_TYPE_ID/events' \
--header 'X-Authorization: API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"dynamicAttributes":{
"customerFirstName":"Harry",
"location":"Garment District"
},
"location":{
"type":"Point",
"coordinates":[
"-73.9951",
"40.7541"
]
}
}'
import { Configuration, EventRequest, EventsApi } from '@skyledge/sdk';
const configuration = new Configuration({
apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
basePath: 'https://api.skyledge.com',
});
const data: Partial<EventRequest> = {
dynamicAttributes: {
customerFirstName: 'Harry',
location: 'Garment District',
} as any,
location: {
type: 'Point',
coordinates: [[-73.9951, 40.7541]],
},
};
const eventTypeIdentifier = EVENT_TYPE_IDENTIFIER;
const eventsApi = new EventsApi(configuration);
const createEvent = await eventsApi.createEvent(eventTypeIdentifier, data);
console.log(createEvent.status);
import requests
import json
url = "https://api.skyledge.com/event-types/EVENT_TYPE_ID/events"
payload = json.dumps({
"dynamicAttributes":{
"customerFirstName":"Harry",
"location":"Garment District"
},
"location":{
"type":"Point",
"coordinates":[
"-73.9951",
"40.7541"
]
}
})
headers = {
'X-Authorization': 'API_KEY',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Your output on the platform in the control room, should look like the following:

Creating Event - Potion Ineffective on customer in Hell’s Kitchen

POST api.skyledge.com/event-types/{eventTypeIdentifier}/events
{
"dynamicAttributes":{
"location":"Garment District"
},
"location":{
"type":"Point",
"coordinates":[
"-73.9951",
"40.7541"
]
}
}
cURL
NodeJs
Python
curl --location --request POST 'https://api.skyledge.com/event-types/EVENT_TYPE_ID/events' \
--header 'X-Authorization: API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"dynamicAttributes":{
"location":"Garment District"
},
"location":{
"type":"Point",
"coordinates":[
"-73.9951",
"40.7541"
]
}
}'
import { Configuration, EventRequest, EventsApi } from '@skyledge/sdk';
const configuration = new Configuration({
apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
basePath: 'https://api.skyledge.com',
});
const data: Partial<EventRequest> = {
dynamicAttributes: {
location: 'Garment District',
} as any,
location: {
type: 'Point',
coordinates: [[-73.9951, 40.7541]],
},
};
const eventTypeIdentifier = EVENT_TYPE_IDENTIFIER;
const eventsApi = new EventsApi(configuration);
const createEvent = await eventsApi.createEvent(eventTypeIdentifier, data);
console.log(createEvent.status);
import requests
import json
url = "https://api.skyledge.com/event-types/EVENT_TYPE_ID/events"
payload = json.dumps({
"dynamicAttributes":{
"location":"Garment District"
},
"location":{
"type":"Point",
"coordinates":[
"-73.9951",
"40.7541"
]
}
})
headers = {
'X-Authorization': 'API_KEY',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
And last but not least, the potion ineffective event will look like this on our platform:

Special Powers - Creating Geofences

Here’s a little secret, developers have a lot more flexibility with the types of events they can generate. Instead of a simple marker, you could create Events that specify a geofence using simple GeoJSON, check this out:

Creating Event - Flying Limit Exceeded

POST api.skyledge.com/event-types/{eventTypeIdentifier}/events
{
"dynamicAttributes":{
"location":"Times Square"
},
"location":{
"type":"Polygon",
"coordinates":[
[
[-73.9872, 40.7611],
[-73.9923, 40.7543],
[-73.9862, 40.7516],
[-73.9811, 40.7586],
[-73.9872, 40.7611]
]
]
}
}
cURL
NodeJs
Python
curl --location --request POST 'https://api.skyledge.com/event-types/EVENT_TYPE_ID/events' \
--header 'X-Authorization: API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"dynamicAttributes":{
"location":"Times Square"
},
"location":{
"type":"Polygon",
"coordinates":[
[
[-73.9872, 40.7611],
[-73.9923, 40.7543],
[-73.9862, 40.7516],
[-73.9811, 40.7586],
[-73.9872, 40.7611]
]
]
}
}'
import { Configuration, EventRequest, EventsApi } from '@skyledge/sdk';
const configuration = new Configuration({
apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
basePath: 'https://api.skyledge.com',
});
const data: Partial<EventRequest> = {
dynamicAttributes: {
location: 'Times Square',
} as any,
location: {
type: 'Polygon',
coordinates: [
[
[-73.9872, 40.7611],
[-73.9923, 40.7543],
[-73.9862, 40.7516],
[-73.9811, 40.7586],
[-73.9872, 40.7611],
],
],
},
};
const eventTypeIdentifier = EVENT_TYPE_IDENTIFIER;
const eventsApi = new EventsApi(configuration);
const createEvent = await eventsApi.createEvent(eventTypeIdentifier, data);
console.log(createEvent.status);
import requests
import json
url = "https://api.skyledge.com/event-types/EVENT_TYPE_ID/events"
payload = json.dumps({
"dynamicAttributes":{
"location":"Times Square"
},
"location":{
"type":"Polygon",
"coordinates":[
[
[-73.9872, 40.7611],
[-73.9923, 40.7543],
[-73.9862, 40.7516],
[-73.9811, 40.7586],
[-73.9872, 40.7611]
]
]
}
})
headers = {
'X-Authorization': 'API_KEY',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
There you have it! A geofence that helps us detect our flying person entering the prohibited airspace of Times Square!
Flying Person detected in Times Square!