Skip to main content

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 ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_RECIPE_IDID associated with the device recipe575ecec57ae143cd83dc4a9f

Request Headers

NameRequiredDescriptionDefault
AuthorizationYThe 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

CodeTypeDescription
201Device Recipe Bulk CreateIf devices were successfully created
202Job Enqueued API ResultIf devices were enqueued to be created

Error Responses

CodeTypeDescription
400ErrorError if malformed request
404ErrorError 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 ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_RECIPE_IDID associated with the device recipe575ecec57ae143cd83dc4a9f

Request Headers

NameRequiredDescriptionDefault
AuthorizationYThe 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

CodeTypeDescription
200SuccessIf device recipe was successfully deleted

Error Responses

CodeTypeDescription
400ErrorError if malformed request
404ErrorError 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 ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_RECIPE_IDID associated with the device recipe575ecec57ae143cd83dc4a9f

Request Query Parameters

NameRequiredDescriptionDefaultExample
tagsAsObjectNReturn tags as an object map instead of an arraytagsAsObject=true
attributesAsObjectNReturn attributes as an object map instead of an arrayattributesAsObject=true

Request Headers

NameRequiredDescriptionDefault
AuthorizationYThe 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

CodeTypeDescription
200Device RecipeDevice recipe information

Error Responses

CodeTypeDescription
400ErrorError if malformed request
404ErrorError 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 ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_RECIPE_IDID associated with the device recipe575ecec57ae143cd83dc4a9f

Request Query Parameters

NameRequiredDescriptionDefaultExample
tagsAsObjectNReturn tags as an object map instead of an arraytagsAsObject=false
attributesAsObjectNReturn attributes as an object map instead of an arrayattributesAsObject=false

Request Headers

NameRequiredDescriptionDefault
AuthorizationYThe 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

CodeTypeDescription
200Device RecipeUpdated device recipe information

Error Responses

CodeTypeDescription
400ErrorError if malformed request
404ErrorError 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.