Device Recipe Actions#

https://api.losant.com/applications/APPLICATION_ID/device-recipes/DEVICE_RECIPE_ID

Below are the various requests that can be performed against the Device Recipe resource, as well as the expected parameters and the potential responses.

Bulk Create#

Bulk creates devices using this recipe from a CSV

Method And Url #

POST https://api.losant.com/applications/APPLICATION_ID/device-recipes/DEVICE_RECIPE_ID/bulkCreate

Authentication #

A valid api access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipe.*, or deviceRecipe.bulkCreate.

Request Path Components #

Path Component Description Example
APPLICATION_ID ID associated with the application 575ec8687ae143cd83dc4a97
DEVICE_RECIPE_ID ID associated with the device recipe 575ecec57ae143cd83dc4a9f

Request Headers #

Name Required Description Default
Authorization Y The token for authenticating the request, prepended with Bearer

Request Body #

The body of the request should be serialized JSON that validates against the Device Recipe Bulk Create Post schema. For example, the following would be a valid body for this request:

{
  "nameColumn": "myNameColumn",
  "descriptionColumn": "column2",
  "csv": "a,comma,separated,string,of,input,data"
}

Curl Example #

curl -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
    -X POST \
    -d '{"nameColumn":"myNameColumn","descriptionColumn":"column2","csv":"a,comma,separated,string,of,input,data"}' \
    https://api.losant.com/applications/APPLICATION_ID/device-recipes/DEVICE_RECIPE_ID/bulkCreate

Successful Responses #

Code Type Description
201 Device Recipe Bulk Create If devices were successfully created
202 Device Recipe Bulk Create Enqueue If devices were enqueued to be created

Error Responses #

Code Type Description
400 Error Error if malformed request
404 Error Error if device recipe was not found

Delete#

Deletes a device recipe

Method And Url #

DELETE https://api.losant.com/applications/APPLICATION_ID/device-recipes/DEVICE_RECIPE_ID

Authentication #

A valid api access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipe.*, or deviceRecipe.delete.

Request Path Components #

Path Component Description Example
APPLICATION_ID ID associated with the application 575ec8687ae143cd83dc4a97
DEVICE_RECIPE_ID ID associated with the device recipe 575ecec57ae143cd83dc4a9f

Request Headers #

Name Required Description Default
Authorization Y The token for authenticating the request, prepended with Bearer

Curl Example #

curl -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
    -X DELETE \
    https://api.losant.com/applications/APPLICATION_ID/device-recipes/DEVICE_RECIPE_ID

Successful Responses #

Code Type Description
200 Success If device recipe was successfully deleted

Error Responses #

Code Type Description
400 Error Error if malformed request
404 Error Error if device recipe was not found

Get#

Retrieves information on a device recipe

Method And Url #

GET https://api.losant.com/applications/APPLICATION_ID/device-recipes/DEVICE_RECIPE_ID

Authentication #

A valid api access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, deviceRecipe.*, or deviceRecipe.get.

Request Path Components #

Path Component Description Example
APPLICATION_ID ID associated with the application 575ec8687ae143cd83dc4a97
DEVICE_RECIPE_ID ID associated with the device recipe 575ecec57ae143cd83dc4a9f

Request Headers #

Name Required Description Default
Authorization Y The token for authenticating the request, prepended with Bearer

Curl Example #

curl -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
    -X GET \
    https://api.losant.com/applications/APPLICATION_ID/device-recipes/DEVICE_RECIPE_ID

Successful Responses #

Code Type Description
200 Device Recipe Device recipe information

Error Responses #

Code Type Description
400 Error Error if malformed request
404 Error Error if device recipe was not found

Patch#

Updates information about a device recipe

Method And Url #

PATCH https://api.losant.com/applications/APPLICATION_ID/device-recipes/DEVICE_RECIPE_ID

Authentication #

A valid api access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipe.*, or deviceRecipe.patch.

Request Path Components #

Path Component Description Example
APPLICATION_ID ID associated with the application 575ec8687ae143cd83dc4a97
DEVICE_RECIPE_ID ID associated with the device recipe 575ecec57ae143cd83dc4a9f

Request Headers #

Name Required Description Default
Authorization Y The token for authenticating the request, prepended with Bearer

Request Body #

The body of the request should be serialized JSON that validates against the Device Recipe Patch schema. For example, the following would be a valid body for this request:

{
  "name": "My Updated Device Recipe",
  "deviceName": "Future device name",
  "description": "Description of my updated device recipe",
  "deviceDescription": "Future device description",
  "tags": [
    {
      "key": "TagKey",
      "value": "TagValue"
    }
  ],
  "attributes": [
    {
      "name": "voltage",
      "dataType": "number"
    }
  ],
  "deviceClass": "standalone"
}

Curl Example #

curl -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
    -X PATCH \
    -d '{"name":"My Updated Device Recipe","deviceName":"Future device name","description":"Description of my updated device recipe","deviceDescription":"Future device description","tags":[{"key":"TagKey","value":"TagValue"}],"attributes":[{"name":"voltage","dataType":"number"}],"deviceClass":"standalone"}' \
    https://api.losant.com/applications/APPLICATION_ID/device-recipes/DEVICE_RECIPE_ID

Successful Responses #

Code Type Description
200 Device Recipe Updated device recipe information

Error Responses #

Code Type Description
400 Error Error if malformed request
404 Error Error if device recipe was not found