Beta > Assets Endpoints

About

All HTTP methods should be prepended by this service's endpoint:

https://api.withleaf.io/services/beta/api

See below the REST resources and their endpoints available in this service.

Assets (BETA)

This feature has the following endpoints available:

DescriptionEndpoints
Get all machinesGET /users/{leafUserId}/machines
Get a machineGET /users/{leafUserId}/machines/{machineId}
Get machine filesGET /users/{leafUserId}/machines/{machineId}/files
Create a machinePOST /users/{leafUserId}/machines
Update a machinePATCH /users/{leafUserId}/machines/{machineId}
Delete a machineDELETE /users/{leafUserId}/machines/{machineId}
Get all implementsGET /users/{leafUserId}/implements
Get an implementGET /users/{leafUserId}/implements/{implementId}
Get all operatorsGET /users/{leafUserId}/operators
Get an operatorGET /users/{leafUserId}/operators/{operatorId}

Get all machines

 GET /users/{leafUserId}/machines

Get the list of machines that are related to a given LeafUserId. Some fields can be sent as query parameters to filter the machines, such as:

Parameter (to filter by)Values
namemachine name
providerJohnDeere, Stara and CNHI
providerOrganizationIdprovider side organization id
serialNumbermachine serial number
originTypespecify the origin of the machine, must be either USER_CREATED, FILE_POOLED or PROVIDER_POOLED
createdTimemust match exactly the time of the record creation, ISO 8601 without timezone
beforeCreatedTimefilters for records created before the datetime, ISO 8601 without timezone
afterCreatedTimefilters for records created after the datetime, ISO 8601 without timezone
vinfilters machines by Vehicle Identification Number

You can also pass some parameters used exclusively for paging through results. They are:

  • page, an integer specifying the page being fetched (default is 0)
  • size, an integer specifying the size of the page (max is 100)
  • sort, the sorting order of the results; can be multi-value, where the first value to be passed will have preference in ordering over the next ones; you can also specify the order as asc or desc with asc being the default. Example: id, desc
    • Valid values for sorting are: id, leafUserId, name, provider, providerOrganizationId, providerMachineId, serialNumber, vin, model, make, category and modelYear
the default value for page size is 20

If the parameters page and size are not set, the endpoint will return 20 results.

Request examples

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/machines'

Response

[
{
"id": "e89b1861-bdbb-49b9-8e11-74840f7e1ea8",
"leafUserId": "faa6691a-7bf7-49c2-8934-b5b4c823aef8",
"name": "TestName",
"provider": "Leaf",
"providerMachineId": "08790ae9-d451-4158-9920-09d1ab1ba5e6",
"providerOrganizationId": "123456",
"originType": "PROVIDER_POOLED",
"createdTime": "2022-02-22T20:06:25.411Z",
"serialNumber": "123456",
"vin": "1234567890ABC",
"model": "ModelName",
"make": "MakerOfMachine",
"category": "Sprayer",
"modelYear": 2000
},
{
"id": "82725746-3150-490d-9f3f-a47151ac0669",
"leafUserId": "325f5ac0-6c57-4b4a-bdea-490ccddb06c4",
"name": "nameTest",
"provider": "Leaf",
"providerMachineId": "75f362b4-8f61-46f9-905b-a357fb239930",
"providerOrganizationId": "654321",
"originType": "FILE_POOLED",
"createdTime": "2022-02-22T20:06:25.411Z",
"serialNumber": "123456",
"vin": "1234567890ABC",
"model": "ModelName",
"make": "MakerOfMachine",
"category": "Harvester",
"modelYear": 2020
},
....
]

Get a machine

 GET /users/{leafUserId}/machines/{machineId}

Get the details of a given machine by its id.

Request examples

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/machines/{machineId}'

Response

{
"id": "UUID",
"leafUserId": "UUID",
"name": "str",
"provider": null,
"providerMachineId": null,
"providerOrganizationId": null,
"originType": "PROVIDER_POOLED",
"createdTime": "2022-02-22T20:06:25.411Z",
"serialNumber": "123456",
"vin": "1234567890ABC",
"model": "ModelName",
"make": "MakerOfMachine",
"category": "Sprayer",
"modelYear": 2000
}

Get machine files

 GET /users/{leafUserId}/machines/{machineId}/files

Get the details of machine operations files given a machine id. Some fields can be sent as query parameters to filter the machine files, such as:

