# Get Plans

This API provides programmatic access to detailed plan information for projects. Authenticate with an API key in the Authorization header. Retrieve plan IDs, project names, creation dates, and more. Integrate to streamline plan management.

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

**GET : get all the plans**

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

[https://ags.aeromegh.com/AeroMegh/AeroCapture/plans/\<projectId>/\<projectName>/\<searchString>/\<startIndex>/\<pageSize>](https://ags.aeromegh.com/AeroMegh/AeroCapture/plans/%3CprojectId%3E/%3CprojectName%3E/%3CsearchString%3E/%3CstartIndex%3E/%3CpageSize%3E)

### URL Parameters

URL parameters are

| Key            | Description                                     |
| -------------- | ----------------------------------------------- |
| project Name : | project name to fetch plans under this projects |
| project Id     | project id to fetch plans under this projects   |
| searchString : | search by planname                              |
| startIndex :   | get records start offset                        |
| pageSize :     | records on each page                            |

### HTTP Response Code

Response codes explanation:

| Code | Details                    |
| ---- | -------------------------- |
| 200  | message: "ok"              |
| 204  | No content                 |
| 400  | request parameters missing |
| 500  | 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/AeroCapture/plans/<projectName>/<searchString>/<startIndex>/<pageSize>' \
--header 'Authorization: Bearer <API_key>'

```

{% endtab %}

{% tab title="Node" %}

```javascript
//Please install 'axios' module first
//Set your API key before making the request your API key
const axios = require('axios');

let config = {
  method: 'get',
  maxBodyLength: Infinity,
  url: 'https://ags.aeromegh.com/AeroMegh/AeroCapture/plans/xdcf/%20/0/1000/eb4d317f-6703-44ea-83e7-5c654b1df06a?tasktype=0',
  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/AeroCapture/plans/xdcf/%20/0/1000/eb4d317f-6703-44ea-83e7-5c654b1df06a?tasktype=0"

payload = {}
headers = {
  'Authorization': 'Bearer <API_KEY>'
}

response = requests.request("GET", 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 %}

### API Response

Example of API response in JSON format:

```json
{
    
      {
        "plans": [
            {
                "id": "b8b016dc-a6e4-44ae-ad67-91c9c9c7a236",
                "project_name": "ndmvp2",
                "plan_name": "plan1",
                "user_id": "edb1bf33-0a01-4362-8474-e54e97873391",
                "date_and_time": "2023-08-29T11:25:48.317Z",
                "flight_source": "20.01507542048126  73.76465920705655",
                "flight_destination": "20.014820933045964  73.76443928606061",
                "plan_source_latlng": "20.01507542048126  73.76465920705655",
                "linked_map": null,
                "thumb": "https://pdrlimage.blob.core.windows.net/user-edb1bf33-0a01-4362-8474-e54e97873391/AeroGCSWorkspace/ndmvp2/plan1/Assets/planMap.png",
                "MissionType": 2,
                "geofenceData": {
                    "geofence": [
                        {
                            "lat": 20.0151333,
                            "lon": 73.7646886,
                            "alt": 7
                        },
                        {
                            "lat": 20.014784366616542,
                            "lon": 73.76462853922483,
                            "alt": 7
                        },
                        {
                            "lat": 20.01481353323206,
                            "lon": 73.76442703533068,
                            "alt": 7
                        },
                        {
                            "lat": 20.015172999998708,
                            "lon": 73.76448139600608,
                            "alt": 7
                        },
                        {
                            "lat": 20.0151333,
                            "lon": 73.7646886,
                            "alt": 7
                        }
                    ]
                },
                "pilot_id": "st=2023-09-11T00%3A02%3A58Z&se=2024-09-11T09%3A22%3A58Z&sp=racwdl&sv=2018-03-28&sr=c&sig=94WHOurXVxKFMEOCATOP1trAJRq12ZTgwYjA3PpleCk%3D"
            }
        ]
    }
    
}
```

### API Response Parameter Details

The following parameters are included in the API response :

* **id**: Unique identifier for the plan.
* **project\_name**: Name of the project to which this plan belongs.
* **plan\_name**: Name of the specific plan.
* **user\_id**: Unique identifier for the user associated with this plan.
* **date\_and\_time**: Date and time when the plan was created
* **flight\_source**: Latitude and longitude coordinates representing the source of the flight&#x20;
* **flight\_destination**: Latitude and longitude coordinates representing the destination of the flight&#x20;
* **plan\_source\_latlng**: Latitude and longitude coordinates representing the source of the plan&#x20;
* **linked\_map**: This attribute appears to be null, indicating there is no linked map associated with this plan.
* **thumb**: URL pointing to a thumbnail image associated with the plan&#x20;
* **MissionType**: Indicates the type of mission (`spraying plan`).
  * **Mission Type Values and Associated Plans:-** The API response includes a missionType value, represented as an integer, which corresponds to different plans. Below is a table illustrating the missionType values along with their associated plan names:

<table data-full-width="false"><thead><tr><th>missionType Value</th><th>Plan Name</th><th data-hidden></th></tr></thead><tbody><tr><td>0</td><td>Waypoints </td><td></td></tr><tr><td>1</td><td>Survey</td><td></td></tr><tr><td>2</td><td>Spraying</td><td></td></tr><tr><td>3</td><td>Vertical</td><td></td></tr><tr><td>5</td><td>Corridor</td><td></td></tr><tr><td>6</td><td>Circular</td><td></td></tr></tbody></table>

* **geofenceData**: Contains an array of geofence coordinates with their respective latitude, longitude, and altitude.
* **pilot\_id**: represent authentication or authorization token.


---

# 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://aerogcs-api-docs.aeromegh.com/aerogcs-enterprise-apis/get-plans.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.
