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 | Job Enqueued API Result | 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 Query Parameters
Name | Required | Description | Default | Example |
---|---|---|---|---|
tagsAsObject | N | Return tags as an object map instead of an array | tagsAsObject=true | |
attributesAsObject | N | Return attributes as an object map instead of an array | attributesAsObject=true |
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 Query Parameters
Name | Required | Description | Default | Example |
---|---|---|---|---|
tagsAsObject | N | Return tags as an object map instead of an array | tagsAsObject=false | |
attributesAsObject | N | Return attributes as an object map instead of an array | attributesAsObject=false |
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 |
Schemas
Device Recipe
Schema for a single Device Recipe
Device Recipe Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 16 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 3 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 3 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 3 keys
- ▶{} 1 key
Device Recipe Example
- ▶{} 12 keys
- "575ecec57ae143cd83dc4a9f"
- "575ecec57ae143cd83dc4a9f"
- "575ec8687ae143cd83dc4a97"
- "2016-06-13T04:00:00.000Z"
- "2016-06-13T04:00:00.000Z"
- "Actual recipe name"
- "Future device name"
- "My recipe description"
- "Future device description"
- ▶[] 1 item
- ▶[] 1 item
- "standalone"
Device Recipe Bulk Create
Schema for the result of a bulk Device creation request
Device Recipe Bulk Create Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 3 keys
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 1 key
Device Recipe Bulk Create Example
- ▶{} 3 keys
- 10
- 0
- "a,comma,separated,string,of,results"
Device Recipe Bulk Create Post
Schema for the body of a bulk Device creation request
Device Recipe Bulk Create Post Schema
- ▶{} 4 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 11 keys
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 3 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 1 key
- false
Device Recipe Bulk Create Post Example
- ▶{} 3 keys
- "myNameColumn"
- "column2"
- "a,comma,separated,string,of,input,data"
Device Recipe Patch
Schema for the body of a Device Recipe modification request
Device Recipe Patch Schema
- ▶{} 4 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 11 keys
- ▶{} 3 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 3 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 3 keys
- ▶{} 1 key
- false
Device Recipe Patch Example
- ▶{} 7 keys
- "My Updated Device Recipe"
- "Future device name"
- "Description of my updated device recipe"
- "Future device description"
- ▶[] 1 item
- ▶[] 1 item
- "standalone"
Error
Schema for errors returned by the API
Error Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 1 key
Error Example
- ▶{} 2 keys
- "NotFound"
- "Application was not found"
Job Enqueued API Result
Schema for the result of a job being queued
Job Enqueued API Result Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
Job Enqueued API Result Example
- ▶{} 3 keys
- true
- "clnHvJbyVkOWAZwYAwLP4"
- true
Success
Schema for reporting a successful operation
Success Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 1 key
- ▶{} 2 keys
Success Example
- ▶{} 1 key
- true
Was this page helpful?
Still looking for help? You can also search the Losant Forums or submit your question there.