Parameter (to filter by)Values
leafFileIdUUID
originTypespecify the origin of the machine, must be either USER_CREATED, FILE_POOLED or PROVIDER_POOLED
createdTimean ISO 8601 without timezone specifying the operation exact created time
beforeCreatedTimefilters for records created before the datetime, ISO 8601 without timezone
afterCreatedTimefilters for records created after the datetime, ISO 8601 without timezone
startTimemust match exactly the time of the start of the operation, ISO 8601 without timezone
endTimemust match exactly the time of the end of the operation, ISO 8601 without timezone
beforeStartTimean ISO 8601 without timezone, returns all operations that started before the specified time
afterStartTimean ISO 8601 without timezone, returns all operations that started after the specified time
beforeEndTimean ISO 8601 without timezone, returns all operations that ended before the specified time
afterEndTimean ISO 8601 without timezone, returns all operations that ended after the specified time
distanceValuea double value for the distance
greaterThanDistanceValuea double value for the distance, returns all operations that have a distance value greater than the specified distance
lessThanDistanceValuea double value for the distance, returns all operations that have a distance value lesser than the specified distance
distanceUnitmust be "Mile", "mile", "Feet" or "ft"

You can also pass some parameters used exclusively for paging through results. They are:

  • page, an integer specifying the page being fetched (default is 0)
  • size, an integer specifying the size of the page (max is 100)
  • sort, the sorting order of the results; can be multi-value, where the first value to be passed will have preference in ordering over the next ones; you can also specify the order as asc or desc with asc being the default. Example: id, desc
    • Valid values for sorting are: id, leafUserId, machineId, startTime, endTime, createdTime, leafFileId

Request examples

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/machines/{machineId}/files'

Response

[
{
"id": "e7916d05-97ae-404a-a467-e2512c202a2f",
"leafFileId": "e0e18a6f-4f88-4801-96e2-f39143f260e1",
"machineId": "98b244fc-7b2d-4acf-a51a-58d20ae27355",
"startTime": "2022-02-22T20:06:25.411Z",
"endTime": "2022-02-22T20:07:25.411Z",
"distance": {
"value": 4152.255,
"unit": "ft"
},
"fuelConsumption": {
"value": 28.89,
"unit": "US gal"
}
},
{
"id": "UUID",
"leafFileId": "UUID",
"machineId": "UUID",
"startTime": "YYYY-mm-ddThh:mm:ssZ",
"endTime": "YYYY-mm-ddThh:mm:ssZ",
"distance": {
"value": 5075.145,
"unit": "ft"
},
"fuelConsumption": {
"value": 25.55,
"unit": "US gal"
}
}
]

Create a machine

 POST /users/{leafUserId}/machines

Creates a machine for a specific LeafUser.

Request body

{
"name": "nameTest",
"serialNumber": "123456",
"vin": "1234567890ABC",
"model": "ModelName",
"make": "MakerOfMachine",
"category": "Harvester",
"modelYear": 2020
}

Request examples

curl -X POST \
-H 'Authorization: Bearer YOUR_TOKEN' \
-d '{ "name": "str"}' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/machines'

Response

{
"id": "d5efe8a1-98be-40db-b2b2-2da332e8f69c",
"name": "nameTest",
"provider": "Leaf",
"providerMachineId": "24de86ff-e6f0-4f8f-b429-0571c30a7ddf",
"providerOrganizationId": "654321",
"leafUserId": "9e081c9d-6185-49e1-8df7-7788d6aa1211",
"originType": "USER_CREATED",
"createdTime": "2023-06-12T17:38:09.148568906Z",
"createdAt": "2023-06-12T17:38:09.148568906Z",
"serialNumber": "123456",
"vin": "1234567890ABC",
"model": "ModelName",
"make": "MakerOfMachine",
"category": "Harvester",
"modelYear": 2020
}

Update a machine

 PATCH /users/{leafUserId}/machines/{machineId}

Update a machine for a specific LeafUser.

Only machines created by the user can be updated

Machine data obtained from providers cannot be updated

Request body

{
"name": "updatedName",
"serialNumber": "000123",
"vin": "1234567890EFR",
"model": "ModelNameUpdated",
"make": "MakerOfMachineUpdated",
"category": "Planted",
"modelYear": 2021
}

Request examples

curl -X PATCH \
-H 'Authorization: Bearer YOUR_TOKEN' \
-d '{ "name": "str"}' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/machines/{machineId}'

Response

