Sky Ledge Docs
  • Welcome
  • Getting Started
    • Creating Your Account
    • Sky Ledge API - Quick start
    • Developer Guide
      • Creating A Control Room
      • Creating Event Types
      • Creating Events (aka Alerts or Notifications)
      • Creating Asset Types
      • Linking Asset Types to a Control Room
      • Creating Assets
      • Creating and Tracking a Metric
      • Future Updates
  • Fundamentals
    • Launchpad
    • Control Rooms
    • Assets
    • Events
    • Places
    • Cycles
    • Widgets
  • API Docs
  • Client Libraries
    • NodeJs
  • Community
    • Where to find us
  • Knowledge Base
    • Articles
      • What is a LaunchPad
      • What is a Control Room
      • How to use the maps controls and layers options
      • Map marker explained
      • Navigating your profile
      • What is an Event
      • What is an Event Type
      • Exploring the event stream
      • Event Stream Filtering
      • What is an Asset
      • What are asset types
      • Understanding Focus Mode
      • Navigating Asset List Mode
      • Table column selection
      • Asset metrics
      • What is a place
      • Searching and Creating a Place
      • Getting Started with Place Notifications
      • Places and how to use the gatehouse report
      • How to use the Event Report (Top-down Investigations Module)
      • What is a Task
      • How to process a task
      • Task Notifications
      • How to invite a work colleague
      • How to submit an awesome ticket
      • Understanding Your Weekly Email Reports
      • Knowledge Base Template
    • What's New
    • Archived - What's News
Powered by GitBook
On this page
  • Creating Events - Using the interface
  • Creating Events - Using the API
  • Special Powers - Creating Geofences
  1. Getting Started
  2. Developer Guide

Creating Events (aka Alerts or Notifications)

PreviousCreating Event TypesNextCreating Asset Types

Last updated 2 years ago

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. Open the Control Room you created in the previous step (Heroes Flying Potion - Real-time Monitoring)

  2. In the side panel, click ‘Post an Event’

  3. Select the Event Type we’d like to post to, in this case “Customer Flying”

  4. Fill in the placeholders with the actual location and name

  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:

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. Head over to ‘Manage Event Types’ in your Control Room

  2. Open the Event Type of interest (e.g. Customer Flying)

  3. Navigate to the ‘Event Type Schema’ tab

  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:

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 --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:

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 --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 --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 --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!

Click 'Post an Event' button
Click on 'Customer Flying' Event Type
Create Event page with placeholders previously designated in Event Type
Click 'Event Type Schema' to get Schema and POST request
Event Alert in Event Stream appearing in Control Room
Flying Person detected in Times Square!