Overview
The FleetSync API gives your systems access to the fleet data you manage in FleetSync.
The FleetSync API is a GraphQL API. Every request is a POST to a single endpoint:
https://fleetsync.io/api/graphqlRequests are authenticated with an access token that you obtain with the credentials of a service user. See Authentication for the steps.
Making a request
Send the query as JSON in the request body, together with the Authorization header:
curl https://fleetsync.io/api/graphql \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "query": "{ getCars { items { id vin make model year } cursor } }" }'The response is a JSON object with a data field. If something went wrong, the object has an errors field instead of, or in addition to, data:
{
"errors": [
{ "message": "Unauthorized" }
]
}Pagination
Queries that can return many rows, such as getCars, return a cursor next to items. Pass it back in the cursor argument to receive the next page. A null cursor means there are no more rows.
query NextPage($cursor: String) {
getCars(cursor: $cursor) {
items { id vin }
cursor
}
}Enums
Enum values are not sent as GraphQL enum names. FleetSync sends the code of the value instead, an integer for most enums and a string for a few. A field such as status is therefore a plain Int in responses and in arguments, and the schema definition file lists which code stands for which name. See Enums for the details and for the JSON-encoded fields that follow the same rule.
The schema
The complete schema is available as a schema definition file, which you can also browse online:
schema.graphqlLoad it into GraphiQL, Postman, Insomnia or your IDE to get validation and autocompletion, and keep it next to your integration code as the reference for types, fields and enum codes. The file is regenerated together with every FleetSync release.