# Sky Ledge API - Quick start

We’re going to show you how easy it is to:

1. [Get your Sky Ledge API Key](#getting-your-sky-ledge-api-key)&#x20;
2. [Create a Control Room via API](#creating-a-control-room)&#x20;
3. [Create an Asset and display it on a map](#creating-asset-our-first-truck)

This guide will just focus on the API calls, the next section will unpack this in more detail using our Hero Potions Inc example

### Getting your Sky Ledge API Key&#x20;

To get your API Key:

1. Click on the Manage Organization menu item
2. Click on API Keys in the sidebar
3. Add your API Key as part of a X-Authorization header in your API requests

{% embed url="<https://www.loom.com/share/160b79771df04f6db5f98204137205e6>" %}
How to retrieve your API Key
{% endembed %}

### **Creating assets and displaying them on a map in four steps**

#### **Creating a Control Room**

```
POST api.skyledge.com/controlrooms

// raw JSON body for api request
{  
   "name":"Hero Logistics",
   "description":"Real-time monitoring of Hero Logistics"
}

```

{% tabs %}
{% tab title="cURL" %}

```
curl --location --request POST 'https://api.skyledge.com/controlrooms' \
--header 'X-Authorization: API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{  
   "name":"Hero Logistics",
   "description":"Real-time monitoring of Hero Logistics"
}'
```

{% endtab %}

{% tab title="NodeJs" %}

```
import {
  Configuration,
  ControlRoomsApi,
  CreateControlRoomRequest,
} from '@skyledge/sdk';

const configuration = new Configuration({
  apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
  basePath: 'https://api.skyledge.com',
});

const data: Partial<CreateControlRoomRequest> = {
  name: 'Hero Logistics',
  description: 'Real-time monitoring of Hero Logistics',
};

const controlRoomApi = new ControlRoomsApi(configuration);

const newControlRoom = await controlRoomApi.createControlRoom(data);

console.log(newControlRoom.status);

```

{% endtab %}

{% tab title="Python" %}

```
import requests
import json

url = "https://api.skyledge.com/controlrooms"

payload = json.dumps({
  "name": "Hero Logistics",
  "description": "Real-time monitoring of Hero Logistics"
})
headers = {
  'X-Authorization': 'API_KEY',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

#### **Creating an Asset Type - Truck**

```
POST api.skyledge.com/asset-types

{  
   "identifier":"truck",
   "name":"Delivery Truck",
   "description":"Trucks belonging to our delivery fleet"
}

```

{% tabs %}
{% tab title="cURL" %}

```
curl --location --request POST 'https://api.skyledge.com/asset-types' \
--header 'X-Authorization: API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{  
   "identifier":"truck",
   "name":"Delivery Truck",
   "description":"Trucks belonging to our delivery fleet"
}'
```

{% endtab %}

{% tab title="NodeJs" %}

```
import { Configuration, AssetTypeRequest, AssetTypesApi } from '@skyledge/sdk';

const configuration = new Configuration({
  apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
  basePath: 'https://api.skyledge.com',
});

const data: Partial<AssetTypeRequest> = {
  identifier: 'truck',
  name: 'Delivery Truck',
  description: 'Trucks belonging to our delivery fleet',
};

const assetTypeApi = new AssetTypesApi(configuration);

const newAssetType = await assetTypeApi.createAssetType(data);

console.log(newAssetType.status);

```

{% endtab %}

{% tab title="Python" %}

```
import requests
import json

url = "https://api.skyledge.com/asset-types"

payload = json.dumps({
  "identifier": "truck",
  "name": "Delivery Truck",
  "description": "Trucks belonging to our delivery fleet"
})
headers = {
  'X-Authorization': 'API_KEY',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

#### **Assigning our Truck Asset Type to our Control Room**

```
PUT api.skyledge.com/controlrooms/{controlRoomId}/asset-types/{assetTypeId}

{}

```

{% tabs %}
{% tab title="cURL" %}

```
curl --location --request PUT 'https://api.skyledge.com/controlrooms/CONTROL_ROOM_ID/asset_types/ASSET_TYPE_ID' \
--header 'X-Authorization: API_KEY'
```

{% endtab %}

{% tab title="NodeJs" %}

```
import { Configuration, AssetTypesApi } from '@skyledge/sdk';

const configuration = new Configuration({
  apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
  basePath: 'https://api.skyledge.com',
});

const assetTypeApi = new AssetTypesApi(configuration);

const controlRoomId = CONTROL_ROOM_ID;
const assetTypeId = ASSET_TYPE_ID;

const addAssetType2ControlRoom =
  await assetTypeApi.assignsAssetTypeToControlRoom(controlRoomId, assetTypeId);

console.log(addAssetType2ControlRoom.status);

```

{% endtab %}

{% tab title="Python" %}

```
import requests

url = "https://api.skyledge.com/controlrooms/CONTROL_ROOM_ID/asset_types/ASSET_TYPE_ID"

payload={}
headers = {
  'X-Authorization': 'API_KEY'
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

#### Creating Asset - Our First Truck

```
POST api.skyledge.com/asset-types/{assetTypeId}/assets

{  
   "assetIdentifier":"truck_001",
   "name":"Mercedes Truck",
   "description":"Refrigerated truck.",
   "attributes":{  
      "icon":"truck",
      "model":"Actos Rigid Truck",
      "year":"2019",
      "asset-manager":"David Lawton",
      “colour” : “pink”
   },
   "metrics":{  
      "maximumCarryingWeightTonnes":3,
      "currentSpeed":80,
      “temperatureOfCargo” : 2
   },
   "location":{  
      "type":"Point",
      "coordinates":[  
         -73.9848,
         40.7586
      ]
   }
}

```

{% tabs %}
{% tab title="cURL" %}

```
curl --location --request POST 'https://api.skyledge.com/asset-types/ASSET_TYPE_ID/assets' \
--header 'X-Authorization: API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{  
   "assetIdentifier":"truck_001",
   "name":"Mercedes Truck",
   "description":"Refrigerated truck.",
   "attributes":{  
      "icon":"truck",
      "model":"Actos Rigid Truck",
      "year":"2019",
      "asset-manager":"David Lawton",
      "colour" : "pink"
   },
   "metrics":{  
      "maximumCarryingWeightTonnes":3,
      "currentSpeed":80,
      "temperatureOfCargo" : 2
   },
   "location":{  
      "type":"Point",
      "coordinates":[  
         -73.9848,
         40.7586
      ]
   }
}'
```

{% endtab %}

{% tab title="NodeJs" %}

```
import { Configuration, AssetRequest, AssetsApi } from '@skyledge/sdk';

const configuration = new Configuration({
  apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
  basePath: 'https://api.skyledge.com',
});

const data: AssetRequest = {
  assetIdentifier: 'truck_001',
  name: 'Mercedes Truck',
  description: 'Refrigerated truck.',
  attributes: {
    icon: 'truck',
    model: 'Actos Rigid Truck',
    year: '2019',
    assetManager: 'David Lawton',
    colour: 'pink',
  } as any,
  metrics: {
    maximumCarryingWeightTonnes: 3,
    currentSpeed: 80,
    temperatureOfCargo: 2,
  },
  location: {
    type: 'Point',
    coordinates: [-73.9848, 40.7586],
  },
};

const assetTypeId = ASSET_TYPE_ID;

const assetApi = new AssetsApi(configuration);

const createAsset = await assetApi.createAsset(assetTypeId, data);

console.log(createAsset.status);

```

{% endtab %}

{% tab title="Python" %}

```
import requests
import json

url = "https://api.skyledge.com/asset-types/ASSET_TYPE_ID/assets"

payload = json.dumps({
  "assetIdentifier": "truck_001",
  "name": "Mercedes Truck",
  "description": "Refrigerated truck.",
  "attributes": {
    "icon": "truck",
    "model": "Actos Rigid Truck",
    "year": "2019",
    "asset-manager": "David Lawton",
    "colour": "pink"
  },
  "metrics": {
    "maximumCarryingWeightTonnes": 3,
    "currentSpeed": 80,
    "temperatureOfCargo": 2
  },
  "location": {
    "type": "Point",
    "coordinates": [
      -73.9848,
      40.7586
    ]
  }
})
headers = {
  'X-Authorization': 'API_KEY',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

Voila. In four steps we’ve created a Control Room, an asset typ&#x65;**,** pushed our first asset type to the Control Room and created our first asset.


---

# 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://docs.skyledge.com/getting-started/sky-ledge-api-quick-start.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.
