Developer API - Devices

  1. Device attributes
  2. List of all devices
  3. Find a specific device
  4. Grant access to a new device
  5. Update a device
  6. Delete a device

Device attributes

A device have the following attributes:

Name Type Description
id Integer Record ID
serial_number String Equipment serial number
enabled Boolean Determine wether the device can access CloudWalk (default true)
logical_number_id Integer Logical Number ID associated with the device
meta JSON Additional information such as brand, model, etc
updated_at String Timestamp in ISO 8601 format
created_at String Timestamp in ISO 8601 format
created_by Integer User ID that created the record
created_via String Channel used to create the record (Interface or API)

List of all devices

Return an array with all devices.

Method and URL format

GET https://api.cloudwalk.io/{version}/devices?access_token={token}

Example of use

$ curl -X GET "https://api.cloudwalk.io/v1/devices?access_token=$TOKEN"
require 'net/http'

token = 'API_TOKEN'

uri = URI("https://api.cloudwalk.io/v1/devices?access_token=#{token}")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri.request_uri)

res = http.request(request)

puts "Response #{res.code} #{res.message}: #{res.body}"

Example of response

{
   "pagination":{
      "page":1,
      "total_pages":1,
      "entries":2,
      "total_entries":2
   },
   "devices":[
      {
         "device":{
            "id":1,
            "serial_number":"123-456-789",
            "enabled":true,
            "updated_at":"2015-01-30T17:42:41Z",
            "created_at":"2015-01-30T17:42:41Z",
            "created_by":1,
            "created_via":"interface"
         }
      },
      {
         "device":{
            "id":2,
            "serial_number":"111-222-333",
            "enabled":true,
            "updated_at":"2015-01-30T17:47:40Z",
            "created_at":"2015-01-30T17:47:40Z",
            "created_by":1,
            "created_via":"interface"
         }
      }
   ]
}

Find a specific device

Return the details of a specific device.

Method and URL format

GET https://api.cloudwalk.io/{version}/devices/{device_id}?access_token={token}

Example of use

$ curl -X GET "https://api.cloudwalk.io/v1/devices/2?access_token=$TOKEN"
require 'net/http'

token = 'API_TOKEN'

uri = URI("https://api.cloudwalk.io/v1/devices/2?access_token=#{token}")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri.request_uri)

res = http.request(request)

puts "Response #{res.code} #{res.message}: #{res.body}"

Example of response

{
  "device":{
    "id":2,
    "serial_number":"111-222-333",
    "enabled":true,
    "updated_at":"2015-01-30T17:47:40Z",
    "created_at":"2015-01-30T17:47:40Z",
    "created_by":1,
    "created_via":"interface"
  }
}

Grant access to a new device

Grant CloudWalk access to a new device.

Method and URL format

POST https://api.cloudwalk.io/{version}/devices?access_token={token}

Example of use

$ curl -X POST "https://api.cloudwalk.io/v1/devices?access_token=$TOKEN" \
-d '{"serial_number":"444-555-666"}'
require 'net/http'
require 'json'

token = 'API_TOKEN'

payload = {
  "serial_number" => "444-555-666"
}

uri = URI("https://api.cloudwalk.io/v1/devices?access_token=#{token}")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.request_uri)
request.body = payload.to_json

res = http.request(request)

puts "Response #{res.code} #{res.message}: #{res.body}"

Example of response

{
  "device":{
    "id":3,
    "serial_number":"444-555-666",
    "enabled":true,
    "updated_at":"2015-01-30T17:55:19Z",
    "created_at":"2015-01-30T17:55:19Z",
    "created_by":1,
    "created_via":"api"
  }
}

Update a device

Update an existing device.

Method and URL format

PUT https://api.cloudwalk.io/{version}/devices/{serial_number}?access_token={token}

Example of use

$ curl -X PUT "https://api.cloudwalk.io/v1/devices/444-555-666?access_token=$TOKEN" \
-d '{"enabled":"false"}'
require 'net/http'
require 'json'

token = 'API_TOKEN'

payload = {
  "enabled" => "false"
}

uri = URI("https://api.cloudwalk.io/v1/devices/444-555-666?access_token=#{token}")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Put.new(uri.request_uri)
request.body = payload.to_json

res = http.request(request)

puts "Response #{res.code} #{res.message}: #{res.body}"

Example of response

{
  "device":{
    "id":3,
    "serial_number":"444-555-666",
    "enabled":false,
    "updated_at":"2015-01-30T17:58:59Z",
    "created_at":"2015-01-30T17:55:19Z",
    "created_by":1,
    "created_via":"api"
  }
}

Delete a device

Delete a device. The equipment with the deleted serial number will not be able to access CloudWalk.

Method and URL format

DELETE https://api.cloudwalk.io/{version}/devices/{serial_number}?access_token={token}

Example of use

$ curl -X DELETE "https://api.cloudwalk.io/v1/devices/444-555-666?access_token=$TOKEN"
require 'net/http'

token = 'API_TOKEN'

uri = URI("https://api.cloudwalk.io/v1/devices/444-555-666?access_token=#{token}")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(uri.request_uri)

res = http.request(request)

puts "Response #{res.code} #{res.message}: #{res.body}"

Example of response

{}