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.

Machines (BETA)

Machine Resources

This feature has the following endpoints available:

DescriptionEndpoints
Get all machinesGET /users/{leafUserId}/machines
Create a machinePOST /users/{leafUserId}/machines
Get a machineGET /users/{leafUserId}/machines/{machineId}
Delete a machineDELETE /users/{leafUserId}/machines/{machineId}
Update a machinePATCH /users/{leafUserId}/machines/{machineId}

Get all machines

 GET /users/{leafUserId}/machines

Get the list of machines that are related to a given LeafUserId. 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)
curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/beta/api/users/{leafUserId}/machines'

Response

The response is a JSON array contain machine records.

[
{
"id": "UUID",
"leafUserId": "UUID",
"name": "str",
"provider": "str",
"providerMachineId": "str",
"providerOrganizationId": "str"
},
{
"id": "UUID",
"leafUserId": "UUID",
"name": "str",
"provider": "str",
"providerMachineId": "str",
"providerOrganizationId": "str"
}
]

Create a machine

 POST /users/{leafUserId}/machines

Creates a machine for a specific LeafUser.

Request body

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

Response

A new machine assigned to the given LeafUserId.

{
"id": "UUID",
"leafUserId": "UUID",
"name": "str",
"provider": null,
"providerMachineId": null,
"providerOrganizationId": null
}

Get a machine

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

Get the details of a given machine by its id

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

Response

A machine record with more details

{
"id": "UUID",
"leafUserId": "UUID",
"name": "str",
"provider": null,
"providerMachineId": null,
"providerOrganizationId": null
}

Delete a machine

 DELETE /api/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

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

Update a machine

 PATCH /api/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

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