> For the complete documentation index, see [llms.txt](https://aerogcs-api-docs.aeromegh.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aerogcs-api-docs.aeromegh.com/aerogcs-enterprise-apis/add-offline-flight-logs.md).

# Add Offline Flight Logs

"Easily upload offline flight logs and seamlessly integrate drone flight data with Aeromegh's addOfflineFlightLogs API."

This API provides programmatic access for uploading offline flight logs with secure API key authentication. This endpoint accepts POST requests and requires authentication through a bearer token, facilitating the integration of flight data into the system.

### 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 | Example                                |
| --------------- | ------------------------------------------ | -------- | -------------------------------------- |
| **projectname** | Specifies the name of the project          | No       | "test"                                 |
| **planname**    | Indicates the name of the flight plan      | No       | "test"                                 |
| **aerostackid** | Unique identifier for the Aerostack system | No       | "999e8416-d5af-4828-8c44-a83f1e556d4e" |
| **flightid**    | Unique identifier for the flight           | No       | "1c0d5d87-4a1c-4613-a5eb-2bb1c0a13791" |
| **droneid**     | Unique identifier for the drone            | No       | "P00001004F002B3131510137383337"       |
| **teamid**      | Unique identifier for the team             | No       | "a16afc9b-5205-4fa5-8c42-6276ce1e3281" |

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

{% code overflow="wrap" %}

```url
https://ags.aeromegh.com/Aeromegh/addOfflineFlightLogs
```

{% endcode %}

### 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/addOfflineFlightLogs' \
--header 'projectname: test' \
--header 'planname: test' \
--header 'aerostackid: 999e8416-d5af-4828-8c44-a83f1e556d4e' \
--header 'flightid: 1c0d5d87-4a1c-4613-a5eb-2bb1c0a13791' \
--header 'droneid: P00001004F002B3131510137383337' \
--header 'teamid: a16afc9b-5205-4fa5-8c42-6276ce1e3281' \
--header 'Authorization: Bearer <API_KEY>' \
--form 'file=@"postman-cloud:///1ef0c693-4ecd-4390-981e-1feebdb9fdcc"'
```

{% endtab %}

{% tab title="Node" %}

```javascript
//Please install 'axios' , ' form-data' and ' fs ' module first
//Set your API key before making the request
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('file', fs.createReadStream('postman-cloud:///1ef0c693-4ecd-4390-981e-1feebdb9fdcc'));

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://ags.aeromegh.com/Aeromegh/addOfflineFlightLogs',
  headers: { 
    'projectname': 'test', 
    'planname': 'test', 
    'aerostackid': '999e8416-d5af-4828-8c44-a83f1e556d4e', 
    'flightid': '1c0d5d87-4a1c-4613-a5eb-2bb1c0a13791', 
    'droneid': 'P00001004F002B3131510137383337', 
    'teamid': 'a16afc9b-5205-4fa5-8c42-6276ce1e3281', 
    'Authorization': 'Bearer <API_KEY>', 
    ...data.getHeaders()
  },
  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' package first
//Set your API key before making the request
import requests

url = "https://ags.aeromegh.com/Aeromegh/addOfflineFlightLogs"

payload = {}
files=[
  ('file',('1ef0c693-4ecd-4390-981e-1feebdb9fdcc',open('postman-cloud:///1ef0c693-4ecd-4390-981e-1feebdb9fdcc','rb'),'application/octet-stream'))
]
headers = {
  'projectname': 'test',
  'planname': 'test',
  'aerostackid': '999e8416-d5af-4828-8c44-a83f1e556d4e',
  'flightid': '1c0d5d87-4a1c-4613-a5eb-2bb1c0a13791',
  'droneid': 'P00001004F002B3131510137383337',
  'teamid': 'a16afc9b-5205-4fa5-8c42-6276ce1e3281',
  'Authorization': 'Bearer <API_KEY>'
}

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

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": "Logs added"
}
```

### API Response Parameter&#x20;

The following parameter is included in API response::

| Parameter   | Description                                                                                                                                                                   |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **message** | A message indicating the result of the operation. In this case, it confirms that the logs has been successfully added to the Aeromegh system. The value will be "Logs added". |
