This article covers CloudAhoy's Organization Flights API.
Accessing the Organization flights endpoint
The /org/flights endpoint is available at
https://www.cloudahoy.com/integration/v1/org/flights
All requests to OAuth-secured endpoints must include an Authorization header, which provides the access token on behalf of which the request is being made:
Authorization: Bearer <org access token>
Importing a Flight
Executing an HTTP POST on the organization flights endpoint, providing the appropriate access token and a CloudAhoy formatted CSV file (or another CloudAhoy-supported file type, such as KML, GPX, or G1000 CSV) will import the flight into the account of a member of the organization.
When uploading a CloudAhoy formatted CSV file, the entire flight’s data can be uploaded in one file, or the upload can be incremental. For example, a 12-hours flight can be split into 4 files, 3 hours in each. All the files must have the same identical metadata.
Files of any other type must include the entire flight in a single file.
POST requests to the /org/flights endpoint require the org:flights:import OAuth scope
Specifying Account
The organization OAuth token with scope org:flights:import provides the ability to import into the account of any user or tail that is a member of the organization for which the token was issued.
Storing by User
Most organizational accounts are set up to store flight data in a user’s account.
In order to determine the specific account into which the flight should be imported, the email address corresponding to the account into which the flight will be imported must be specified.
If importing a CloudAhoy-formatted CSV file, the CSV file must specify the email field in the CSV file.
If importing any other supported filetype, the METADATA
form field of the POST must specify the owner
field (see the Form fields section below).
Storing by Tail
For organizations set to store flight data by a Tail Number, the flight’s metadata can omit an owner field and instead include only a tail field.
The METADATA
form field of the POST must specify the tail field (see the Form fields section below).
Including an owner will cause the flight to also show up in the flights tab for the specified email.
Form Fields
The file to import must be specified by the IMPORT form field of the post.
A JSON-formatted string containing metadata about the flight must be specified by the METADATA
form field of the POST. The properties of the metadata are described in the following table:
Metadata Object
Property | Type | Description |
---|---|---|
importerVersion |
string | Required The version of the importing software. This is free text and, ideally, should change with each release of the application performing the import |
owner |
object | Optional if... 1. Importing a CloudAhoy-formatted CSV file 2. Importing into a Store by Tail organization Required in all other requests An object containing the properties: * name Required if not importing a CloudAhoy-formatted CSV file (GPX, KML, Etc.). See details below.* role (optional)* flags (optional)Where name is the email address of the account to which the flight should import.Where role is one of : Pilot , Copilot , Student , Instructor , Passenger , Safety Pilot , Examiner and flags is an optional sub-object containing any combination of these properties: pic , solo , or checkride , with a boolean values indicating with the owner was the Pilot in command, on a solo flight, or on a checkride, respectively. Any property not provided will default to false .NOTE: the owner and other may not have the same role . A 400 error will be generated if they do.NOTE: the owner and other may not have any of the same flags set to true. A 400 error will be generated if they do.Examples: owner: { 'name': 'orgmember@org.com', 'role': 'Instructor' } owner: { 'flags': { 'pic': true } } owner: { 'role': 'Student', 'flags': { 'pic': true } } |
other |
object | Optional an object containing the properties: * name * role (optional - ignored if name isn't provided)* flags (optional - ignored if name isn't provided)Where name is the name or email address of the second occupant of the aircraft. If an email address is specified, and that email address corresponds to a CloudAhoy user that is a buddy of the owner, the flight will also appear in the account of the buddy.Where role is one of : Pilot , Copilot , Student , Instructor , Passenger , Safety Pilot , Examiner And flags is an optional sub-object containing any combination of these properties: pic , solo , or checkride , with a boolean values indicating with the owner was the Pilot in command, on a solo flight, or on a checkride, respectively. Any property not provided will default to false .NOTE: the owner and other may not have the same role . A 400 error will be generated if they do.NOTE: the owner and other may not have any of the same flags set to true. A 400 error will be generated if they do.Examples: other: { 'name': 'Pete Mitchell', 'role': 'Instructor' } other: { 'name': 'maverick@miramar.navy.gov', 'flags': { 'pic': true } } other: { 'name': 'Seth', 'role': 'Student', 'flags': { 'pic': true } } |
tail |
string | Required if... 1. Importing into a Store by Tail organization Optional for all other requests The tail number of the aircraft flown during the flight. If not provided, defaults to *UNK |
remarks |
string | Optional Remarks about the flight. |
isSim |
integer | Optional 1 if this flight was flown in a simulator, 0 (or not provided) otherwise. |
aircraft_make |
string | Optional The make of the aircraft, e.g. CESSNA Ignored if aircraft_model is not also specified. |
aircraft_model |
string | Optional The mode of the aircraft, e.g. "172" Ignored if aircraft_make is not also specified. |
aircraft_make and aircraft_model
Theaircraft_make
and aircraft_model
fields should correspond to the make/model associated with an aircraft type defined within the organization. More information about defining aircraft can be found in the Organization Aircraft help topic.For example, the following shell command uses curl to import the file /tmp/my_flight.csv:
$ curl -F "IMPORT=@/tmp/my_flight.csv" \ -F 'METADATA={"importerVersion":"v1.23.4"}' \ -H "Authorization: Bearer <org access token>" \ https://www.cloudahoy.com/integration/v1/org/flights
Here’s another example, importing the file /tmp/g1000.csv and specifying the owner and other parameters via the METADATA
form field of the POST.
curl -F "IMPORT=@/tmp/g1000.csv" \ -F 'METADATA={"importerVersion":"v1.23.4", "owner":{"name":"maverick@topgun.mil", "role":"Student"}, "other":{"name":"viper@topgun.mil", "role":"Instructor"}, "aircraft_make":"GRUMMAN", "aircraft_model":"F-14", "isSim": 1}' \ -H "Authorization: Bearer <org access token>" \ https://www.cloudahoy.com/integration/v1/org/flights
Return value
A successful import will result in the following return object:
Parameter | Type | Description |
---|---|---|
key |
string | A temporary key that allows the flight to be immediately debriefed |
status |
string | Indication of success: OK |
flightId |
string | The ID of the uploaded flight in the user's account. NOTE: This flightId is not globally unique but is unique within the user's account. |
error |
string | Present and populated only if the flight was successfully imported, but some problems make it not-debriefable, such as no airborne segments or too few data points. The value returned indicates the problem. |
The key
returned may be used for a period of time to link directly to the flight:
http://www.cloudahoy.com/debrief/?key=<imported flight key>
Be aware that the import can be successful, but the flight can not be debriefable. This may occur if no airborne segments are detected in the flight or if there are too few data samples. In these cases, the error property will be present and populated in the object returned by the import.
If the request or file is malformed, an HTTP status 400 will be returned, with a text description of the problem.
Last Updated: