# Add Drone

This API provides programmatic access to add a new drone to the system with secure API key authentication for authorized users.

### Authentication&#x20;

To use the API, insert your API key in the Authorization header like this:

```javascript
Authorization: Bearer <YOUR_API_KEY>
```

Replace `<YOUR_API_KEY>` with your AeroGCS API key. Without it, you'll get a 401 Unauthorized error.

### Method

**POST**&#x20;

#### **Post Data Parameters**

| Parameter                | Description                                | Optional |
| ------------------------ | ------------------------------------------ | -------- |
| **droneID**              | Unique identifier for the drone.           | No       |
| **droneName**            | Name assigned to the drone.                | No       |
| **uin**                  | Unique Identification Number of the drone. | No       |
| **model**                | Model of the drone.                        | Yes      |
| **serialNo**             | Serial number of the drone.                | Yes      |
| **fcsNo**                | Flight control system number of the drone. | Yes      |
| **rcsNo**                | Remote control system number of the drone. | Yes      |
| **board\_type**          | Type of board used in the drone.           | Yes      |
| **green\_build\_number** | Build number for the green version.        | Yes      |
| **device\_ram**          | RAM capacity of the device.                | Yes      |
| **android\_version**     | Version of the Android operating system.   | Yes      |
| **device\_model\_name**  | Model name of the device.                  | Yes      |
| **firmware\_version**    | Version of the drone's firmware.           | Yes      |
| **license\_type**        | Type of license associated with the drone. | Yes      |

### HTTP Request <a href="#http-request-33" id="http-request-33"></a>

{% code overflow="wrap" %}

```json
https://ags.aeromegh.com/Aeromegh/addDrone?${teamId}
```

{% endcode %}

### URL Parameters <a href="#http-response-32" id="http-response-32"></a>

URL Parameters are:

| Parameter  | Description                                         |
| ---------- | --------------------------------------------------- |
| **teamID** | Unique identifier for the team managing the drones. |

### HTTP Response <a href="#http-response-32" id="http-response-32"></a>

Response Codes Explanation:

| Code | Details                     | Message                      |
| ---- | --------------------------- | ---------------------------- |
| 200  | The request was successful. | "OK"                         |
| 400  | Request parameters missing. | "Request parameters missing" |
| 500  | Internal server error.      | "Internal server error"      |

### Code Snippet

Examples of how you can call this API using curl, Node.js, and Python

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

```json
curl --location 'https://ags.aeromegh.com/Aeromegh/addDrone?teamId=a16afc9b-5205-4fa5-8c42-6276ce1e3281' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API_KEY>' \
--data '{
    "droneID": "P000010024003B3131510137381045",
    "droneName": "testapi",
    "uin": "BTASD123DB746",
    "model": "134", 
    "serialNo": "34665dffd4554", 
    "fcsNo": "dgf34554", 
    "rcsNo": "ws43433", 
    "board_type": "cubeOrangePlus", 
    "green_build_number": "103.265.20240425.01", 
    "device_ram": "12GB", 
    "android_version": "Android 9", 
    "device_model_name": "QUALCOMM MK15", 
    "firmware_version": "4.4.4", 
    "license_type": "OEM" 
}'
```

{% endtab %}

{% tab title="Node" %}

```javascript
//Please install 'axios' module first
//Set your API key before making the request
const axios = require('axios');
let data = JSON.stringify({
  "droneID": "P000010024003B3131510137381045",
  "droneName": "testapi",
  "uin": "BTASD123DB746",
  "model": "134",
  "serialNo": "34665dffd4554",
  "fcsNo": "dgf34554",
  "rcsNo": "ws43433",
  "board_type": "cubeOrangePlus",
  "green_build_number": "103.265.20240425.01",
  "device_ram": "12GB",
  "android_version": "Android 9",
  "device_model_name": "QUALCOMM MK15",
  "firmware_version": "4.4.4",
  "license_type": "OEM"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://ags.aeromegh.com/Aeromegh/addDrone?teamId=a16afc9b-5205-4fa5-8c42-6276ce1e3281',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer <API_KEY>'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
//Please install 'requests' AND 'json' package first
//Set your API key before making the request
import requests
import json

url = "https://ags.aeromegh.com/Aeromegh/addDrone?teamId=a16afc9b-5205-4fa5-8c42-6276ce1e3281"

payload = json.dumps({
  "droneID": "P000010024003B3131510137381045",
  "droneName": "testapi",
  "uin": "BTASD123DB746",
  "model": "134",
  "serialNo": "34665dffd4554",
  "fcsNo": "dgf34554",
  "rcsNo": "ws43433",
  "board_type": "cubeOrangePlus",
  "green_build_number": "103.265.20240425.01",
  "device_ram": "12GB",
  "android_version": "Android 9",
  "device_model_name": "QUALCOMM MK15",
  "firmware_version": "4.4.4",
  "license_type": "OEM"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <API_KEY>'
}

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

print(response.text)

```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note:** Replace **`<API_KEY>`** with the actual API\_KEY provided by Aeromegh.
{% endhint %}

### &#x20;API Response

Example of API response in JSON format:

```json
{
    "message" : "Drone has been registered"
}
```

### API Response Parameter&#x20;

Following parameter is included in API response:

| Parameter   | Description                          |
| ----------- | ------------------------------------ |
| **message** | returned message indicating response |
