This will cover the main operations that you can perform through the API: creating new records, listing, updating and deleting.

Response Codes

When everything goes fine, XFleet will reply with the following codes:

HTTP operation Response code
POST 204 - Resource created
PATCH 200 - Successful
DELETE 204 - No content
GET 200 - Successful

Data Types

In our API you will encounter the following data types:

Type Example
string "I like apple pie"
int 314
float 3.1415
decimal(precision, scale) 3.14
date "2019-03-14"
datetime "2019-03-14T23:10:37"
time "23:10:37"
list "[...]"

Create

$ curl -H 'Authorization: ...' \
       -H 'Content-type: application/json' \
       -X POST \
       -d '{ your JSON }' \
       https://app.xfleet.io/api/v1/companies/{company}/{entity}

Where:

  • {company} is your company ID
  • {entity} is the entity that you're creating (eg: vehicles, orders, clients)

Read

List records

$ curl -H 'Authorization: ...' \
       -X GET \
       https://app.xfleet.io/api/v1/companies/{company}/{entity}

Where:

  • {company} is your company ID
  • {entity} is the entity that you're creating (eg: vehicles, orders, clients)

You can customize the search with the following query parameters:

  • $orderby: The field(s) to use for ordering the results. Eg: ?$orderby=id,createdAt desc
  • $skip: The number of records to skip from. Eg: ?$skip=100
  • $top: The maximum number of records to return. Eg: ?$top=10
  • $filter: An expression for filtering the results. Eg: ?$filter=licensePlate eq 'NY1234' and driver.name like '%John%'

Update

The update of existing records is performed using the PATCH HTTP verb. Please note that the updates are partials (that is, all missing fields are left untouch).

$ curl -H 'Authorization: ...' \
       -H 'Content-type: application/json' \
       -X PATCH \
       -d '{ JSON with the fields that need to be updated }' \
       https://app.xfleet.io/api/v1/companies/{company}/{entity}/{id}

Where:

  • {company} is your company ID
  • {entity} is the entity that you're updating (eg: vehicles, orders, clients)
  • {id} is the ID of the record to update

Delete

To delete one or more records you can use the DELETE HTTP method.

Delete one record

$ curl -H 'Authorization: ...' \
       -X DELETE \
       https://app.xfleet.io/api/v1/companies/{company}/{entity}/{id}

Where:

  • {company} is your company ID
  • {entity} is the entity that you're deleting (eg: vehicles, orders, clients)
  • {id} is the ID of the record to delete

Delete more records

$ curl -H 'Authorization: ...' \
       -X DELETE \
       https://app.xfleet.io/api/v1/companies/{company}/{entity}?$filter=some criteria

Where:

  • {company} is your company ID
  • {entity} is the entity that you're deleting (eg: vehicles, orders, clients)