{
"id": "d5efe8a1-98be-40db-b2b2-2da332e8f69c",
"name": "updatedName",
"provider": "Leaf",
"providerMachineId": "24de86ff-e6f0-4f8f-b429-0571c30a7ddf",
"providerOrganizationId": "654321",
"leafUserId": "9e081c9d-6185-49e1-8df7-7788d6aa1211",
"originType": "USER_CREATED",
"createdTime": "2023-06-12T17:38:09.148568906Z",
"createdAt": "2023-06-12T17:38:09.148568906Z",
"serialNumber": "updatedName",
"vin": "1234567890EFR",
"model": "ModelNameUpdated",
"make": "MakerOfMachineUpdated",
"category": "Planted",
"modelYear": 2021
}

Delete a machine

 DELETE /users/{leafUserId}/machines/{machineId}

Delete a machine data

Only machines created by the user can be Deleted

Machine data obtained from providers cannot be deleted

Request examples

curl -X DELETE \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/machines/{machineId}'

Get all implements

 GET /users/{leafUserId}/implements

Get all the implements information based on your leafUserId. Currently, John Deere and Trimble implements are listed.

Parameter (to filter by)Values
leafUserIduuid of one of your users
providerJohnDeere or Trimble
providerImplementIdprovider side implement id
providerOrganizationIdprovider side organization id
createdTimeISO 8601 date. Returns operations from the createdTime onward
updatedTimeISO 8601 date. Returns operations from the updatedTime onward
nameimplement name

You can also pass some parameters used exclusively for paging through results. They are:

  • page, an integer specifying the page being fetched (default is 0)
  • size, an integer specifying the size of the page (max is 100)
  • sort, the sorting order of the results; can be multi-value, where the first value to be passed will have preference in ordering over the next ones; you can also specify the order as asc or desc with asc being the default. Example: id, desc
    • Valid values for sorting are: id, leafUserId, name, provider, providerOrganizationId, providerImplementId, serialNumber, model, make, category.
the default value for page size is 20

If the parameters page and size are not set, the endpoint will return 20 results.

Request examples

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/implements'

Response

[
{
"id": "38d313fc-e4ce-442b-9147-f469b30aedab",
"name": "c3po_implement",
"provider": "JohnDeere",
"providerImplementId": "110237",
"providerOrganizationId": "296264",
"leafUserId": "mbba54fb-3710-4f7d-9aaf-703107930193",
"originType": "PROVIDER_POOLED",
"serialNumber": "00000",
"model": "StMax150",
"make": "JOHN DEERE",
"category": "Cotton Harvester Implement"
},
...
]

Get an implement

 GET /users/{leafUserId}/implements/{implementId}

Get the details of a given implement by its id.

Request examples

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/implements/{implementId}'

Response

{
"id": "38d313fc-e4ce-442b-9147-f469b30aedab",
"name": "c3po_implement",
"provider": "JohnDeere",
"providerImplementId": "110237",
"providerOrganizationId": "296264",
"leafUserId": "mbba54fb-3710-4f7d-9aaf-703107930193",
"originType": "PROVIDER_POOLED",
"serialNumber": "00000",
"model": "StMax150",
"make": "JOHN DEERE",
"category": "Cotton Harvester Implement"
}

Get all operators

 GET /users/{leafUserId}/operators

Get all the operators information based on your leafUserId. Currently, John Deere operators are listed.

You can also pass some parameters used exclusively for paging through results. They are:

  • page, an integer specifying the page being fetched (default is 0)
  • size, an integer specifying the size of the page (max is 100)
the default value for page size is 20

If the parameters page and size are not set, the endpoint will return 20 results.

Request examples

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/operators'

Response

[
{
"id": "aa8c917bc-7e9b-47bc-99b8-4a0df818ab07",
"name": "Brian O.",
"provider": "JohnDeere",
"providerOperatorId": "bbd3a3e8-5ac3-4ab8-4619-d582da4568cc",
"providerOrganizationId": "9999",
"originType": "PROVIDER_POOLED",
"license": null,
"updatedTime": "2023-10-10T10:10:10.000Z",
"status": "ACTIVE"
},
...
]

Get an operator

 GET /users/{leafUserId}/operators/{operatorId}

Get the details of a given operator by its id.

Request examples

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/operators/{operatorId}'

Response

{
"id": "aa8c917bc-7e9b-47bc-99b8-4a0df818ab07",
"name": "Brian O.",
"provider": "JohnDeere",
"providerOperatorId": "bbd3a3e8-5ac3-4ab8-4619-d582da4568cc",
"providerOrganizationId": "9999",
"originType": "PROVIDER_POOLED",
"license": null,
"updatedTime": "2023-10-10T10:10:10.000Z",
"status": "ACTIVE"
}