---
description: >-
  "Seamlessly initiate flights with detailed telemetry data retrieval using
  Aeromegh's startFlight API."
---

# Start Flight

This API provides programmatic access to detailed startFlight information with secure API key authentication. Retrieve parameters like flight ID, upstream topic, downstream topic, stream key, validity period, stream URI, and stream server base.

### 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;

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

{% code overflow="wrap" %}
```url
https://ags.aeromegh.com/Aeromegh/startFlight?projectName={projectName}&planName={planName}&droneId={droneId}&teamId={teamId}&firmwareVersion={firmwareVersion}&greenBuildNumber={greenBuildNumber}&areaCalculateMethod={areaCalculateMethod}

```
{% endcode %}

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

URL Parameters are:

| Parameter               | Description                                                                                |
| ----------------------- | ------------------------------------------------------------------------------------------ |
| **projectName**         | Name of the project associated with the flight.                                            |
| **planName**            | Name of the flight plan to execute.                                                        |
| **droneId**             | Unique identifier for the drone initiating the flight.                                     |
| **teamId**              | Unique identifier for the team managing the flight.                                        |
| **firmwareVersion**     | (Optional) Version of the drone's firmware.                                                |
| **greenBuildNumber**    | (Optional) Build number for the green version.                                             |
| **areaCalculateMethod** | (Optional) Specifies the method for area calculation, must be either "spraying" or "plot". |

### 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 --request POST 'https://ags.aeromegh.com/Aeromegh/startFlight?projectName=sandip24april&planName=435pm&droneId=P00001004F002B3131510137383337&teamId=a16afc9b-5205-4fa5-8c42-6276ce1e3281&firmwareVersion=4.4.4&greenBuildNumber=103.265.20240425.01&areaCalculateMethod=spraying' \
--header 'Authorization: Bearer <API_KEY>'
```
{% endtab %}

{% tab title="Node" %}
```javascript
//Please install 'axios' module first
//Set your API key before making the request
const axios = require('axios');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://ags.aeromegh.com/Aeromegh/startFlight?projectName=sandip24april&planName=435pm&droneId=P00001004F002B3131510137383337&teamId=a16afc9b-5205-4fa5-8c42-6276ce1e3281&firmwareVersion=4.4.4&greenBuildNumber=103.265.20240425.01&areaCalculateMethod=spraying',
  headers: { 
    'Authorization': 'Bearer <API_KEY>'
  }
};

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


```
{% endtab %}

{% tab title="Python" %}
```python
//Please install 'requests' package first
//Set your API key before making the request
import requests

url = "https://ags.aeromegh.com/Aeromegh/startFlight?projectName=sandip24april&planName=435pm&droneId=P00001004F002B3131510137383337&teamId=a16afc9b-5205-4fa5-8c42-6276ce1e3281&firmwareVersion=4.4.4&greenBuildNumber=103.265.20240425.01&areaCalculateMethod=spraying"

payload = {}
headers = {
  '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
{
    "flightId": "54e9ce7b-e2b8-455e-b351-590c1bf2abdf",
    "upStreamTopic": "wicqkj7f433mhkzxr8yzf5644vpnv36rtsept99wmq3zwq6h26xqhzaf2k1jlr32",
    "downStreamTopic": "8ft0jnqc14va4tf2hfxmsqt8yg565yzf1hso86cfqp2dgdje1v8rj6o9464syefn",
    "streamKey": "20pr1ospms",
    "validTill": "Sun, 12 May 2024 07:53:48 GMT",
    "streamUri": "rtmp://stream02.aeromegh.com/LiveApp",
    "streamServerBase": "stream02.aeromegh.com"
}
```

### API Response Parameter&#x20;

The following parameters are included in API response:&#x20;

| Parameter            | Description                                                                                     |
| -------------------- | ----------------------------------------------------------------------------------------------- |
| **flightId**         | Unique identifier for the initiated flight.                                                     |
| **upStreamTopic**    | Topic for upstream communication, facilitating data transmission from the drone to the server.  |
| **downStreamTopic**  | Topic for downstream communication, enabling data reception from the server to the drone.       |
| **streamKey**        | Key used for stream authentication.                                                             |
| **validTill**        | Timestamp indicating the expiration time of the initiated flight.                               |
| **streamUri**        | Uniform Resource Identifier (URI) for streaming, specifying the destination for streaming data. |
| **streamServerBase** | Base URL of the streaming server facilitating data transmission.                                |
