NAV
Ruby Python Node.js Perl PHP C# Java cURL

Introduction

This document describes the Pulseway REST API v3 usage.

The REST API accepts JSON as input. The output matches the Accept header and defaults to JSON if the Accept header is not present.

We use built-in HTTP features, like HTTP authentication and HTTP verbs, which can be understood by off-the-shelf HTTP clients.

Authentication

BASIC Authentication

class PublishResource < ActiveResource::Base
    self.site = ENDPOINT
    self.username = TOKEN_ID
    self.password = TOKEN_SECRET
    self.timeout = 30
    self.include_format_in_path = false 
end
requests.post(ENDPOINT + 'publish', publish, auth=(TOKEN_ID, TOKEN_SECRET), headers={"content-type":"application/json"})
var Client = require('node-rest-client').Client;
var options_auth = {user: TOKEN_ID, password: TOKEN_SECRET};
var client = new Client(options_auth);
my $client = HTTP::Request->new( 'GET', $url);
$client->authorization_basic("$token_id", "$token_secret");
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);
using (var client = new HttpClient())
{
    client.BaseAddress = new Uri(ENDPOINT);
    const string auth = TOKEN_ID + ":" + TOKEN_SECRET;
    byte[] authBytes = Encoding.ASCII.GetBytes(auth);
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(authBytes));
}
HttpPost post = new HttpPost(ENDPOINT + "publish");
String auth = Base64.encodeBase64String((TOKEN_ID + ":" + TOKEN_SECRET).getBytes());
post.setHeader("Authorization", "Basic " + auth);
curl https://api.pulseway.com/v3/systems \
     -u TOKEN_ID:TOKEN_SECRET
# If you host your own Pulseway Enterprise Server, use:
# curl https://<server_name>/api/v3/systems \

Make sure to replace TOKEN_ID and TOKEN_SECRET with your own credentials.

Pulseway REST API uses Basic Authentication for all requests. All requests must be via HTTPS otherwise the request will fail.

Basic Authentication requires an Authorization header with the Pulseway Token ID and Token Secret in the TOKEN_ID:TOKEN_SECRET format encoded as Base64.

Devices

Publish

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

INSTANCE_ID    = "production_website_1"
INSTANCE_NAME  = "Production Web Site"
INSTANCE_GROUP = "Web Sites"

class Device < ActiveRestClient::Base
    request_body_type :json

    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET' 

    post :publish, "/devices"
end

begin   
    puts "Publish..."   

    @result = Device.publish(
        "InstanceId": "production_website_1",
        "Name": "Production Web Site",
        "GroupId": 123,
        "Description": "Running on ip.91.71.60.196.us-west-2.compute.internal",
        "Contents": [
            {
                "Name": "Status",
                "Contents": [
                    {
                        "Icon": "error",
                        "Type": "label",
                        "Title": "Could not connect to the database.",
                        "Subtitle": "Database Connection"
                    },
                    {
                        "Icon": "information",
                        "Type": "label",
                        "Title": "5 hours, 39 minutes",
                        "Subtitle": "Uptime"
                    }
                ]
            },
            {
                "Name": "Commands",
                "Contents": [
                    {
                        "CallbackUrl": "https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config",
                        "Type": "webhook_command",
                        "Title": "Reload Configuration",
                        "Subtitle": "Reads configuration from file"
                    }
                ]
            }
        ],          
        "NextRefreshIntervalMinutes": 5,
        "NotifyWhenOffline": "false"
    )

    puts @result.Meta['ResponseCode']

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    result = api.devices.post(
    {
        "InstanceId": "production_website_1",
        "Name": "Production Web Site",
        "GroupId": 123,
        "Description": "Running on ip.91.71.60.196.us-west-2.compute.internal",
        "Contents": [
            {
                "Name": "Status",
                "Contents": [
                    {
                        "Icon": "error",
                        "Type": "label",
                        "Title": "Could not connect to the database.",
                        "Subtitle": "Database Connection"
                    },
                    {
                        "Icon": "information",
                        "Type": "label",
                        "Title": "5 hours, 39 minutes",
                        "Subtitle": "Uptime"
                    }
                ]
            },
            {
                "Name": "Commands",
                "Contents": [
                    {
                        "CallbackUrl": "https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config",
                        "Type": "webhook_command",
                        "Title": "Reload Configuration",
                        "Subtitle": "Reads configuration from file"
                    }
                ]
            }
        ],
        "NextRefreshIntervalMinutes": 5,
        "NotifyWhenOffline": "false"
    });

    print (result)

except Exception as e:
    print('Publish raised an exception.')
    print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";
var instance_id    = "production_website_1";
var instance_name  = "Production Web Site";
var instance_group_id = 123;

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    data: {
        "InstanceId": instance_id,
        "Name": instance_name,
        "GroupId": instance_group_id,
        "Description": "Running on ip.91.71.60.196.us-west-2.compute.internal",
        "Contents": [
        {
            "Name": "Status",
            "Contents": [
            {
                "Icon": "error",
                "Type": "label",
                "Title": "Could not connect to the database.",
                "Subtitle": "Database Connection"
            },
            {
                "Icon": "information",
                "Type": "label",
                "Title": "5 hours, 39 minutes",
                "Subtitle": "Uptime"
            }
            ]
        },
        {
            "Name": "Commands",
            "Contents": [
            {
                "CallbackUrl": "https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config",
                "Type": "webhook_command",
                "Title": "Reload Configuration",
                "Subtitle": "Reads configuration from file"
            }]
        }],
        "NextRefreshIntervalMinutes": 5,
        "NotifyWhenOffline": "false"
    },
    headers: {"Content-Type": "application/json"}
}

client.registerMethod("publish", endpoint + "devices", "POST");

client.methods.publish(args, function (data, response) {    
    console.log(data);  
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON -support_by_pp;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'devices';

my $uri = URI->new($endpoint.$query_object);

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $instance_id = "production_website_1";
my $instance_name = "Production Web Site";
my $instance_group = 123;

my $publish = {
    'InstanceId' => $instance_id,
    'Name' => $instance_name,
    'GroupId' => $instance_group,
    'Description' => "Running on ip.91.71.60.196.us-west-2.compute.internal",
    'Contents' => [
    {
        'Name' => "Status",
        'Contents' => 
        [
            {
                'Icon' => "error",
                'Type' => "label",
                'Title' => "Could not connect to the database.",
                'Subtitle' => "Database Connection"
            },
            {
                'Icon' => "information",
                'Type' => "label",
                'Title'=> "5 hours, 39 minutes",
                'Subtitle' => "Uptime"
            }
        ]
    },
    {
        'Name' => "Commands",
        'Contents' =>
        [
            {
                'CallbackUrl' => "https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config",
                'Type' => "webhook_command",
                'Title' => "Reload Configuration",
                'Subtitle' => "Reads configuration from file"
            }
        ]
    }],
    'NextRefreshIntervalMinutes' => "5",
    'NotifyWhenOffline' => "false"
};  

my $json = new JSON;
my $data = $json->allow_nonref->pretty->utf8->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->encode($publish);

my $client = HTTP::Request->new( 'POST', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");
$client->content($data);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}
<?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";
const INSTANCE_ID    = "rest";
const INSTANCE_NAME  = "Production Web Site";
const INSTANCE_GROUP = 123;

$options = array(
    'object' => 'Devices'       
);

$publishRequest = array(
    "InstanceId" => INSTANCE_ID,
    "Name" => INSTANCE_NAME,
    "GroupId" => INSTANCE_GROUP,
    "Description" => "Running on ip.91.71.60.196.us-west-2.compute.internal",
    "Contents" => array(
        array(
            "Name" => "Status",
            "Contents" => array(
                array(
                    "Icon" => "error",
                    "Type" => "label",
                    "Title" => "Could not connect to the database.",
                    "Subtitle" => "Database Connection"
                ),
                array(
                    "Icon" => "information",
                    "Type" => "label",
                    "Title" => "5 hours, 39 minutes",
                    "Subtitle" => "Uptime"
                )
            )
        ),
        array(
            "Name" => "Commands",
            "Contents" => array(
                array(
                    "CallbackUrl" => "https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config",
                    "Type" => "webhook_command",
                    "Title" => "Reload Configuration",
                    "Subtitle" => "Reads configuration from file"
                )
            )
        )
    ),
    "NextRefreshIntervalMinutes" => 5,
    "NotifyWhenOffline" => "false"
);

function request($opt, $data) {
    $request = curl_init();
    $data_string = json_encode($data);
    $headers = array(
        'Content-Type: application/json',
        'Content-Length: '.strlen($data_string)
    );

    $url = ENDPOINT . $opt['object'];

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($request, CURLOPT_POST, TRUE);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Publish</p>";
    $publishResponse = request($options, $publishRequest);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Publish' exception: ", $e->getMessage(), "</p></br></br>";
}
?> 
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class Publish
    {
        private const string Endpoint = "https://api.pulseway.com/v3/";
        private const string TokenId = "TOKEN_ID";
        private const string TokenSecret = "TOKEN_SECRET";
        private const string InstanceId = "production_website_1";
        private const string InstanceName = "Production Web Site";
        private const int InstanceGroupId = 123;

        static void Main(string[] args)
        {
            var client = new RestClient(Endpoint);
            client.Authenticator = new HttpBasicAuthenticator(TokenId, TokenSecret);

            var request = new RestRequest("Devices", Method.POST);            
            request.RequestFormat = DataFormat.Json;
            request.AddBody(GetPublishRequest());

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }

        private static PublishRequest GetPublishRequest()
        {
            PublishRequest publishRequest = new PublishRequest();
            publishRequest.InstanceId = InstanceId;
            publishRequest.Name = InstanceName;
            publishRequest.Group = InstanceGroupId;
            publishRequest.Description = "Running on ip.91.71.60.196.us-west-2.compute.internal";
            publishRequest.Groups = new Group[2];
            publishRequest.NextRefreshIntervalMinutes = 5;
            publishRequest.NotifyWhenOffline = false;

            // Status Group
            Group status = new Group();
            status.Name = "Status";
            Item label1 = new Item
            {
                Icon = "error",
                Title = "Cannot connect to the database.",
                Subtitle = "Database Connection",
                Type = "label"
            };
            Item label2 = new Item
            {
                Icon = "information",
                Title = "5 hours, 39 minutes",
                Subtitle = "Uptime",
                Type = "label"
            };
            status.Contents = new[] { label1, label2 };
            // Commands Group
            Group commands = new Group();
            commands.Name = "Commands";
            Item webhook1 = new Item();
            webhook1.CallbackUrl = "https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config";
            webhook1.Title = "Reload Configuration";
            webhook1.Subtitle = "Reads configuration from file";
            webhook1.Type = "webhook_command";
            commands.Contents = new[] { webhook1 };

            publishRequest.Groups = new[] { status, commands };
            return publishRequest;
        }

        public class PublishRequest
        {
            public string InstanceId { get; set; }
            public string Name { get; set; }
            public int GroupId { get; set; }
            public string Description { get; set; }
            public Group[] Groups { get; set; }
            public int? NextRefreshIntervalMinutes { get; set; }
            public bool NotifyWhenOffline { get; set; }
        }
        public class Group
        {
            public string Name { get; set; }
            public Item[] Contents { get; set; }
        }
        public class Item
        {            
            public string Icon { get; set; }            
            public string Type { get; set; }
            public string Title { get; set; }
            public string Subtitle { get; set; }            
            public string CallbackUrl { get; set; }
        }       
    }
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class Publish 
{ 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final String INSTANCE_ID = "production_website_1";
    private static final String INSTANCE_NAME = "Production Web Site";
    private static final int INSTANCE_GROUP = 123;

    private static PublishRequest getPublishRequest()
    {     
        PublishRequest request = new PublishRequest();

        request.setInstanceId(INSTANCE_ID);
        request.setName(INSTANCE_NAME);
        request.setGroup(INSTANCE_GROUP);
        request.setDescription("Running on ip.91.71.60.196.us-west-2.compute.internal");
        request.setNextRefreshIntervalMinutes(5);
        request.setNotifyWhenOffline(false);

        // Status Group
        Group status = new Group();
        status.setName("Status");      
        Item label1 = new Item();
        label1.setIcon("error");
        label1.setTitle("Cannot connect to the database");
        label1.setSubtitle("Database Connection");
        label1.setType("label");      
        Item label2 = new Item();
        label2.setIcon("information");
        label2.setTitle("5 hours, 39 minutes");
        label2.setSubtitle("Uptime");
        label2.setType("label");
        status.setContents(new Item[]{label1, label2});

        // Commands Group
        Group commands = new Group();
        commands.setName("Commands");
        Item webhook1 = new Item();
        webhook1.setCallbackUrl("https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config");
        webhook1.setTitle("Reload Configuration");
        webhook1.setSubtitle("Reads configuration from file.");
        webhook1.setType("webhook_command");
        commands.setContents(new Item[]{webhook1});

        request.setContents(new Group[]{status, commands});

        return request;
    }

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/devices");             
            URI uri = builder.build();

            HttpPost request = new HttpPost(uri);         
            request.setHeader("Content-Type", "application/json");

            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            Gson gson = new Gson();

            PublishRequest publishRequest = getPublishRequest();
            StringEntity publishJson = new StringEntity(gson.toJson(publishRequest));

            request.setEntity(publishJson);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Meta.ResponseCode);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  
    public static class Response
    {     
        public Meta Meta;           

        public Response() {}      
    }   
    public static class Meta
    {
        public String ResponseCode;
        public String ErrorMessage;               

        public Meta() {}      
    } 
    public static class PublishRequest
    {
        public String InstanceId;
        public String Name;
        public int GroupId;
        public String Description;
        public Group[] Contents;
        public int NextRefreshIntervalMinutes;
        public boolean NotifyWhenOffline;

        public PublishRequest() {} 

        public void setInstanceId(String instanceId)
        {
            this.InstanceId = instanceId;
        }
        public void setName(String name)
        {
            this.Name = name;
        }
        public void setGroup(int groupId)
        {
            this.GroupId = groupId;
        }
        public void setDescription(String description)
        {
            this.Description = description;
        }
        public void setContents(Group[] contents)
        {
            this.Contents = contents;
        }
        public void setNextRefreshIntervalMinutes(int nextRefreshIntervalMinutes)
        {
            this.NextRefreshIntervalMinutes = nextRefreshIntervalMinutes;
        }
        public void setNotifyWhenOffline(boolean notifyWhenOffline)
        {
            this.NotifyWhenOffline = notifyWhenOffline;
        }
    }
    public static class Group
    {
        public String Name;
        public Item[] Contents;

        public Group() {} 

        public void setName(String name)
        {
            this.Name = name;
        }
        public void setContents(Item[] contents)
        {
            this.Contents = contents;
        }
    }

    public static class Item
    {
        public String Icon;
        public String Type;
        public String Title;
        public String Subtitle;
        public String CallbackUrl;

        public Item() {} 

        public void setIcon(String icon)
        {
            this.Icon = icon;
        }
        public void setType(String type)
        {
            this.Type = type;
        }
        public void setTitle(String title)
        {
            this.Title = title;
        }
        public void setSubtitle(String subtitle)
        {
            this.Subtitle = subtitle;
        }
        public void setCallbackUrl(String callbackUrl)
        {
            this.CallbackUrl = callbackUrl;
        }
    }
}   
curl https://api.pulseway.com/v3/devices \
     -u TOKEN_ID:TOKEN_SECRET \
     -X POST \
     -H "Content-Type: application/json" \
     -d '{"InstanceId":"production_website_1","Name":"Production Web Site","GroupId": 123,"Description":"Running on ip.91.71.60.196.us-west-2.compute.internal","Contents":[{"Name":"Status","Contents":[{"Icon":"error","Type":"label","Title":"Could not connect to the database.","Subtitle":"Database Connection"},{"Icon":"information","Type":"label","Title":"5 hours, 39 minutes","Subtitle":"Uptime"}]},{"Name":"Commands","Contents":[{"CallbackUrl":"https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config","Type":"webhook_command","Title":"Reload Configuration","Subtitle":"Reads configuration from file"}]}],"NextRefreshIntervalMinutes":5,"NotifyWhenOffline":"false"}'

The above command returns JSON structured like this:

{
    "Data": {
        "Identifier": "11111111-2222-3333-4444-555555555555"
    },
    "Meta": {
        "ResponseCode": 200
    }
}   

Publish registers or updates a Pulseway Device instance.

HTTP Request

https://api.pulseway.com/v3/Devices

HTTP Verb

POST

Fields

Name Value Required Description
InstanceId string yes Unique instance identifier. (maximum 100 characters)
Name string no Name of the instance. (maximum 100 characters)
GroupId int yes Group ID of the instance.
Description string no Instance description. Shows under the instance name. (maximum 255 characters)
Contents array no Data used to create the details view. See Group.
NextRefreshIntervalMinutes int no Marks the instance as offline if the Publish method is not called again after the specified interval. Zero disables the offline counter.
NotifyWhenOffline string no If the next refresh interval was specified, a notification will be sent if the instance goes offline for an extended period of time.

Group

Name Value Required Description
Name string yes Name of the group.
Contents array no An array of items of type Label or Web Hook Commands that are part of the group. See Label and Web Hook Command.

Label

Name Value Required Description
Type string yes Type of the object. Must be set to label.
Title string yes Title of the label. Appears on the first line of the label.
Subtitle string no Subtitle of the label. Appears on the second line of the label.
Icon string no Appears to the left of the text. Possible values: information, warning and error.

Web Hook Command

Name Value Required Description
Type string yes Type of the object. Must be set to webhook_command.
CallbackUrl string yes Url that gets invoked when the command triggers.
Title string yes Title of the command. Appears on the first line of the button.
Subtitle string no Subtitle of the command. Appears on the second line of the button.

Get All Devices

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Device < ActiveRestClient::Base
  # use $top & $skip parameters  
  before_request do |name, request|
    request.get_params[:$top] = "50"
    request.get_params[:$skip] = "0"
  end

  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'   

  get :all, "/devices"
end

begin   
    puts "Get Devices..."       
    @result = Device.all
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    # use $top & $skip parameters
    result = api.devices.get($top='50', $skip='0')
    print (result)

except Exception as e:
    print('GetDevices raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    // use $top & $skip parameters
    parameters: { $top: "50", $skip: "0" }
}

client.registerMethod("getDevices", endpoint + "devices", "GET");

client.methods.getDevices(args, function (data, response) { 
    console.log(data);  
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'devices';

my $uri = URI->new($endpoint.$query_object);
# use $top & $skip parameters
$uri->query_form('$top'  => '50', '$skip' => '0');

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}
 <?php

const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'devices'       
);

// use $top & $skip parameters
const params = array (
    '$top' => '50',
    '$skip' => '0'
);

function request($opt, $params) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];

    $parameters = '';
    if (isset($params['$top']) || isset($params['$skip']))
        foreach($params as $key=>$value)
            $parameters .= $key.'='.$value.'&';

    $parameters = trim($parameters, '&');

    curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Devices</p>";
    $publishResponse = request(options, params);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Devices' exception: ", $e.getMessage(), "</p></br></br>";
}
?> 
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;
using System;

namespace ConsoleApplication
{
    class GetDevices
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("devices", Method.GET);

            request.AddParameter("$top", "50");
            request.AddParameter("$skip", "0");

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);            
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetDevices {
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/devices")
                .setParameter("$top", "50")
                .setParameter("$skip", "0");
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data[0].Identifier);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }    
    public class Response
    {
        public Device[] Data;
        public Meta Meta;                          
    }    
    public class Device
    {
        public String Identifier;
        public String Name;
        public String GroupName;
        public int GroupId;
        public bool IsAgentInstalled;
        public bool IsMdmEnrolled;
        public long SiteId;
        public String SiteName;
        public long OrganizationId;
        public String OrganizationName;
        public bool HasCustomFields;
    }    
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;      
    }  
}
curl https://https://api.pulseway.com/v3/devices \
     -u TOKEN_ID:TOKEN_SECRET 

# If you want to use $top & $skip parameters, append
# "?&$top=50&$skip=0" to the url

The above command returns JSON structured like this:

{
    "Data": [
        {
            "Identifier": "11111111-2222-3333-9B2F-016B8D621AB5",
            "Name": "Computer1",
            "GroupId": 123,
            "GroupName": "Group1",
            "IsAgentInstalled": false,
            "IsMdmEnrolled": false,
            "SiteId": 123,
            "SiteName": "Site1",
            "OrganizationId": 123,
            "OrganizationName": "Organization1",
            "HasCustomFields": false
        },
        {
            "Identifier": "66666666-7777-8888-9B2F-016B8D621AB5",
            "Name": "Computer2",
            "GroupId": 123,
            "GroupName": "Group1",
            "IsAgentInstalled": false,
            "IsMdmEnrolled": false,
            "SiteId": 123,
            "SiteName": "Site1",
            "OrganizationId": 123,
            "OrganizationName": "Organization1",
            "HasCustomFields": false
        }
    ],
    "Meta": {
        "ResponseCode": 200,
        "TotalCount": 2
    }   
}

Returns a list of devices.

HTTP Request

https://api.pulseway.com/v3/devices

HTTP Verb

GET

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: Identifier, Name, GroupId, GroupName, IsAgentInstalled, IsMdmEnrolled, SiteId, SiteName, OrganizationId, OrganizationName. $filter=contains(tolower(GroupName), 'mygroup')
$orderby string no OData sorting. Sortable properties: Identifier, Name, GroupId, GroupName, IsAgentInstalled, IsMdmEnrolled, SiteId, SiteName, OrganizationId, OrganizationName. $orderby=GroupId desc

Get a Specific Device

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Device < ActiveRestClient::Base
    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET'     

    get :find, "/devices/:id"
end

begin   
    puts "Get Device..."        
    @result = Device.find('11111111-2222-3333-4444-555555555555')
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    # result = api.devices.get();
    result = api.devices("11111111-2222-3333-4444-555555555555").get()
    print (result)

except Exception as e:
    print('GetDevice raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": '11111111-2222-3333-4444-555555555555' },
}

client.registerMethod("getDevice", endpoint + "devices/${id}", "GET");

client.methods.getDevices(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = "11111111-2222-3333-4444-555555555555";

my $client = HTTP::Request->new( 'GET', $endpoint .'devices'.'/'.$id);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
    'object' => 'devices',
    'id' => '11111111-2222-3333-4444-555555555555'
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id']))
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Device</p>";
    $publishResponse = request(options);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Device' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetDevice
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("devices/{id}", Method.GET);
            request.AddUrlSegment("id", "11111111-2222-3333-4444-555555555555"); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetDevice { 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final String ID = "11111111-2222-3333-4444-555555555555";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/devices/"+ ID);            
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.Description);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public DeviceDetails Data;
        public Meta Meta;                          
    }    
    public class DeviceDetails
    {
        public String Identifier;
        public String Name;
        public String GroupName;
        public int GroupId;
        public String Description;
        public String ExternalIpAddress;
        public String Uptime;
        public boolean IsOnline;
        public String ComputerType;
        public String ClientVersion;
        public boolean InMaintenance;
        public int CriticalNotifications;
        public int ElevatedNotifications;
        public int NormalNotifications;
        public int LowNotifications;
        public bool IsAgentInstalled;
        public bool IsMdmEnrolled;
        public long SiteId;
        public String SiteName;
        public long OrganizationId;
        public String OrganizationName;
        public bool HasCustomFields;
    }    
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;      
    }  
}  
curl https://api.pulseway.com/v3/devices/11111111-2222-3333-4444-555555555555 \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
    "Data": {
        "Description":"Windows 10 Enterprise",
        "Uptime":"Offline since 63 days ago",
        "IsOnline":false,
        "ComputerType":"windows",
        "InMaintenance":false,
        "ExternalIpAddress":"1.2.3.4",
        "CriticalNotifications":0,
        "ElevatedNotifications":0,
        "NormalNotifications":0,
        "LowNotifications":0,
        "ClientVersion":"4.8.5",
        "Identifier":"28440dda-f385-4ec8-a5c3-d1e6074113bb",
        "Name":"MyPC",
        "GroupName":"Home",
        "GroupId":123,
        "IsAgentInstalled": false,
        "IsMdmEnrolled": false,
        "SiteId": 123,
        "SiteName": "Site1",
        "OrganizationId": 123,
        "OrganizationName": "Organization1",
        "HasCustomFields": false
    },
    "Meta": {
        "ResponseCode":200
    }
}   

Returns the device details.

HTTP Request

https://api.pulseway.com/v3/devices/:id

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the device identifier.

Get Device Notifications

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Device < ActiveRestClient::Base
    # use $top & $skip parameters    
    before_request do |name, request|
        request.get_params[:$top] = "50"
        request.get_params[:$skip] = "0"
    end

    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET' 

  get :notifications, "/devices/:id/notifications" 
end

begin   
    puts "Get Device Notifications..."      
    @result = Device.notifications('11111111-2222-3333-4444-555555555555')
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    # result = api.devices.get();
    result = api.devices("11111111-2222-3333-4444-555555555555").notifications.get()
    print (result)

except Exception as e:
    print('GetDeviceNotifications raised an exception.')
    print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": '11111111-2222-3333-4444-555555555555' },
}

client.registerMethod("getDeviceNotifications", endpoint + "devices/${id}/notifications", "GET");

client.methods.getDeviceNotifications(args, function (data, response) { 
    console.log(data);  
});   
##!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
$endpoint->query_form('$top'  => '50', '$skip' => '0');
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = "11111111-2222-3333-4444-555555555555";

my $uri = URI->new('devices/'.$id.'/notifications')->abs($endpoint);

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
 <?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'devices',
    'id' => '11111111-2222-3333-4444-555555555555'
);

// use $top & $skip parameters
const params = array (
    '$top' => '50',
    '$skip' => '0'
);

function request($opt, $params) {
    $request = curl_init();
    $headers = array(
    'Content-Type: application/json'        
);

$url = ENDPOINT . $opt['object'];
if (isset($opt['id']))
    $url = ENDPOINT . $opt['object'] . '/' . $opt["id"].'/'.'notifications';

    $parameters = '';
    if (isset($params['$top']) || isset($params['$skip']))
    foreach($params as $key=>$value)
        $parameters .= $key.'='.$value.'&';

    $parameters = trim($parameters, '&');

    curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Device Notifications</p>";
    $publishResponse = request(options, params);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Device Notifications' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetDeviceNotifications
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("devices/{id}/notifications", Method.GET);
            request.AddUrlSegment("id", "11111111-2222-3333-4444-555555555555"); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetDeviceNotifications {
    private static final String ENDPOINT = "api.pulseway.com/v3/";  
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final String ID = "11111111-2222-3333-4444-555555555555";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/devices/"+ ID + "/notifications")
                .setParameter("$top", "50")
                .setParameter("$skip", "0");              
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();

            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.length);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public Notification[] Data;
        public Meta Meta;                          
    }    
    public class Notification
    {
        public int Id;
        public String Message;
        public int DateTime;
        public String Priority;      
    }    
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;      
    }  
}  
curl https://https://api.pulseway.com/v3/devices/11111111-2222-3333-4444-555555555555/notifications \
     -u TOKEN_ID:TOKEN_SECRET 

# If you want to use $top & $skip parameters, append
# "?&$top=50&$skip=0" to the url

The above command returns JSON structured like this:

{
    "Data": [
        {
            "Id":2733,
            "Message":"Production Web Site Instance in group Web Sites cannot connect to the database.",
            "DateTime":1463388894,
            "Priority":"critical"
        },
        {
            "Id":2732,
            "Message":"Production Web Site Instance in group Web Sites cannot connect to the database.",
            "DateTime":1463388888,
            "Priority":"critical"
        }
    ],
    "Meta": {
        "ResponseCode": 200,
        "TotalCount": 2
    }
}   

Return the device notifications.

HTTP Request

https://api.pulseway.com/v3/devices/:id/notifications

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the device identifier.

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: Id, Message, DateTime, Priority. $filter=contains(tolower(Message), 'free space')
$orderby string no OData sorting. Sortable properties: Id, Message, DateTime, Priority. $orderby=Priority

Get Antivirus Status

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Device < ActiveRestClient::Base
    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET'     

    get :get_antivirus_status, "/devices/:id/antivirus"
end

begin   
    puts "Get Antivirus Status..."      
    @result = Device.get_antivirus_status('11111111-2222-3333-4444-555555555555')
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    result = api.devices("11111111-2222-3333-4444-555555555555").antivirus().get()
    print (result)

except Exception as e:
    print('GetAntivirusStatus raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": '11111111-2222-3333-4444-555555555555' },
}

client.registerMethod("getAntivirusStatus", endpoint + "devices/${id}/antivirus", "GET");

client.methods.getAntivirusStatus(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = "11111111-2222-3333-4444-555555555555";

my $client = HTTP::Request->new( 'GET', $endpoint .'devices'.'/'.$id.'/'.'antivirus');

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
    'object' => 'devices',
    'id' => '11111111-2222-3333-4444-555555555555',
    'antivirus' => 'antivirus',
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id'])) {
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];
        if (isset($opt['antivirus'])) {
            $url = ENDPOINT . $opt['object'] . '/' . $opt["id"] . '/' . $opt["antivirus"];
        }
    }

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Antivirus Status</p>";
    $publishResponse = request(options);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Antivirus Status' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetAntivirusStatus
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("devices/{id}/antivirus", Method.GET);
            request.AddUrlSegment("id", "11111111-2222-3333-4444-555555555555"); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetDeviceAntivirusStatus { 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final String DEVICE_ID = "11111111-2222-3333-4444-555555555555";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/Devices/"+ DEVICE_ID + "/Antivirus");              
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.ProtectionStatus);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public DeviceAntivirusStatus Data;
        public Meta Meta;                          
    }    
    public class DeviceAntivirusStatus
    {
        public String ProtectionStatus;
        public String DefinitionsStatus;
        public String ScanStatus;
        public String[] AgentStatus;
        public String Policy;
    }    
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;      
    }  
}  
curl https://api.pulseway.com/v3/Devices/11111111-2222-3333-4444-555555555555/Antivirus \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
    "Data": {
        "ProtectionStatus": "active",
        "DefinitionsStatus": "up_to_date",
        "ScanStatus": "scanning",
        "UpdateStatus": "updating",
        "AgentStatus": [
            "installed",
            "scanning",
            "updating"
        ],
        "Policy": "Production Servers"
    },
    "Meta": {
        "ResponseCode": 200
    }
}

Returns the antivirus status of a device.

HTTP Request

https://api.pulseway.com/v3/Devices/:deviceId/Antivirus

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
deviceId string yes The ID of the device.

Get Device Custom Fields

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Device < ActiveRestClient::Base
    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET'     

    get :custom_fields, "/devices/:id/customfields"
end

begin   
    puts "Get Device..."        
    @result = Device.custom_fields('11111111-2222-3333-4444-555555555555')
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    # result = api.devices.get();
    result = api.devices("11111111-2222-3333-4444-555555555555").customfields.get()
    print (result)

except Exception as e:
    print('GetDevice raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": '11111111-2222-3333-4444-555555555555' },
}

client.registerMethod("getDeviceCustomFields", endpoint + "devices/${id}/customfields", "GET");

client.methods.getDeviceCustomFields(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = "11111111-2222-3333-4444-555555555555";

my $client = HTTP::Request->new( 'GET', $endpoint .'devices'.'/'.$id.'/customfields');

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
    'object' => 'devices',
    'id' => '11111111-2222-3333-4444-555555555555'
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id']))
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"]. '/customfields';

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Device</p>";
    $publishResponse = request(options);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Device Custom Fields ' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetDevice
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("devices/{id}/customfields", Method.GET);
            request.AddUrlSegment("id", "11111111-2222-3333-4444-555555555555"); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetDevice { 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final String ID = "11111111-2222-3333-4444-555555555555";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/devices/"+ ID + "/customfields");              
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.Name);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public CustomField[] Data;
        public Meta Meta;                          
    }

    public class CustomField
    {
        public long Id;
        public String Name;
        public String Value;
        public String Type;
    }

    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;
    }  
}  
curl https://api.pulseway.com/v3/devices/11111111-2222-3333-4444-555555555555/customfields \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
    "Data": [
        {
            "Id": 123,
            "Name": "Custom Field Name",
            "Value": "Custom Field Value1",
            "Type": "Text"
        },
        {
            "Id": 345,
            "Name": "Custom Field Name2",
            "Value": "2",
            "Type": "Number"
        }
    ],
    "Meta": {
        "TotalCount": 2,
        "ResponseCode": 200
    }
}   

Returns the device custom fields.

HTTP Request

https://api.pulseway.com/v3/devices/:id/customfields

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the device identifier.

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: Id, Name, Value, Type. $filter=contains(tolower(Name), 'Custom')
$orderby string no OData sorting. Sortable properties: Id, Name, Value, Type. $orderby=Type

Assets

Get Assets

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Assets < ActiveRestClient::Base
  # use $top & $skip parameters  
  before_request do |name, request|
    request.get_params['$top'] = "50"
    request.get_params['$skip'] = "0"
  end

  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'   

  get :all, "/assets"
end

begin   
    puts "Get Assets..."        
    @result = Assets.all
    puts @result.data.to_json

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    # use $top & $skip parameters
    result = api.assets.get($top='50', $skip='0')
    print (result)

except Exception as e:
    print('Get Assets raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    // use $top & $skip parameters
    parameters: { $top: "50", $skip: "0" }
}

client.registerMethod("getAssets", endpoint + "assets", "GET");

client.methods.getAssets(args, function (data, response) {  
    console.log(data);  
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'assets';

my $uri = URI->new($endpoint.$query_object);
# use $top & $skip parameters
$uri->query_form('$top'  => '50', '$skip' => '0');

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}
 <?php

const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'assets'        
);

// use $top & $skip parameters
const params = array (
    '$top' => '50',
    '$skip' => '0'
);

function request($opt, $params) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];

    $parameters = '';
    if (isset($params['$top']) || isset($params['$skip']))
        foreach($params as $key=>$value)
            $parameters .= $key.'='.$value.'&';

    $parameters = trim($parameters, '&');

    curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Assets</p>";
    $getAssetsResponse = request(options, params);
    echo "<p>".$getAssetsResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Assets' exception: ", $e.getMessage(), "</p></br></br>";
}
?> 
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;
using System;

namespace Program
{
    class Assets
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("assets", Method.GET);

            request.AddParameter("$top", "50");
            request.AddParameter("$skip", "0");

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);            
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetAssets 
{ 
    private static final String ENDPOINT = "https://api.pulseway.com/v3/";
    // If you host your own Pulseway Enterprise Server, use:
    // private static final String ENDPOINT = "<server_name>/api/v3/"
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String APITOKEN = "TOKEN_SECRET";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/assets")
              .setParameter("$top", "50")
              .setParameter("$skip", "0");
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + APITOKEN).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Meta.ResponseCode);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public Assets[] Data;
        public Meta Meta;                          
    }    
    public class Assets 
    {
        public String Identifier;
        public String Name;
        public String GroupName;
        public String Description;
        public String[] Tags;
        public String Type;
        public String ClientVersion;
        public String LastUpdated; // ISO 8601 in UTC
        public String LastSeenOnline; // ISO 8601 in UTC
        public String LastReboot; // ISO 8601 in UTC
        public int CpuUsage;
        public int MemoryUsage;
        public long MemoryTotal;
        public boolean FirewallEnabled;
        public String AntivirusEnabled;
        public String AntivirusUpToDate;
        public boolean UacEnabled;
        public DeviceEventLogs EventLogs;
        public DeviceUpdates Updates;
        public DeviceAssetInfo[] AssetInfo;
        public String PublicIpAddress;
        public DeviceIpAddresses[] IpAddresses;
        public DeviceDisks[] Disks;
        public DeviceInstalledSoftware[] InstalledSoftware;
    }
    public class DeviceEventLogs 
    {
        public int Error;
        public int Warning;
        public int Information;
    }
    public class DeviceUpdates 
    {
        public int Critical;
        public int Important;
        public int Moderate;
        public int Low;
        public int Unspecified;
    }
    public class DeviceAssetInfo 
    {
        public String CategoryName;
        public HashMap<String, String> CategoryData;
    }
    public class DeviceIpAddresses 
    {
        public String Name;
        public String MAC;
        public DeviceIpAddress[] IPs;
    }
    public class DeviceIpAddress 
    {
        public String Ip;
        public boolean V6;
        public long Download;
        public long Upload;
    }
    public class DeviceDisks 
    {
        public String Name;
        public boolean System;
        public int FreePercentage;
        public long TotalValue;
    }
    public class DeviceInstalledSoftware 
    {
        public String Name;
        public String Publisher;
        public String Version;
    }
    public class Meta
    {
        public String ResponseCode;
        public String ErrorMessage;      
    }  
}
curl https://https://api.pulseway.com/v3/assets?$top=50&$skip=0 \
     -u TOKEN_ID:TOKEN_SECRET 

The above command returns JSON structured like this:

{
    "Data": [
        {
            "Identifier": "11111111-2222-3333-4444-555555555555",
            "Name": "Computer1",
            "GroupName": "Group1",
            "Description": "Windows 10 Enterprise",
            "Tags": [
                "development"
            ],
            "Type": "windows",
            "ClientVersion": "5.1.2",
            "LastUpdated": "",
            "LastSeenOnline": "2017-08-11T15:10:06Z",
            "LastReboot": "",
            "ExternalUrl": "https://<server_name>/app/main/systems/11111111-2222-3333-4444-555555555555/details",
            "CpuUsage": 19,
            "MemoryUsage": 55,
            "MemoryTotal": 8589398016,
            "FirewallEnabled": false,
            "AntivirusEnabled": "enabled",
            "AntivirusUpToDate": "disabled",
            "UacEnabled": true,
            "EventLogs": {
                "Error": 2159,
                "Warning": 928,
                "Information": 55353
            },
            "Updates": {
                "Critical": 12,
                "Important": 1,
                "Moderate": 0,
                "Low": 0,
                "Unspecified": 0
            },
            "AssetInfo": [
                {
                    "CategoryName": "System",
                    "CategoryData": {
                        "Name": "Computer1",
                        "Manufacturer": "VMware, Inc.",
                        "Model": "VMware Virtual Platform",
                        "Type": "x64-based PC",
                        "CPU": "Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz",
                        "Number of Processors": "1",
                        "Number of Logical Processors": "2",
                        "DNS Host Name": "Computer1",
                        "Domain": "WORKGROUP",
                        "Owner Name": "John",
                        "Roles": "LM_Workstation, LM_Server, SQLServer, NT, Potential_Browser, Master_Browser",
                        "Status": "OK"
                    }
                },
                {
                    "CategoryName": "BIOS",
                    "CategoryData": {
                        "Serial Number": "VMware-55 44 55 22 44 11 44 dd-22 f4 a4 10 bb ee 77 cc",
                        "Name": "PhoenixBIOS 4.0 Release 6.0     ",
                        "Manufacturer": "Phoenix Technologies LTD",
                        "SMBIOS Version": "6.00",
                        "SMBIOS Major Version": "2",
                        "SMBIOS Minor Version": "7",
                        "Version": "INTEL  - 6040000",
                        "Release Date": "Thursday, July 2, 2015 1:00 AM",
                        "Status": "OK",
                        "Description": "PhoenixBIOS 4.0 Release 6.0     "
                    }
                },
                {
                    "CategoryName": "Operating System",
                    "CategoryData": {
                        "Name": "Windows 10 Enterprise",
                        "Version": "10.0.15063.0",
                        "Build Type": "Multiprocessor Free",
                        "Registered User": "John",
                        "Serial Number": "11111-22222-233333-44444",
                        "Service Pack Major Version": "0",
                        "Service Pack Minor Version": "0",
                        "System Device": "\\Device\\HarddiskVolume2",
                        "System Directory": "C:\\WINDOWS\\system32",
                        "Windows Directory": "C:\\WINDOWS",
                        "Install Date": "Tuesday, May 16, 2017 5:15 PM",
                        "Local Date and Time": "Friday, August 11, 2017 1:54 PM",
                        "Last Boot Up Time": "Thursday, August 3, 2017 10:26 AM"
                    }
                }
            ],
            "PublicIpAddress": "1.2.3.4",
            "IpAddresses": [
                {
                    "Name": "Ethernet0",
                    "MAC": "001122334455",
                    "IPs": [
                        {
                            "IP": "192.168.0.1",
                            "V6": false,
                            "Download": 5097,
                            "Upload": 2067
                        }
                    ]
                }
            ],
            "Disks": [
                {
                    "Name": "C:",
                    "System": true,
                    "FreePercentage": 73,
                    "TotalValue": 277358588
                }
            ],
            "InstalledSoftware": [
                {
                    "Name": "Google Chrome",
                    "Publisher": "Google Inc.",
                    "Version": "60.0.3112.90"
                },
                {
                    "Name": "Google Update Helper",
                    "Publisher": "Google Inc.",
                    "Version": "1.3.33.5"
                }
            ]
        }
    ],
    "Meta": {
        "TotalCount": 1,
        "ResponseCode": 200
    }
}

Returns a list of assets.

HTTP Request

https://api.pulseway.com/v3/assets

HTTP Verb

GET

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: Identifier, Name, GroupName, Description, … $filter=GroupName eq 'My Org - My Site - My Group'
$orderby string no OData sorting. Sortable properties: Identifier, Name, GroupName, Description, … $orderby=Name

Get Assets for a Specific Device

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Device < ActiveRestClient::Base
    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET'     

    get :find, "/assets/:id"
end

begin   
    puts "Get Device Assets..."     
    @result = Device.find(id: '11111111-2222-3333-4444-555555555555', '$top': 10, '$skip': 0)
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    result = api.assets("11111111-2222-3333-4444-555555555555").get()
    print (result)

except Exception as e:
    print('Get Device Assets raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": '11111111-2222-3333-4444-555555555555' },
}

client.registerMethod("getDeviceAssets", endpoint + "assets/${id}", "GET");

client.methods.getDeviceAssets(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = "11111111-2222-3333-4444-555555555555";

my $client = HTTP::Request->new( 'GET', $endpoint .'assets'.'/'.$id);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
    'object' => 'assets',
    'id' => '11111111-2222-3333-4444-555555555555'
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id']))
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Device Assets</p>";
    $publishResponse = request(options);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Device Assets' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetDeviceAssets
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("assets/{id}", Method.GET);
            request.AddUrlSegment("id", "11111111-2222-3333-4444-555555555555"); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
            Console.WriteLine(result.data.CategoryData);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.util.HashMap;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetDeviceAssets 
{ 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final String ID = "11111111-2222-3333-4444-555555555555";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/assets/"+ ID);             
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Meta.ResponseCode);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public Assets Data;
        public Meta Meta;                          
    }    
    public class Assets 
    {
        public String Identifier;
        public String Name;
        public String GroupName;
        public String Description;
        public String[] Tags;
        public String Type;
        public String ClientVersion;
        public String LastUpdated; // ISO 8601 in UTC
        public String LastSeenOnline; // ISO 8601 in UTC
        public String LastReboot; // ISO 8601 in UTC
        public int CpuUsage;
        public int MemoryUsage;
        public long MemoryTotal;
        public boolean FirewallEnabled;
        public String AntivirusEnabled;
        public String AntivirusUpToDate;
        public boolean UacEnabled;
        public DeviceEventLogs EventLogs;
        public DeviceUpdates Updates;
        public DeviceAssetInfo[] AssetInfo;
        public String PublicIpAddress;
        public DeviceIpAddresses[] IpAddresses;
        public DeviceDisks[] Disks;
        public DeviceInstalledSoftware[] InstalledSoftware;
    }
    public class DeviceEventLogs 
    {
        public int Error;
        public int Warning;
        public int Information;
    }
    public class DeviceUpdates 
    {
        public int Critical;
        public int Important;
        public int Moderate;
        public int Low;
        public int Unspecified;
    }
    public class DeviceAssetInfo 
    {
        public String CategoryName;
        public HashMap<String, String> CategoryData;
    }
    public class DeviceIpAddresses 
    {
        public String Name;
        public String MAC;
        public DeviceIpAddress[] IPs;
    }
    public class DeviceIpAddress 
    {
        public String Ip;
        public boolean V6;
        public long Download;
        public long Upload;
    }
    public class DeviceDisks 
    {
        public String Name;
        public boolean Device;
        public int FreePercentage;
        public long TotalValue;
    }
    public class DeviceInstalledSoftware 
    {
        public String Name;
        public String Publisher;
        public String Version;
    }
    public class Meta
    {
        public String ResponseCode;
        public String ErrorMessage;      
    }  
}  
curl https://api.pulseway.com/v3/assets/11111111-2222-3333-4444-555555555555 \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
    "Data": {        
        "Identifier": "11111111-2222-3333-4444-555555555555",
        "Name": "Computer1",
        "GroupName": "Group1",
        "Description": "Windows 10 Enterprise",
        "Tags": [
            "development"
        ],
        "Type": "windows",
        "ClientVersion": "5.1.2",
        "LastUpdated": "",
        "LastSeenOnline": "2017-08-11T15:10:06Z",
        "LastReboot": "",
        "ExternalUrl": "https://<server_name>/app/main/systems/11111111-2222-3333-4444-555555555555/details",
        "CpuUsage": 19,
        "MemoryUsage": 55,
        "MemoryTotal": 8589398016,
        "FirewallEnabled": false,
        "AntivirusEnabled": "enabled",
        "AntivirusUpToDate": "disabled",
        "UacEnabled": true,
        "EventLogs": {
            "Error": 2159,
            "Warning": 928,
            "Information": 55353
        },
        "Updates": {
            "Critical": 12,
            "Important": 1,
            "Moderate": 0,
            "Low": 0,
            "Unspecified": 0
        },
        "AssetInfo": [
            {
                "CategoryName": "System",
                "CategoryData": {
                    "Name": "Computer1",
                    "Manufacturer": "VMware, Inc.",
                    "Model": "VMware Virtual Platform",
                    "Type": "x64-based PC",
                    "CPU": "Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz",
                    "Number of Processors": "1",
                    "Number of Logical Processors": "2",
                    "DNS Host Name": "Computer1",
                    "Domain": "WORKGROUP",
                    "Owner Name": "John",
                    "Roles": "LM_Workstation, LM_Server, SQLServer, NT, Potential_Browser, Master_Browser",
                    "Status": "OK"
                }
            },
            {
                "CategoryName": "BIOS",
                "CategoryData": {
                    "Serial Number": "VMware-55 44 55 22 44 11 44 dd-22 f4 a4 10 bb ee 77 cc",
                    "Name": "PhoenixBIOS 4.0 Release 6.0     ",
                    "Manufacturer": "Phoenix Technologies LTD",
                    "SMBIOS Version": "6.00",
                    "SMBIOS Major Version": "2",
                    "SMBIOS Minor Version": "7",
                    "Version": "INTEL  - 6040000",
                    "Release Date": "Thursday, July 2, 2015 1:00 AM",
                    "Status": "OK",
                    "Description": "PhoenixBIOS 4.0 Release 6.0     "
                }
            },
            {
                "CategoryName": "Operating System",
                "CategoryData": {
                    "Name": "Windows 10 Enterprise",
                    "Version": "10.0.15063.0",
                    "Build Type": "Multiprocessor Free",
                    "Registered User": "John",
                    "Serial Number": "11111-22222-233333-44444",
                    "Service Pack Major Version": "0",
                    "Service Pack Minor Version": "0",
                    "Device": "\\Device\\HarddiskVolume2",
                    "System Directory": "C:\\WINDOWS\\system32",
                    "Windows Directory": "C:\\WINDOWS",
                    "Install Date": "Tuesday, May 16, 2017 5:15 PM",
                    "Local Date and Time": "Friday, August 11, 2017 1:54 PM",
                    "Last Boot Up Time": "Thursday, August 3, 2017 10:26 AM"
                }
            }
        ],
        "PublicIpAddress": "1.2.3.4",
        "IpAddresses": [
            {
                "Name": "Ethernet0",
                "MAC": "001122334455",
                "IPs": [
                    {
                        "IP": "192.168.0.1",
                        "V6": false,
                        "Download": 5097,
                        "Upload": 2067
                    }
                ]
            }
        ],
        "Disks": [
            {
                "Name": "C:",
                "System": true,
                "FreePercentage": 73,
                "TotalValue": 277358588
            }
        ],
        "InstalledSoftware": [
            {
                "Name": "Google Chrome",
                "Publisher": "Google Inc.",
                "Version": "60.0.3112.90"
            },
            {
                "Name": "Google Update Helper",
                "Publisher": "Google Inc.",
                "Version": "1.3.33.5"
            }
        ]   
    },
    "Meta": {
        "ResponseCode": 200
    }
}

Returns the assets for a specific device.

HTTP Request

https://api.pulseway.com/v3/assets/:id

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the device identifier.

Automation

Run Task

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

IDENTIFIERS = ["11111111-2222-3333-4444-555555555555"]

class Automation < ActiveRestClient::Base
    request_body_type :json

    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET' 

    post :run_task, "/automation/tasks/1234/executions"
end

begin   
    puts "Run Task..."   

    @result = Automation.run_task(
        "identifiers": IDENTIFIERS
    )
    puts @result.Meta['ResponseCode']

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

identifiers  = ["11111111-2222-3333-4444-555555555555"]

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    result = api.automation.tasks(1234).executions.post(
        {
          "identifiers": identifiers
        }
    );

    print (result)

except Exception as e:
    print('Run Task raised an exception.')
    print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var task_id    = 1234;
var identifiers  = ["11111111-2222-3333-4444-555555555555"];

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {
    data: {
        identifiers: identifiers
    },
    headers: {"Content-Type": "application/json"}
}

client.registerMethod("run_task", endpoint + "automation/tasks/" + task_id + "/executions", "POST");

client.methods.run_task(args, function (data, response) {
    console.log(data);  
});  
package main;
use strict;
use REST::Client;
use JSON -support_by_pp;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $task_id = 1234;
my $identifiers = ("11111111-2222-3333-4444-555555555555");

my $query_object = 'automation/tasks/' .$task_id .'/executions';
my $uri = URI->new($endpoint.$query_object);

my $runTask = { 
    'identifiers' => $identifiers
}; 

my $json = new JSON;
my $data = $json->allow_nonref->pretty->utf8->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->encode($runTask);

my $client = HTTP::Request->new( 'POST', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");
$client->content($data);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
 <?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const Identifiers  = array("11111111-2222-3333-4444-555555555555");

const options = array(
    'object' => 'automation/tasks/',
    'id' => '1234',
    'executions' => 'executions'    
);

$runTaskRequest = array(
    "Identifiers" => Identifiers
);

function request($opt, $data) {
    $request = curl_init();
    $data_string = json_encode($data);
    $headers = array(
        'Content-Type: application/json',
        'Content-Length: '.strlen($data_string)
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id'])) {
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];
        if (isset($opt['executions'])) {
            $url = ENDPOINT . $opt['object'] . '/' . $opt["id"] . '/' . $opt["executions"];
        }
    }

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($request, CURLOPT_POST, TRUE);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Run Task</p>";
    $runTaskResponse = request(options, $runTaskRequest);
    echo "<p>".$runTaskResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Run Task' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class Program
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static int TASK_ID = 1234;
        static string[] IDENTIFIERS = new[] {"11111111-2222-3333-4444-555555555555"};

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("automation/tasks/" + TASK_ID + "/executions", Method.POST);
            request.RequestFormat = DataFormat.Json;
            request.AddJsonBody(new RunTask() { Identifiers = IDENTIFIERS });

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }

        public class RunTask
        {
            public string[] Identifiers { get; set; }           
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class Notify {

  private static final String ENDPOINT = "api.pulseway.com/v3/";
  // If you host your own Pulseway Enterprise Server, use:
  // private static final String ENDPOINT = "https://<server_name>/api/v3/"
  private static final String TOKEN_ID = "TOKEN_ID";
  private static final String TOKEN_SECRET = "TOKEN_SECRET";

  private static final String TASK_ID = "1234";
  private static final String[] IDENTIFIERS = {"11111111-2222-3333-4444-555555555555"};

  private static RunTask getRunTaskRequest() 
  {
      RunTask request = new RunTask();
      request.setIdentifiers(IDENTIFIERS);

      return request;
  }

  public static void main(String[] args) 
  {
      try 
      {                 
          URIBuilder builder = new URIBuilder();
          builder.setScheme("https").setHost(ENDPOINT).setPath("/automation/tasks/" + TASK_ID + "/executions");           
          URI uri = builder.build();

          HttpPost request = new HttpPost(uri);       
          request.setHeader("Content-Type", "application/json");

          String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
          request.setHeader("Authorization", "Basic " + auth);

          Gson gson = new Gson();
          RunTask runTaskRequest = getRunTaskRequest();
          StringEntity notifyJson = new StringEntity(gson.toJson(runTaskRequest));

          request.setEntity(notifyJson);

          HttpClient httpClient = HttpClients.createDefault();
          HttpResponse response = httpClient.execute(request);

          HttpEntity httpEntity = response.getEntity();
          String apiOutput = EntityUtils.toString(httpEntity);

          Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

          System.out.println(resp.Meta.ResponseCode);
      }
      catch (Exception ex) 
      {
          System.out.println("An exception has occurred: " +  ex.getMessage());
      }
  }  

  public static class Response
  {   
      public Meta Meta;    

      public Response() {}      
  }   
  public static class Meta
  {
      public int ResponseCode;
      public String ErrorMessage;   

      public Meta() {}      
  } 
  public static class Device
  {
      public int id;

      public Device() {}
  }
  public static class RunTask
  {
      public String[] Identifiers;

      public RunTask() {}

      public void setIdentifiers(String[] identifiers)
      {
          this.Identifiers = identifiers;
      }
  }
}  
curl https://api.pulseway.com/v3/automation/tasks/1234/executions \
    -u TOKEN_ID:TOKEN_SECRET \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"Identifiers": ["11111111-2222-3333-4444-555555555555"] }'

The above command returns JSON structured like this:

{
    "Meta": {
        "ResponseCode": 200
    },
    "Data": {
        "Id`": 10450
    }
}   

Runs a specific automation task.

HTTP Request

https://api.pulseway.com/v3/automation/tasks/:id/executions

HTTP Verb

POST

Fields

Name Value Required Description
Identifiers array No Identifiers of the systems where the automation task will run. If the identifiers are not specified the task will run on the configured scope.

URL Parameters

Parameter Value Required Description
id string yes Id of the task to run.

Get Task Execution

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class TaskExecution < ActiveRestClient::Base
  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'       

  get :find, "/automation/executions/:id"
end

begin   
  puts "Get Task Execution..."      
  @result = TaskExecution.find('1234')
  puts @result.Data.to_json

rescue Exception => e       
  puts e.message        
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
  api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
  result = api.automation.executions("1234").get()
  print (result)

except Exception as e:
  print('Get Task Execution raised an exception.')
  print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
  path: { "id": '1234' },
}

client.registerMethod("getTaskExecution", endpoint + "automation/executions/${id}", "GET");

client.methods.getTaskExecution(args, function (data, response) {
  console.log(data);    
});  
package main;

use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = "1234";

my $client = HTTP::Request->new( 'GET', $endpoint .'automation/executions'.'/'.$id);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
  my $jsonobj = JSON::decode_json($response->decoded_content);

  # Data::Dumper makes it easy to see what the JSON returned actually looks like 
  # when converted into Perl data structures.

  print Dumper($jsonobj->{'Meta'});
  print Dumper($jsonobj->{'Data'});
} else {
  die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
  'object' => 'automation/executions',
  'id' => '1234'
);

function request($opt) {
  $request = curl_init();
  $headers = array(
    'Content-Type: application/json'        
  );

  $url = ENDPOINT . $opt['object'];
  if (isset($opt['id']))
    $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];

  curl_setopt($request, CURLOPT_URL, $url);
  curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

  $response = curl_exec($request);
  if ($response == FALSE) {
    die('<p>Curl failed: '.curl_error($request).'</p>');
  }

  return $response;
}

try {
  echo "<p>Get Task Execution</p>";
  $taskExecutionResponse = request(options);
  echo "<p>".$taskExecutionResponse."</p></br></br>";
}
catch (Exception $e) {
  echo "<p>'Get Task Execution' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class Program
    {
        private const string Endpoint = "https://api.pulseway.com/v3/";
        private const string TokenId = "TOKEN_ID";
        private const string TokenSecret = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(Endpoint);
            client.Authenticator = new HttpBasicAuthenticator(TokenId, TokenSecret);

            var request = new RestRequest("automation/executions/{id}", Method.GET);
            request.AddUrlSegment("id", "1234");

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetTaskExecution {

  private static final String Endpoint = "api.pulseway.com/v3/";
  // If you host your own Pulseway Enterprise Server, use:
  // private static final String Endpoint = "<server_name>/api/v3/"
  private static final String TokenId = "TOKEN_ID";
  private static final String TokenSecret = "TOKEN_SECRET";
  private static final String Id = "1234";

  public static void main(String[] args) 
  {
      try 
      {                 
          URIBuilder builder = new URIBuilder();
          builder.setScheme("https").setHost(Endpoint).setPath("/automation/executions/"+ Id);            
          URI uri = builder.build();

          HttpGet request = new HttpGet(uri);         
          request.setHeader("Content-Type", "application/json");
          String auth = new String(Base64.encodeBase64((TokenId + ":" + TokenSecret).getBytes()), StandardCharsets.UTF_8.toString());
          request.setHeader("Authorization", "Basic " + auth);

          HttpClient httpClient = HttpClients.createDefault();
          HttpResponse response = httpClient.execute(request);

          HttpEntity httpEntity = response.getEntity();
          String apiOutput = EntityUtils.toString(httpEntity);

          Gson gson = new Gson();
          Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

          System.out.println(resp.data.state);
      }
      catch (Exception ex) 
      {
          System.out.println("An exception has occurred: " +  ex.getMessage());
      }
  }  

  public class Response
  {
      public TaskExecution Data;
      public Meta Meta;                          
  }    
  public class TaskExecution
  {
      public String Id;
      public int TaskId;
      public int DeviceCount;
      public int SuccessfulDeviceCount;
      public int FailedDeviceCount;
      public String StartTime;
      public String EndTime;
      public String Duration;
      public String State;
      public String GroupName;
  }    
  public class Meta
  {
      public String ResponseCode;
      public String ErrorMessage;      
  }  
}
curl https://api.pulseway.com/v3/automation/executions/1234 \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
    "Meta": {
        "ResponseCode": 200
    },
    "Data": {
        "Id": 1234,
        "TaskId": 12345,
        "DeviceCount": 2,
        "SuccessfulDeviceCount": 2,
        "FailedDeviceCount": 0,
        "StartTime": "2017-08-31T15:28:25Z",
        "EndTime": "2017-08-31T15:28:41Z",
        "Duration": "16 seconds",
        "State": "Successful"
    }
}   

Returns the task execution status.

HTTP Request

https://api.pulseway.com/v3/automation/executions/:id

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes Id of the task execution.

Get Task Execution Devices

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Device < ActiveRestClient::Base
    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET'     

    get :get_task_execution_devices, "/automation/executions/:id/devices"
end

begin   
    puts "Get Task Execution Devices..."        
    @result = Device.get_task_execution_devices('1234')
    puts @result.data.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    result = api.automation.executions("1234").devices().get()
    print (result)

except Exception as e:
    print('Get Task Execution devices raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": '1234' },
}

client.registerMethod("getTaskExecutionDevices", endpoint + "automation/executions/${id}/devices", "GET");

client.methods.getTaskExecutionDevices(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = "1234";

my $client = HTTP::Request->new( 'GET', $endpoint .'automation/executions'.'/'.$id.'/'.'devices');

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
    'object' => 'automation/executions',
    'id' => '1234',
    'devices' => 'devices',
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id'])) {
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];
        if (isset($opt['devices'])) {
            $url = ENDPOINT . $opt['object'] . '/' . $opt["id"] . '/' . $opt["devices"];
        }
    }

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Task Execution Devices</p>";
    $taskExecutionDevicesResponse = request(options);
    echo "<p>".$taskExecutionDevicesResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Task Execution Devices: ", $e.getMessage(), "</p></br></br>";
}
?>  
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetTaskExecutionDevices
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("automation/executions/{id}/devices", Method.GET);
            request.AddUrlSegment("id", "1234");

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetTaskExecutionDevices {

  private static final String ENDPOINT = "api.pulseway.com/v3/";
  // If you host your own Pulseway Enterprise Server, use:
  // private static final String ENDPOINT = "<server_name>/api/v3/"
  private static final String TOKEN_ID = "TOKEN_ID";
  private static final String TOKEN_SECRET = "TOKEN_SECRET";
  private static final String ID = "1234";

  public static void main(String[] args) 
  {
      try 
      {                 
          URIBuilder builder = new URIBuilder();
          builder.setScheme("https").setHost(ENDPOINT).setPath("/automation/executions/"+ ID + "/devices");           
          URI uri = builder.build();

          HttpGet request = new HttpGet(uri);         
          request.setHeader("Content-Type", "application/json");
          String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
          request.setHeader("Authorization", "Basic " + auth);

          HttpClient httpClient = HttpClients.createDefault();
          HttpResponse response = httpClient.execute(request);

          HttpEntity httpEntity = response.getEntity();
          String apiOutput = EntityUtils.toString(httpEntity);

          Gson gson = new Gson();
          Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

          if (resp.Data != null && resp.Data.length > 0)
          {
              for(TaskExecutionDevice device : resp.Data) {
                  System.out.println("Name: " + device.Name);  
                  System.out.println("Execution state: "+ device.ExecutionState);  
              }
          }
          else
          {
              if(resp.Meta != null)
              {
                  System.out.println("Error");

                  String responseCode = resp.Meta.ResponseCode;
                  if(responseCode != null && !responseCode.isEmpty())
                  {
                      System.out.println(" code: '" + resp.Meta.ResponseCode + "'");
                  }

                  String errorMessage = resp.Meta.ErrorMessage;
                  if(errorMessage != null && !errorMessage.isEmpty())
                  {
                      System.out.println(" message: '" + resp.Meta.ErrorMessage + "'");
                  }
              }
          }

      }
      catch (Exception ex) 
      {
          System.out.println("An exception has occurred: " +  ex.getMessage());
      }
  }  

  public class Response
  {
      public TaskExecutionDevice[] Data;
      public Meta Meta;                          
  }    
  public class TaskExecutionDevice
  {
      public String Identifier;
      public String Name;
      public String GroupName;
      public String ExecutionState; 
  }    
  public class Meta
  {
      public String ResponseCode;
      public String ErrorMessage;
      public int TotalCount;
  }  
}
curl https://api.pulseway.com/v3/automation/executions/1234/devices \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
    "Meta": {
        "ResponseCode": 200,
        "TotalCount": 2
    },
    "Data": [
        {
            "Identifier": "11111111-2222-3333-4444-555555555555",
            "Name": "Device 1",
            "GroupName": "Workstations",
            "Description": "Windows Server 2012 R2 Standard",
            "ExecutionState": "Successful"
        },
        {
            "Identifier": "66666666-7777-8888-9999-123456789012",
            "Name": "Device 2",
            "GroupName": "Workstations",
            "Description": "Windows 10 Enterprise",
            "ExecutionState": "Successful"
        }
    ]
}

Returns the execution status for the devices where the task has executed.

HTTP Request

https://api.pulseway.com/v3/automation/executions/:id/devices

HTTP Verb

GET

URL Parameters

Parameter Value Required Description Example
id string yes Id of the task execution. 123
includeFailed string no Include devices where the task execution has failed. Defaults to true. false
includeSuccessful string no Include devices where the task execution was successful. Defaults to true. false
$top integer no Maximum number of items to return, limited to 100. Default value: 100. $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: Identifier, Name, GroupName, Description, ExecutionState. $filter=ExecutionState eq 'Successful' and contains(Description, 'Windows')
$orderby string no OData sorting. Sortable properties: Identifier, Name, GroupName, Description, ExecutionState. $orderby=ExecutionState

Notifications

Notify

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

InstanceId    = "production_website_1"
InstanceName  = "Production Web Site"
InstanceGroup = "Web Sites"

class Notification < ActiveRestClient::Base
  request_body_type :json

  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'   

  post :notify, "/notifications"
end

begin   
    puts "Notify..."    

    @result = Notification.notify(
        "InstanceId": InstanceId,
        "Title": "Runtime error",
        "Message": "Cannot connect to the database.",
        "Priority": "critical"
    )

    puts @result.Meta['ResponseCode']

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    result = api.notifications.post(
        {
          "InstanceId": "production_website_1",
          "Title": "Runtime error",
          "Message": "Cannot connect to the database.",
          "Priority": "critical"
        }
    );

    print (result)

except Exception as e:
    print('Notify raised an exception.')
    print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";
var instance_id    = "production_website_1";
var instance_name  = "Production Web Site";
var instance_group = "Web Sites";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {
    data: {
        InstanceId: instance_id,
        Title: "Database Connection Error",
        Message: instance_name + " Instance in group " + instance_group + " cannot connect to the database",
        Priority: "Critical"
    },
    headers: {"Content-Type": "application/json"}
}

client.registerMethod("notify", endpoint + "notifications", "POST");

client.methods.notify(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON -support_by_pp;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'notifications';

my $uri = URI->new($endpoint.$query_object);

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $instance_id = "production_website_1";
my $instance_name = "Production Web Site";
my $instance_group = "Web Sites";

my $notify = {
    'InstanceId' => $instance_id,   
    'Title' => "Cannot connect to the database",
    'Message' => "Database Connection Error",
    'Priority' => "Critical"
}; 

my $json = new JSON;

my $data = $json->allow_nonref->pretty->utf8->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->encode($notify);

my $client = HTTP::Request->new( 'POST', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");
$client->content($data);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
 <?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";
const INSTANCE_ID    = "rest";
const INSTANCE_NAME  = "Production Web Site";
const INSTANCE_GROUP = "Web Sites";

const options = array(
    'object' => 'notifications'     
);

$notifyRequest = array(
    "InstanceId" => INSTANCE_ID,
    "Title" => "Database Connection Error",
    "Message" => INSTANCE_NAME." Instance in group ".INSTANCE_GROUP." cannot connect to the database.",
    "Priority" => "Critical"
);

function request($opt, $data) {
    $request = curl_init();
    $data_string = json_encode($data);
    $headers = array(
        'Content-Type: application/json',
        'Content-Length: '.strlen($data_string)
    );

    $url = ENDPOINT . $opt['object'];

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($request, CURLOPT_POST, TRUE);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Notify</p>";
    $publishResponse = request(options, $notifyRequest);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Notify' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace Notify
{
    class Program
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        private const string INSTANCE_ID = "production_website_1";
        private const string INSTANCE_NAME = "Production Web Site";
        private const string INSTANCE_GROUP = "Web Sites";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("notifications", Method.POST);
            request.RequestFormat = DataFormat.Json;
            request.AddBody(GetPublishRequest());

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }

        private static NotifyRequest GetPublishRequest()
        {
            return new NotifyRequest
            {
                InstanceId = INSTANCE_ID,
                Title = "Database Connection Error",
                Message = INSTANCE_NAME + " Instance in group " + INSTANCE_GROUP + " cannot connect to the database.",
                Priority = "Critical"
            };
        }

        public class NotifyRequest
        {
            public string InstanceId { get; set; }
            public string Title { get; set; }
            public string Message { get; set; }
            // Critical, Elevated, Normal or Low
            public string Priority { get; set; }
        }
        public class Response
        {
            public int ResponseCode { get; set; }
            public string ErrorMessage { get; set; }
        }
    }
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class Notify 
{ 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final String INSTANCE_ID = "production_website_1";

    private static NotifyRequest getNotifyRequest() 
    {
        NotifyRequest request = new NotifyRequest();
        request.setInstanceId(INSTANCE_ID);
        request.setTitle("Could not connect to the database.");
        request.setMessage("Database Connection Error");
        request.setPriority("Critical");
        return request;
    }

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/notifications");           
            URI uri = builder.build();

            HttpPost request = new HttpPost(uri);         
            request.setHeader("Content-Type", "application/json");

            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            Gson gson = new Gson();

            NotifyRequest notifyRequest = getNotifyRequest();
            StringEntity notifyJson = new StringEntity(gson.toJson(notifyRequest));

            request.setEntity(notifyJson);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Meta.ResponseCode);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }    
    public static class Response
    {     
        public Meta Meta;   
    }   
    public static class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;     
    } 
    public static class NotifyRequest
    {
        public String InstanceId;
        public String Title;
        public String Message;
        public String Priority;     

        public void setInstanceId(String instanceId)
        {
            this.InstanceId = instanceId;
        }
        public void setTitle(String title)
        {
            this.Title = title;
        }
        public void setMessage(String message)
        {
            this.Message = message;
        }
        public void setPriority(String priority)
        {
            this.Priority = priority;
        }      
    }
}  
curl https://api.pulseway.com/v3/notifications \
    -u TOKEN_ID:TOKEN_SECRET \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"InstanceId":"production_website_1","Title":"Runtime error","Message":"Cannot connect to the database.","Priority":"Critical"}'

The above command returns JSON structured like this:

{
    "Meta": {
        "ResponseCode": 200 
    }   
}   

Creates a device notification.

HTTP Request

https://api.pulseway.com/v3/notifications

HTTP Verb

POST

Fields

Name Value Required Description
InstanceId string yes Identifier of the instance that triggered the notification. (maximum 100 characters)
Title string yes Notification title that is displayed in the PUSH notification.
Message string no Notification message appears in the Notification Detail view. Defaults to the title field. (maximum 5000 characters)
Priority string no Possible values: Low, Normal, Elevated, Critical. Defaults to Normal.

Get All Notifications

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Notification < ActiveRestClient::Base
# use $top & $skip parameters    
    before_request do |name, request|
        request.get_params['$top'] = "2"
        request.get_params['$skip'] = "0"
    end

    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET' 

  get :all, "/notifications"
end

begin   
    puts "Get Notifications..."     
    @result = Notification.all
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    # use $top & $skip parameters
    result = api.notifications.get($top='2', $skip='0')
    print (result)

except Exception as e:
    print('GetNotifications raised an exception.')
    print(e.strerror)
)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    // use $top & $skip parameters
    parameters: { $top: "2", $skip: "0" }
}

client.registerMethod("getNotifications", endpoint + "notifications", "GET");

client.methods.getNotifications(args, function (data, response) {   
    console.log(data);  
});   
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $uri = URI->new($endpoint.'notifications');
$uri->query_form('$top'  => '2', '$skip' => '0');

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
<?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'notifications'     
);

// use $top & $skip parameters
const params = array (
    '$top' => '2',
    '$skip' => '0'
);

function request($opt, $params) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];

    $parameters = '';
    if (isset($params['$top']) || isset($params['$skip']))
        foreach($params as $key=>$value)
                $parameters .= $key.'='.$value.'&';

    $parameters = trim($parameters, '&');

    curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Notifications</p>";
    $publishResponse = request(options, params);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Notifications' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetNotifications
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("notifications", Method.GET);

            request.AddParameter("$top", "2");
            request.AddParameter("$skip", "0");

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetNotifications { 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/notifications")
                .setParameter("$top", "5")
                .setParameter("$skip", "0");
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();

            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.length);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }    
    public class Response
    {
        public Notification[] Data; 
        public Meta Meta;           
    }    
    public class Notification
    {
        public int Id;
        public String Message;
        public int DateTime;
        public String Priority;    
    }    
    public class Meta
    {
        public String ResponseCode;
        public String ErrorMessage;      
    }  
}
curl https://https://api.pulseway.com/v3/notifications \
     -u TOKEN_ID:TOKEN_SECRET 

# If you want to use $top & $skip parameters, append
# "?&$top=2&$skip=0" to the url  

The above command returns JSON structured like this:

{ 
    "Data": [
        {
            "Id": 2750,
            "Message": "Production Web Site Instance in group Web Sites cannot connect to the database",
            "DateTime": 1463473104,
            "Priority": "critical" 
        },
        {
            "Id": 2749,
            "Message": "Cannot connect to the database.",           
            "DateTime": 1463473083,
            "Priority": "critical" 
        }
    ],
    "Meta": {
        "ResponseCode": 200,
        "TotalCount": 2
    }
}    

Returns the device notifications.

HTTP Request

https://api.pulseway.com/v3/notifications

HTTP Verb

GET

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: Id, Message, DateTime, Priority. $filter=contains(tolower(Message), 'free space')
$orderby string no OData sorting. Sortable properties: Id, Message, DateTime, Priority. $orderby=Priority

Get a Specific Notification

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Notification < ActiveRestClient::Base  
  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'   

  get :find, "/notifications/:id"
end

begin   
    puts "Get Notification..."      
    @result = Notification.find(2643)
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    result = api.notifications(2643).get()
    print (result)

except Exception as e:
    print('GetNotification raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": 2643 },
}

client.registerMethod("getNotification", endpoint + "Notifications/${id}", "GET");

client.methods.getNotification(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 2643;

my $uri = URI->new($endpoint.'Notifications'.'/'.$id);

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
 <?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'Notifications',
    'id' => 2643
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id']))
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Notification</p>";
    $publishResponse = request(options);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Notification' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication2
{
    class GetNotification
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("notifications/{id}", Method.GET);
            request.AddUrlSegment("id", "2643"); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetNotification {
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final int ID = 2643;

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/notifications/"+ ID);              
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();

            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.ComputerIdentifier);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public NotificationDetails Data;
        public Meta Meta;                   
    }    
    public class NotificationDetails
    {
        public int Id;
        public String Message;
        public int DateTime;
        public String Priority;
        public String ComputerIdentifier;
        public boolean Read;
    }    
    public class Meta
    {
        public String ResponseCode;
        public String ErrorMessage;    
    }  
}  
curl https://https://api.pulseway.com/v3/notifications/2643 \
     -u TOKEN_ID:TOKEN_SECRET 

The above command returns JSON structured like this:

{   
    "Data": [{
        "ComputerIdentifier": "28440dda-f385-4ec8-a5c3-d1e6074113bb",
        "Read": false,
        "Id": 2643,
        "Message": "Production Web Site Instance in group Web Sites cannot connect to the database",
        "DateTime": 1463473104,
        "Priority": "critical"
    }],
    "Meta": {
        "ResponseCode": 200
    }
}       

Returns the notification details.

HTTP Request

https://api.pulseway.com/v3/notifications/:id

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the notification identifier

Delete a Specific Notification

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Notification < ActiveRestClient::Base
    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET' 

    delete :del, "/notifications/:id"
end

begin   
    puts "Delete Notification..."       
    @result = Notification.del(2643)
    puts @result.Meta.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    result = api.notifications(2643).delete()
    print (result)

except Exception as e:
    print('DeleteNotification raised an exception.')
    print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": 2643 },
}

client.registerMethod("deleteNotification", endpoint + "notifications/${id}", "DELETE");

client.methods.deleteNotification(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 2643;

my $uri = URI->new($endpoint.'notifications'.'/'.$id);

my $client = HTTP::Request->new( 'DELETE', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
 <?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'notifications',
    'id' => 2643
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id']))
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_CUSTOMREQUEST, "DELETE");
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Delete Notification</p>";
    $publishResponse = request(options);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Delete Notification' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class DeleteNotification
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("notifications/{id}", Method.DELETE);
            request.AddUrlSegment("id", "2643"); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}

package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class DeleteNotification { 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final int ID = 2643;

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/notifications/"+ ID);              
            URI uri = builder.build();

            HttpDelete request = new HttpDelete(uri);         
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();

            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Meta.ResponseCode);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }    
    public class Response
    {       
        public Meta Meta;                          
    }          
    public class Meta
    {
        public String ResponseCode;
        public String ErrorMessage;      
    }  
}  
curl -X DELETE https://https://api.pulseway.com/v3/notifications/2643 \
     -u TOKEN_ID:TOKEN_SECRET 

The above command returns JSON structured like this:

{
    "Meta": {
        "ResponseCode": 200
    }
}   

Deletes a specific notification.

HTTP Request

https://api.pulseway.com/v3/notifications/:id

HTTP Verb

DELETE

URL Parameters

Parameter Value Required Description
id string yes The value of the notification identifier

Organizations

Get All Organizations

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Organization < ActiveRestClient::Base
  # use $top & $skip parameters  
  before_request do |name, request|
    request.get_params[:$top] = "50"
    request.get_params[:$skip] = "0"
  end

  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'   

  get :all, "/organizations"
end

begin   
    puts "Get Organizations..."     
    @result = Organization.all
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    # use $top & $skip parameters
    result = api.organizations.get($top='50', $skip='0')
    print (result)

except Exception as e:
    print('GetOrganizations raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    // use $top & $skip parameters
    parameters: { $top: "50", $skip: "0" }
}

client.registerMethod("getOrganizations", endpoint + "organizations", "GET");

client.methods.getOrganizations(args, function (data, response) {   
    console.log(data);  
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'organizations';

my $uri = URI->new($endpoint.$query_object);
# use $top & $skip parameters
$uri->query_form('$top'  => '50', '$skip' => '0');

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}
 <?php

const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'organizations'     
);

// use $top & $skip parameters
const params = array (
    '$top' => '50',
    '$skip' => '0'
);

function request($opt, $params) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];

    $parameters = '';
    if (isset($params['$top']) || isset($params['$skip']))
        foreach($params as $key=>$value)
            $parameters .= $key.'='.$value.'&';

    $parameters = trim($parameters, '&');

    curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Organizations</p>";
    $publishResponse = request(options, params);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Organizations' exception: ", $e.getMessage(), "</p></br></br>";
}
?> 
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;
using System;

namespace ConsoleApplication
{
    class GetOrganizations
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("organizations", Method.GET);

            request.AddParameter("$top", "50");
            request.AddParameter("$skip", "0");

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);            
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetOrganizations {
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/organizations")
                .setParameter("$top", "50")
                .setParameter("$skip", "0");
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data[0].Id);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }    
    public class Response
    {
        public Organization[] Data;
        public Meta Meta;                          
    }    
    public class Organization
    {
        public int Id;
        public String Name;
        public boolean HasCustomFields;
        public int PsaMappingId;
        public String PsaMappingType;
    }    
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;
        public int TotalCount;
    }  
}
curl https://https://api.pulseway.com/v3/organizations \
     -u TOKEN_ID:TOKEN_SECRET 

# If you want to use $top & $skip parameters, append
# "?&$top=50&$skip=0" to the url

The above command returns JSON structured like this:

{
    "Data": [
        {
            "Id": 101,
            "Name": "MyOrg1",
            "HasCustomFields": false,
            "PsaMappingId": null,
            "PsaMappingType": null
        },
        {
            "Id": 102,
            "Name": "MyOrg2",
            "HasCustomFields": true,
            "PsaMappingId": 123,
            "PsaMappingType": "AutoTask"
        }
    ],
    "Meta": {
        "ResponseCode": 200,
        "TotalCount": 2
    }   
}

Returns a list of organizations.

HTTP Request

https://api.pulseway.com/v3/organizations

HTTP Verb

GET

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: see below. $filter=PsaMappingType eq 'AutoTask' and contains(Name, 'myorg')
$orderby string no OData sorting. Sortable properties: see below. $orderby=Name asc

Organization Response Properties

Property Type Filterable Sortable Description
Id integer yes yes Organization ID.
Name string yes yes Organization Name.
HasCustomFields boolean no no Shows if Organization has any Custom Fields assigned.
PsaMappingId integer yes yes ID of PSA Mapping
PsaMappingType string yes yes Type of PSA Mapping. Possible values: ConnectWise, AutoTask, null

Get a Specific Organization

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Organization < ActiveRestClient::Base
    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET'     

    get :find, "/organizations/:id"
end

begin   
    puts "Get Organization..."      
    @result = Organization.find(123)
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    # result = api.organizations.get();
    result = api.organizations(123).get()
    print (result)

except Exception as e:
    print('GetOrganization raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": 123 },
}

client.registerMethod("getOrganization", endpoint + "organizations/${id}", "GET");

client.methods.getOrganizations(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 123;

my $client = HTTP::Request->new( 'GET', $endpoint .'organizations'.'/'.$id);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
    'object' => 'organizations',
    'id' =>  123
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id']))
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Organization</p>";
    $publishResponse = request(options);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Organization' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetOrganization
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("organizations/{id}", Method.GET);
            request.AddUrlSegment("id", 123); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetOrganization { 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final int ID = 123;

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/organizations/"+ ID);              
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.Name);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public Organization Data;
        public Meta Meta;                          
    }    
    public class Organization
    {
        public int Id;
        public String Name;
        public boolean HasCustomFields;
        public int PsaMappingId;
        public String PsaMappingType;
    }
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;      
    }  
}  
curl https://api.pulseway.com/v3/organizations/123 \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
    "Data": {
        "Id": 102,
        "Name": "MyOrg2",
        "HasCustomFields": true,
        "PsaMappingId": 123,
        "PsaMappingType": "AutoTask"
    },
    "Meta": {
        "ResponseCode":200
    }
}   

Returns the organization details.

HTTP Request

https://api.pulseway.com/v3/organizations/:id

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the organization ID.

Organization Response Properties

Property Type Description
Id integer Organization ID.
Name string Organization Name.
HasCustomFields boolean Shows if Organization has any Custom Fields assigned.
PsaMappingId integer ID of PSA Mapping
PsaMappingType string Type of PSA Mapping. Possible values: ConnectWise, AutoTask, null

Get Organization Custom Fields

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Organization < ActiveRestClient::Base
    # use $top & $skip parameters    
    before_request do |name, request|
        request.get_params[:$top] = "50"
        request.get_params[:$skip] = "0"
    end

    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET' 

  get :customfields, "/organizations/:id/customfields" 
end

begin   
    puts "Get Organization Custom Fields..."        
    @result = Organization.customfields('11111111-2222-3333-4444-555555555555')
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    result = api.organizations(123).customfields.get()
    print (result)

except Exception as e:
    print('GetOrganizationCustomFields raised an exception.')
    print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": 123 },
}

client.registerMethod("getOrganizationCustomFields", endpoint + "organizations/${id}/customfields", "GET");

client.methods.getOrganizationCustomFields(args, function (data, response) {    
    console.log(data);  
});   
##!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
$endpoint->query_form('$top'  => '50', '$skip' => '0');
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 123;

my $uri = URI->new('organizations/'.$id.'/customfields')->abs($endpoint);

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
 <?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'organizations',
    'id' => 123
);

// use $top & $skip parameters
const params = array (
    '$top' => '50',
    '$skip' => '0'
);

function request($opt, $params) {
    $request = curl_init();
    $headers = array(
    'Content-Type: application/json'        
);

$url = ENDPOINT . $opt['object'];
if (isset($opt['id']))
    $url = ENDPOINT . $opt['object'] . '/' . $opt["id"].'/'.'customfields';

    $parameters = '';
    if (isset($params['$top']) || isset($params['$skip']))
    foreach($params as $key=>$value)
        $parameters .= $key.'='.$value.'&';

    $parameters = trim($parameters, '&');

    curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Organization Custom Fields</p>";
    $publishResponse = request(options, params);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Organization Custom Fields' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetOrganizationCustomFields
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("organizations/{id}/customfields", Method.GET);
            request.AddUrlSegment("id", 123); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetOrganizationCustomFields {
    private static final String ENDPOINT = "api.pulseway.com/v3/";  
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final int ID = 123;

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/organizations/"+ ID + "/customfields")
                .setParameter("$top", "50")
            .setParameter("$skip", "0");              
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();

            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.length);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public CustomField[] Data;
        public Meta Meta;                          
    }    
    public class CustomField
    {
        public int Id;
        public String Name;
        public String Value;
        public String Type; 
    }    
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;     
        public int TotalCount; 
    }  
}  
curl https://https://api.pulseway.com/v3/organizations/123/customfields \
     -u TOKEN_ID:TOKEN_SECRET 

# If you want to use $top & $skip parameters, append
# "?&$top=50&$skip=0" to the url

The above command returns JSON structured like this:

{
    "Data": [{
            "Id": 569,
            "Name": "CustomField_42",
            "Value": "422",
            "Type": "Text"
    }, {
            "Id": 643,
            "Name": "SomeEmptyValue",
            "Value": null,
            "Type": "Text"
    }, {
            "Id": 850,
            "Name": "Text Custom Field",
            "Value": "None",
            "Type": "Text"
    }],
    "Meta": {
        "ResponseCode": 200,
        "TotalCount": 3
    }
}   

Return the organization custom fields.

HTTP Request

https://api.pulseway.com/v3/organizations/:id/customfields

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the organization ID.

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: see below. $filter=Type eq 'Text'
$orderby string no OData sorting. Sortable properties: see below. $orderby=Name

Custom Field Response Properties

Property Type Filterable Sortable Description
Id integer yes yes Custom Field ID.
Name string yes yes Custom Field Name.
Value string yes yes Custom Fields Value converted to string.
Type string yes yes Type of Custom Field. Possible values: Text, Number, Date, Boolean.

Sites

Get All Sites

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Site < ActiveRestClient::Base
  # use $top & $skip parameters  
  before_request do |name, request|
    request.get_params[:$top] = "50"
    request.get_params[:$skip] = "0"
  end

  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'   

  get :all, "/Sites"
end

begin   
    puts "Get Sites..."     
    @result = Site.all
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    # use $top & $skip parameters
    result = api.Sites.get($top='50', $skip='0')
    print (result)

except Exception as e:
    print('GetSites raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    // use $top & $skip parameters
    parameters: { $top: "50", $skip: "0" }
}

client.registerMethod("getSites", endpoint + "Sites", "GET");

client.methods.getSites(args, function (data, response) {   
    console.log(data);  
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'Sites';

my $uri = URI->new($endpoint.$query_object);
# use $top & $skip parameters
$uri->query_form('$top'  => '50', '$skip' => '0');

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}
 <?php

const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'Sites'     
);

// use $top & $skip parameters
const params = array (
    '$top' => '50',
    '$skip' => '0'
);

function request($opt, $params) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];

    $parameters = '';
    if (isset($params['$top']) || isset($params['$skip']))
        foreach($params as $key=>$value)
            $parameters .= $key.'='.$value.'&';

    $parameters = trim($parameters, '&');

    curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Sites</p>";
    $publishResponse = request(options, params);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Sites' exception: ", $e.getMessage(), "</p></br></br>";
}
?> 
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;
using System;

namespace ConsoleApplication
{
    class GetSites
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("Sites", Method.GET);

            request.AddParameter("$top", "50");
            request.AddParameter("$skip", "0");

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);            
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetSites {
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/Sites")
                .setParameter("$top", "50")
                .setParameter("$skip", "0");
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data[0].Id);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }    
    public class Response
    {
        public Site[] Data;
        public Meta Meta;                          
    }    
    public class Site
    {
        public int Id;
        public String Name;
        public ContactInformation ContactInformation;
        public String ParentId;
        public String ParentName;
        public boolean HasCustomFields;
        public int PsaMappingId;
        public String PsaIntegrationType;
    }   
    public class ContactInformation
    {
        public string Phone;
        public String Fax;
        public String Email;
        public String ContactName;
        public string CountryCode;
        public String City;
        public String Address1;
        public String Address2;
        public String Zip;
    }     
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;
        public int TotalCount;
    }  
}
curl https://https://api.pulseway.com/v3/Sites \
     -u TOKEN_ID:TOKEN_SECRET 

# If you want to use $top & $skip parameters, append
# "?&$top=50&$skip=0" to the url

The above command returns JSON structured like this:

{
    "Data": [
        {
            "Id": 101,
            "Name": "MySite1",
            "ContactInformation": {
                "Phone": "123213123",
                "Fax": "1231231",
                "Email": "email@contact.com",
                "ContactName": "Contact Name",
                "CountryCode": "PL",
                "City": "City1",
                "Address1": "AdressLine1",
                "Address2": "AddressLine2",
                "Zip": "123"
            },
            "ParentId" : 1,
            "ParentName" : "MyOrg1",
            "HasCustomFields": false,
            "PsaMappingId": null,
            "PsaIntegrationType": null
        },
        {
            "Id": 102,
            "Name": "MySite2",
            "ParentId" : 1,
            "ParentName" : "MyOrg1",
            "HasCustomFields": true,
            "PsaMappingId": 123,
            "PsaIntegrationType": "AutoTask"
        }
    ],
    "Meta": {
        "ResponseCode": 200,
        "TotalCount": 2
    }   
}

Returns a list of Sites.

HTTP Request

https://api.pulseway.com/v3/sites

HTTP Verb

GET

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: see below. $filter=PsaIntegrationType eq 'AutoTask' and contains(Name, 'myorg')
$orderby string no OData sorting. Sortable properties: see below. $orderby=Name asc

Site Response Properties

Property Type Filterable Sortable Description
Id integer yes yes Site ID.
Name string yes yes Site Name.
ContactInformation ContactInformation no no Information on how to contact the site.
ParentId integer yes yes Site’s parent organization id.
ParentName string yes yes Site’s parent organization name.
HasCustomFields boolean no no Shows if Site has any Custom Fields assigned.
PsaMappingId integer yes yes ID of PSA Mapping
PsaIntegrationType string yes yes Type of PSA Mapping. Possible values: ConnectWise, AutoTask, null

ContactInformation Properties

Property Type Description
Phone string Contact’s phone number.
Fax string Contact’s fax number.
Email string Contact’s email.
ContactName string Contact’s name.
CountryCode string Contact’s country code.
City string Contact’s city.
Address1 string Contact’s Address Line 1.
Address2 string Contact’s Address Line 2.
Zip string Contact’s Zip code.

Get a Specific Site

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Site < ActiveRestClient::Base
    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET'     

    get :find, "/Sites/:id"
end

begin   
    puts "Get Site..."      
    @result = Site.find(123)
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    # result = api.Sites.get();
    result = api.Sites(123).get()
    print (result)

except Exception as e:
    print('GetSite raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": 123 },
}

client.registerMethod("getSite", endpoint + "Sites/${id}", "GET");

client.methods.getSites(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 123;

my $client = HTTP::Request->new( 'GET', $endpoint .'Sites'.'/'.$id);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
    'object' => 'Sites',
    'id' =>  123
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id']))
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Site</p>";
    $publishResponse = request(options);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Site' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetSite
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("Sites/{id}", Method.GET);
            request.AddUrlSegment("id", 123); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetSite { 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final int ID = 123;

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/Sites/"+ ID);              
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.Name);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public Site Data;
        public Meta Meta;                          
    }    
    public class Site
    {
        public int Id;
        public String Name;
        public ContactInformation ContactInformation;
        public String ParentId;
        public String ParentName;
        public boolean HasCustomFields;
        public int PsaMappingId;
        public String PsaIntegrationType;
    }   
    public class ContactInformation
    {
        public string Phone;
        public String Fax;
        public String Email;
        public String ContactName;
        public string CountryCode;
        public String City;
        public String Address1;
        public String Address2;
        public String Zip;
    }   
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;      
    }  
}  
curl https://api.pulseway.com/v3/Sites/123 \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
    "Data": {
        "Id": 102,
        "Name": "MySite2",
        "ParentId" : 1,
        "ContactInformation": {
            "Phone": "123213123",
            "Fax": "1231231",
            "Email": "email@contact.com",
            "ContactName": "Contact Name",
            "CountryCode": "PL",
            "City": "City1",
            "Address1": "AdressLine1",
            "Address2": "AddressLine2",
            "Zip": "123"
        },
        "ParentName" : "MyOrg1",
        "HasCustomFields": true,
        "PsaMappingId": 123,
        "PsaIntegrationType": "AutoTask"
    },
    "Meta": {
        "ResponseCode":200
    }
}   

Returns the Site details.

HTTP Request

https://api.pulseway.com/v3/sites/:id

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the Site ID.

Site Response Properties

Property Type Description
Id integer Site ID.
Name string Site Name.
ContactInformation ContactInformation Information on how to contact the site.
ParentId int Site’s parent organization id.
ParentName string Site’s parent organization name.
HasCustomFields boolean Shows if Site has any Custom Fields assigned.
PsaMappingId integer ID of PSA Mapping
PsaIntegrationType string Type of PSA Mapping. Possible values: ConnectWise, AutoTask, null

ContactInformation Properties

Property Type Description
Phone string Contact’s phone number.
Fax string Contact’s fax number.
Email string Contact’s email.
ContactName string Contact’s name.
CountryCode string Contact’s country code.
City string Contact’s city.
Address1 string Contact’s Address Line 1.
Address2 string Contact’s Address Line 2.
Zip string Contact’s Zip code.

Get Site Custom Fields

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Site < ActiveRestClient::Base
    # use $top & $skip parameters    
    before_request do |name, request|
        request.get_params[:$top] = "50"
        request.get_params[:$skip] = "0"
    end

    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET' 

  get :customfields, "/Sites/:id/customfields" 
end

begin   
    puts "Get Site Custom Fields..."        
    @result = Site.customfields('11111111-2222-3333-4444-555555555555')
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    result = api.Sites(123).customfields.get()
    print (result)

except Exception as e:
    print('GetSiteCustomFields raised an exception.')
    print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": 123 },
}

client.registerMethod("getSiteCustomFields", endpoint + "Sites/${id}/customfields", "GET");

client.methods.getSiteCustomFields(args, function (data, response) {    
    console.log(data);  
});   
##!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
$endpoint->query_form('$top'  => '50', '$skip' => '0');
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 123;

my $uri = URI->new('Sites/'.$id.'/customfields')->abs($endpoint);

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
 <?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'Sites',
    'id' => 123
);

// use $top & $skip parameters
const params = array (
    '$top' => '50',
    '$skip' => '0'
);

function request($opt, $params) {
    $request = curl_init();
    $headers = array(
    'Content-Type: application/json'        
);

$url = ENDPOINT . $opt['object'];
if (isset($opt['id']))
    $url = ENDPOINT . $opt['object'] . '/' . $opt["id"].'/'.'customfields';

    $parameters = '';
    if (isset($params['$top']) || isset($params['$skip']))
    foreach($params as $key=>$value)
        $parameters .= $key.'='.$value.'&';

    $parameters = trim($parameters, '&');

    curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Site Custom Fields</p>";
    $publishResponse = request(options, params);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Site Custom Fields' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetSiteCustomFields
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("Sites/{id}/customfields", Method.GET);
            request.AddUrlSegment("id", 123); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetSiteCustomFields {
    private static final String ENDPOINT = "api.pulseway.com/v3/";  
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final int ID = 123;

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/Sites/"+ ID + "/customfields")
                .setParameter("$top", "50")
            .setParameter("$skip", "0");              
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();

            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.length);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public CustomField[] Data;
        public Meta Meta;                          
    }    
    public class CustomField
    {
        public int Id;
        public String Name;
        public String Value;
        public String Type; 
    }    
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;     
        public int TotalCount; 
    }  
}  
curl https://https://api.pulseway.com/v3/Sites/123/customfields \
     -u TOKEN_ID:TOKEN_SECRET 

# If you want to use $top & $skip parameters, append
# "?&$top=50&$skip=0" to the url

The above command returns JSON structured like this:

{
    "Data": [{
            "Id": 569,
            "Name": "CustomField_42",
            "Value": "422",
            "Type": "Text"
    }, {
            "Id": 643,
            "Name": "SomeEmptyValue",
            "Value": null,
            "Type": "Text"
    }, {
            "Id": 850,
            "Name": "Text Custom Field",
            "Value": "None",
            "Type": "Text"
    }],
    "Meta": {
        "ResponseCode": 200,
        "TotalCount": 3
    }
}   

Return the Site custom fields.

HTTP Request

https://api.pulseway.com/v3/sites/:id/customfields

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the Site ID.

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: see below. $filter=Type eq 'Text'
$orderby string no OData sorting. Sortable properties: see below. $orderby=Name

Custom Field Response Properties

Property Type Filterable Sortable Description
Id integer yes yes Custom Field ID.
Name string yes yes Custom Field Name.
Value string yes yes Custom Fields Value converted to string.
Type string yes yes Type of Custom Field. Possible values: Text, Number, Date, Boolean.

Groups

Get All Groups

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Group < ActiveRestClient::Base
  # use $top & $skip parameters  
  before_request do |name, request|
    request.get_params[:$top] = "50"
    request.get_params[:$skip] = "0"
  end

  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'   

  get :all, "/groups"
end

begin   
    puts "Get Groups..."        
    @result = Group.all
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
    # use $top & $skip parameters
    result = api.groups.get($top='50', $skip='0')
    print (result)

except Exception as e:
    print('GetGroups raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    // use $top & $skip parameters
    parameters: { $top: "50", $skip: "0" }
}

client.registerMethod("getGroups", endpoint + "groups", "GET");

client.methods.getGroups(args, function (data, response) {  
    console.log(data);  
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'groups';

my $uri = URI->new($endpoint.$query_object);
# use $top & $skip parameters
$uri->query_form('$top'  => '50', '$skip' => '0');

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}
 <?php

const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'groups'        
);

// use $top & $skip parameters
const params = array (
    '$top' => '50',
    '$skip' => '0'
);

function request($opt, $params) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];

    $parameters = '';
    if (isset($params['$top']) || isset($params['$skip']))
        foreach($params as $key=>$value)
            $parameters .= $key.'='.$value.'&';

    $parameters = trim($parameters, '&');

    curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Groups</p>";
    $publishResponse = request(options, params);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Groups' exception: ", $e.getMessage(), "</p></br></br>";
}
?> 
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;
using System;

namespace ConsoleApplication
{
    class GetGroups
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("groups", Method.GET);

            request.AddParameter("$top", "50");
            request.AddParameter("$skip", "0");

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);            
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetGroups {
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/groups")
                .setParameter("$top", "50")
                .setParameter("$skip", "0");
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data[0].Id);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }    
    public class Response
    {
        public Group[] Data;
        public Meta Meta;                          
    }    
    public class Group
    {
        public int Id;
        public String Name;
        public boolean HasCustomFields;
        public int ParentSiteId;
        public String ParentSiteName;
        public int ParentOrganizationId;
        public String ParentOrganizationId;
        public int PsaMappingId;
        public String PsaMappingType;
        public String Notes;

    }    
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;
        public int TotalCount;
    }  
}
curl https://https://api.pulseway.com/v3/groups \
     -u TOKEN_ID:TOKEN_SECRET 

# If you want to use $top & $skip parameters, append
# "?&$top=50&$skip=0" to the url

The above command returns JSON structured like this:

{
    "Data": [
        {
            "Id": 101,
            "Name": "MyGroup1",
            "ParentSiteId": 6979,
            "ParentSiteName": "Some Site",
            "ParentOrganizationId": 6978,
            "ParentOrganizationName": "Some Org",
            "Notes": null,
            "HasCustomFields": false,
            "PsaMappingId": null,
            "PsaMappingType": null
        },
        {
            "Id": 102,
            "Name": "MyGroup2",
            "ParentSiteId": 6979,
            "ParentSiteName": "Some Site",
            "ParentOrganizationId": 6978,
            "ParentOrganizationName": "Some Org",
            "Notes": "Some Notes",
            "HasCustomFields": true,
            "PsaMappingId": 123,
            "PsaMappingType": "AutoTask"
        }
    ],
    "Meta": {
        "ResponseCode": 200,
        "TotalCount": 2
    }   
}

Returns a list of groups.

HTTP Request

https://api.pulseway.com/v3/groups

HTTP Verb

GET

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: see below. $filter=PsaMappingType eq 'AutoTask' and contains(Name, 'MyGroup')
$orderby string no OData sorting. Sortable properties: see below. $orderby=Name asc

Group Response Properties

Property Type Filterable Sortable Description
Id integer yes yes Group ID.
Name string yes yes Group Name.
ParentSiteId integer yes yes Id of the parent Site.
ParentSiteName string yes yes Name of the parent Site.
ParentOrganizationId integer yes yes Id of the parent Organization.
ParentOrganizationName string yes yes Name of the parent Organization.
Notes string yes yes Group Notes.
HasCustomFields boolean no no Shows if Group has any Custom Fields assigned.
PsaMappingId integer yes yes ID of PSA Mapping
PsaMappingType string yes yes Type of PSA Mapping. Possible values: ConnectWise, AutoTask, null

Get a Specific Group

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Group < ActiveRestClient::Base
    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET'     

    get :find, "/groups/:id"
end

begin   
    puts "Get Group..."     
    @result = Group.find(123)
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    # result = api.groups.get();
    result = api.groups(123).get()
    print (result)

except Exception as e:
    print('GetGroup raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": 123 },
}

client.registerMethod("getGroup", endpoint + "groups/${id}", "GET");

client.methods.getGroup(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 123;

my $client = HTTP::Request->new( 'GET', $endpoint .'groups'.'/'.$id);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
    'object' => 'groups',
    'id' =>  123
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id']))
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Group</p>";
    $publishResponse = request(options);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Group' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetGroup
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("groups/{id}", Method.GET);
            request.AddUrlSegment("id", 123); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetGroup { 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final int ID = 123;

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/groups/"+ ID);             
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.Name);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public Group Data;
        public Meta Meta;                          
    }    
    public class Group
    {
        public int Id;
        public String Name;
        public boolean HasCustomFields;
        public int ParentSiteId;
        public String ParentSiteName;
        public int ParentOrganizationId;
        public String ParentOrganizationId;
        public int PsaMappingId;
        public String PsaMappingType;
        public String Notes;
        public PackageInfo[] Packages;
    }
    public class PackageInfo 
    {
        public string Type;
        public string Name;
    }
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;      
    }  
}  
curl https://api.pulseway.com/v3/groups/123 \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
    "Data": {
        "Id": 102,
        "Name": "MyGroup2",
        "ParentSiteId": 6979,
        "ParentSiteName": "Some Site",
        "ParentOrganizationId": 6978,
        "ParentOrganizationName": "Some Org",
        "Notes": "Some Notes",
        "HasCustomFields": true,
        "PsaMappingId": 123,
        "PsaMappingType": "AutoTask",
        "Packages": [
            {
                    "Type": "windows_agent_x64",
                    "Name": "Windows (64 bit)"
            },
            {
                    "Type": "windows_agent_x86",
                    "Name": "Windows (32 bit)"
            }
    ]
    },
    "Meta": {
        "ResponseCode": 200
    }
}   

Returns the group details.

HTTP Request

https://api.pulseway.com/v3/groups/:id

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the group ID.

Group Response Properties

Property Type Description
Id integer Group ID.
Name string Group Name.
ParentSiteId integer Id of the parent Site.
ParentSiteName string Name of the parent Site.
ParentOrganizationId integer Id of the parent Organization.
ParentOrganizationName string Name of the parent Organization.
Notes string Group Notes.
HasCustomFields boolean Shows if Group has any Custom Fields assigned.
PsaMappingId integer ID of PSA Mapping.
PsaMappingType string Type of PSA Mapping. Possible values: ConnectWise, AutoTask, null.
Packages Package List of packages available to download.

Package object Properties

Property Type Description
Type string Download Package type. Download URL can be requested via api/v3/groups/:id/package/:type call.
Name string Download Package name.

Get Group Custom Fields

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Group < ActiveRestClient::Base
    # use $top & $skip parameters    
    before_request do |name, request|
        request.get_params[:$top] = "50"
        request.get_params[:$skip] = "0"
    end

    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET' 

  get :customfields, "/groups/:id/customfields" 
end

begin   
    puts "Get Group Custom Fields..."       
    @result = Group.customfields('11111111-2222-3333-4444-555555555555')
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    result = api.groups(123).customfields.get()
    print (result)

except Exception as e:
    print('GetGroupCustomFields raised an exception.')
    print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": 123 },
}

client.registerMethod("getGroupCustomFields", endpoint + "groups/${id}/customfields", "GET");

client.methods.getGroupCustomFields(args, function (data, response) {   
    console.log(data);  
});   
##!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
$endpoint->query_form('$top'  => '50', '$skip' => '0');
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 123;

my $uri = URI->new('groups/'.$id.'/customfields')->abs($endpoint);

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
 <?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
    'object' => 'groups',
    'id' => 123
);

// use $top & $skip parameters
const params = array (
    '$top' => '50',
    '$skip' => '0'
);

function request($opt, $params) {
    $request = curl_init();
    $headers = array(
    'Content-Type: application/json'        
);

$url = ENDPOINT . $opt['object'];
if (isset($opt['id']))
    $url = ENDPOINT . $opt['object'] . '/' . $opt["id"].'/'.'customfields';

    $parameters = '';
    if (isset($params['$top']) || isset($params['$skip']))
    foreach($params as $key=>$value)
        $parameters .= $key.'='.$value.'&';

    $parameters = trim($parameters, '&');

    curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Group Custom Fields</p>";
    $publishResponse = request(options, params);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Group Custom Fields' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetGroupCustomFields
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("groups/{id}/customfields", Method.GET);
            request.AddUrlSegment("id", 123); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetGroupCustomFields {
    private static final String ENDPOINT = "api.pulseway.com/v3/";  
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final int ID = 123;

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/groups/"+ ID + "/customfields")
                .setParameter("$top", "50")
            .setParameter("$skip", "0");              
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();

            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.length);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public CustomField[] Data;
        public Meta Meta;                          
    }    
    public class CustomField
    {
        public int Id;
        public String Name;
        public String Value;
        public String Type; 
    }    
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;     
        public int TotalCount; 
    }  
}  
curl https://https://api.pulseway.com/v3/groups/123/customfields \
     -u TOKEN_ID:TOKEN_SECRET 

# If you want to use $top & $skip parameters, append
# "?&$top=50&$skip=0" to the url

The above command returns JSON structured like this:

{
    "Data": [{
            "Id": 569,
            "Name": "CustomField_42",
            "Value": "422",
            "Type": "Text"
    }, {
            "Id": 643,
            "Name": "SomeEmptyValue",
            "Value": null,
            "Type": "Text"
    }, {
            "Id": 850,
            "Name": "Text Custom Field",
            "Value": "None",
            "Type": "Text"
    }],
    "Meta": {
        "ResponseCode": 200,
        "TotalCount": 3
    }
}   

Return the group custom fields.

HTTP Request

https://api.pulseway.com/v3/groups/:id/customfields

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the group ID.

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: see below. $filter=Type eq 'Text'
$orderby string no OData sorting. Sortable properties: see below. $orderby=Name

Custom Field Response Properties

Property Type Filterable Sortable Description
Id integer yes yes Custom Field ID.
Name string yes yes Custom Field Name.
Value string yes yes Custom Fields Value converted to string.
Type string yes yes Type of Custom Field. Possible values: Text, Number, Date, Boolean.

Get a Group Package

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class GroupPackage < ActiveRestClient::Base
    base_url 'https://api.pulseway.com/v3/'
    username 'TOKEN_ID'
    password 'TOKEN_SECRET'     

    get :find, "/groups/:id/package/:packageId"
end

begin   
    puts "Get Group Package..."     
    @result = GroupPackage.find(123, 'windows_agent_x64')
    puts @result.Data.to_json

rescue Exception => e       
    puts e.message      
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:        
    api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
    result = api.groups(123).package("windows_agent_x64").get()
    print (result)

except Exception as e:
    print('GetGroupPackage raised an exception.')
    print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {    
    path: { "id": 123, "packageId": "windows_agent_x64" },
}

client.registerMethod("getGroupPackage", endpoint + "groups/${id}/package/${packageId}", "GET");

client.methods.getGroupPackage(args, function (data, response) {
    console.log(data);  
});   
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 123;
my $packageId = "windows_agent_x64";

my $client = HTTP::Request->new( 'GET', $endpoint .'groups'.'/'.$id.'/'.'package'.'/'.$packageId);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
    my $jsonobj = JSON::decode_json($response->decoded_content);

    # Data::Dumper makes it easy to see what the JSON returned actually looks like 
    # when converted into Perl data structures.

    print Dumper($jsonobj->{'Meta'});
    print Dumper($jsonobj->{'Data'});
} else {
    die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
    'object' => 'groups',
    'id' =>  123,
    'packageId' => 'windows_agent_x64'
);

function request($opt) {
    $request = curl_init();
    $headers = array(
        'Content-Type: application/json'        
    );

    $url = ENDPOINT . $opt['object'];
    if (isset($opt['id']))
        $url = ENDPOINT . $opt['object'] . '/' . $opt["id"] . 'package' . '/' . $opt["pacakgeId"];

    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

    $response = curl_exec($request);
    if ($response == FALSE) {
        die('<p>Curl failed: '.curl_error($request).'</p>');
    }

    return $response;
}

try {
    echo "<p>Get Group Package</p>";
    $publishResponse = request(options);
    echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
    echo "<p>'Get Group Package' exception: ", $e.getMessage(), "</p></br></br>";
}
?>  
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetGroupPackage
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("groups/{id}/package/{packageId}", Method.GET);
            request.AddUrlSegment("id", 123);
                        request.AddUrlSegment("packageId", "windows_agent_x64");

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetGroupPackage { 
    private static final String ENDPOINT = "api.pulseway.com/v3/";
    private static final String TOKEN_ID = "TOKEN_ID";
    private static final String TOKEN_SECRET = "TOKEN_SECRET";
    private static final int ID = 123;
    private static final String PACKAGE_ID = "windows_agent_x64";

    public static void main(String[] args) 
    {
        try 
        {                   
            URIBuilder builder = new URIBuilder();
            builder.setScheme("https").setHost(ENDPOINT).setPath("/groups/"+ ID + "/package/" + PACKAGE_ID);              
            URI uri = builder.build();

            HttpGet request = new HttpGet(uri);       
            request.setHeader("Content-Type", "application/json");
            String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
            request.setHeader("Authorization", "Basic " + auth);

            HttpClient httpClient = HttpClients.createDefault();
            HttpResponse response = httpClient.execute(request);

            HttpEntity httpEntity = response.getEntity();
            String apiOutput = EntityUtils.toString(httpEntity);

            Gson gson = new Gson();
            Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

            System.out.println(resp.Data.Url);
        }
        catch (Exception ex) 
        {
            System.out.println("An exception has occurred: " +  ex.getMessage());
        }
    }  

    public class Response
    {
        public PackageInfo Data;
        public Meta Meta;                          
    }    
    public class PackageInfo 
    {
        public string Name;
        public string Url;
    }
    public class Meta
    {
        public int ResponseCode;
        public String ErrorMessage;      
    }  
}  
curl https://api.pulseway.com/v3/groups/123/package/windows_agent_x86 \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
    "Data": {
        "Name": "Windows (64 bit)",
        "Url": "https://server-name/installer?type=windows_agent_x64&secret=4e43f74a34d346088b2fa59a9eda3c45"
    },
    "Meta": {
        "ResponseCode":200
    }
}   

Returns the Name and Download URL for Group install package.

HTTP Request

https://api.pulseway.com/v3/groups/:id/package/:packageType

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the group ID.
packageType string yes Type of install package. Possible values: windows_agent_x64, windows_agent_x86

Package Response Properties

Property Type Description
Name string Package name.
Url string Package Download URL

Notification Webhooks

Get All Notification Webhooks

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class NotificationWebhook < ActiveRestClient::Base
  # use $top & $skip parameters   
  before_request do |name, request|
    request.get_params[:$top] = "50"
    request.get_params[:$skip] = "0"
  end

  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'  

  get :all, "/notifications/webhooks"
end

begin  
  puts "Get Notification Webhooks..."    
  @result = NotificationWebhook.all
  puts @result.Data.to_json

rescue Exception => e    
  puts e.message    
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:    
  api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
  # use $top & $skip parameters
  result = api.notifications.webhooks.get($top='50', $skip='0')
  print (result)

except Exception as e:
  print('GetNotificationWebhooks raised an exception.')
  print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {  
  // use $top & $skip parameters
  parameters: { $top: "50", $skip: "0" }
}

client.registerMethod("getNotificationWebhooks", endpoint + "notificationwebhooks", "GET");

client.methods.getNotificationWebhooks(args, function (data, response) {  
  console.log(data);  
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'notifications/webhooks';

my $uri = URI->new($endpoint.$query_object);
# use $top & $skip parameters
$uri->query_form('$top'  => '50', '$skip' => '0');

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $client = HTTP::Request->new( 'GET', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
  my $jsonobj = JSON::decode_json($response->decoded_content);

  # Data::Dumper makes it easy to see what the JSON returned actually looks like 
  # when converted into Perl data structures.

  print Dumper($jsonobj->{'Meta'});
  print Dumper($jsonobj->{'Data'});
} else {
  die $response->status_line;
}
 <?php

const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
  'object' => 'notifications/webhooks'    
);

// use $top & $skip parameters
const params = array (
  '$top' => '50',
  '$skip' => '0'
);

function request($opt, $params) {
  $request = curl_init();
  $headers = array(
    'Content-Type: application/json'        
  );

  $url = ENDPOINT . $opt['object'];

  $parameters = '';
  if (isset($params['$top']) || isset($params['$skip']))
    foreach($params as $key=>$value)
      $parameters .= $key.'='.$value.'&';

  $parameters = trim($parameters, '&');

  curl_setopt($request, CURLOPT_URL, (isset($params['$top']) || isset($params['$skip'])) ? $url.'?'.$parameters : $url);
  curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

  $response = curl_exec($request);
  if ($response == FALSE) {
    die('<p>Curl failed: '.curl_error($request).'</p>');
  }

  return $response;
}

try {
  echo "<p>Get Notification Webhooks</p>";
  $publishResponse = request(options, params);
  echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
  echo "<p>'Get Notification Webhooks' exception: ", $e.getMessage(), "</p></br></br>";
}
?> 
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;
using System;

namespace ConsoleApplication
{
    class GetNotificationWebhooks
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("notifications/webhooks", Method.GET);

            request.AddParameter("$top", "50");
            request.AddParameter("$skip", "0");

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);            
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetNotificationWebhooks {
  private static final String ENDPOINT = "api.pulseway.com/v3/";
  private static final String TOKEN_ID = "TOKEN_ID";
  private static final String TOKEN_SECRET = "TOKEN_SECRET";

  public static void main(String[] args) 
  {
    try 
    {               
      URIBuilder builder = new URIBuilder();
      builder.setScheme("https").setHost(ENDPOINT).setPath("/notifications/webhooks")
        .setParameter("$top", "50")
        .setParameter("$skip", "0");
      URI uri = builder.build();

      HttpGet request = new HttpGet(uri);      
      request.setHeader("Content-Type", "application/json");
      String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
      request.setHeader("Authorization", "Basic " + auth);

      HttpClient httpClient = HttpClients.createDefault();
      HttpResponse response = httpClient.execute(request);

      HttpEntity httpEntity = response.getEntity();
      String apiOutput = EntityUtils.toString(httpEntity);

      Gson gson = new Gson();
      Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

      System.out.println(resp.Data[0].Id);
    }
    catch (Exception ex) 
    {
      System.out.println("An exception has occurred: " +  ex.getMessage());
    }
  }    
  public class Response
  {
    public NotificationWebhook[] Data;
    public Meta Meta;                          
  }    
  public class NotificationWebhook
  {
    public int Id;
    public String Name;
    public String Description;
    public String[] Priorities;
    public int[] OrganizationIds;
    public HashMap<String, String> Headers;
    public String Url;
    public String CreatedAt;
    public String Language;
  }    
  public class Meta
  {
    public int ResponseCode;
    public String ErrorMessage;
    public int TotalCount;
  }  
}
curl https://https://api.pulseway.com/v3/notifications/webhooks \
     -u TOKEN_ID:TOKEN_SECRET 

# If you want to use $top & $skip parameters, append
# "?&$top=50&$skip=0" to the url

The above command returns JSON structured like this:

{
  "Data": [
    {
      "Id": 101,
      "Name": "MyNotificationWebhook1",
      "Description": "Some Description",
      "Priorities": ["Low", "Normal", "Elevated", "Critical"],
      "OrganizationIds": null,
      "Headers": { "MyHeader": "Value" },
      "Url": "https://some-webhook-url/test1",
      "CreatedAt": "2023-07-26T15:40:31",
      "Language": "en"
    },
    {
      "Id": 102,
      "Name": "MyNotificationWebhook2",
      "Description": null,
      "Priorities": ["Elevated", "Critical"],
      "OrganizationIds": [1002, 1003],
      "Headers": null,
      "Url": "https://some-webhook-url/test2",
      "CreatedAt": "2023-07-26T16:40:31",
      "Language": "de"
    }
  ],
  "Meta": {
    "ResponseCode": 200,
    "TotalCount": 2
  }  
}

Returns a list of Notification Webhooks.

HTTP Request

https://api.pulseway.com/v3/notifications/webhooks

HTTP Verb

GET

Query Parameters

Parameter Value Required Description Example
$top integer no Maximum number of items to return, limited to 100. Default value: 100 $top=100
$skip integer no Starting position. $skip=100
$filter string no OData filters. Filterable properties: see below. $filter=Priorities/any(p: p eq 'Elevated')
$orderby string no OData sorting. Sortable properties: see below. $orderby=Name asc

Notification Webhook Response Properties

Property Type Filterable Sortable Description
Id integer yes yes Webhook ID.
Name string yes yes Webhook Name.
Description string yes yes Webhook Description.
Priorities array of strings yes no List of Notification Priorities that are sent through Webhook.
OrganizationIds array of integers yes no List of Organization IDs used to limit scope of Notifications.
Headers key-value list no no List of additional headers sent to the Target URL.
Url string yes yes Webhook Target URL.
CreatedAt string yes yes Creation date and time.
Language string yes yes Language of Notifications send through webhook. Available values: en, de.

Get a Specific Notification Webhook

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class NotificationWebhook < ActiveRestClient::Base
  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'    

  get :find, "/notifications/webhooks/:id"
end

begin  
  puts "Get Notification Webhook..."    
  @result = NotificationWebhook.find(123)
  puts @result.Data.to_json

rescue Exception => e    
  puts e.message    
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:    
  api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))
  result = api.notifications.webhooks(123).get()
  print (result)

except Exception as e:
  print('GetNotificationWebhook raised an exception.')
  print(e.strerror)   
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {  
  path: { "id": 123 },
}

client.registerMethod("getNotificationWebhook", endpoint + "notifications/webhooks/${id}", "GET");

client.methods.getNotificationWebhook(args, function (data, response) {
  console.log(data);  
});   
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = "https://api.pulseway.com/v3/";
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 123;

my $client = HTTP::Request->new( 'GET', $endpoint .'notifications/webhooks'.'/'.$id);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
  my $jsonobj = JSON::decode_json($response->decoded_content);

  # Data::Dumper makes it easy to see what the JSON returned actually looks like 
  # when converted into Perl data structures.

  print Dumper($jsonobj->{'Meta'});
  print Dumper($jsonobj->{'Data'});
} else {
  die $response->status_line;
}   
<?php
const ENDPOINT = "https://api.pulseway.com/v3/";
const TOKEN_ID = "TOKEN_ID";
const TOKEN_SECRET = "TOKEN_SECRET";

const options = array(
  'object' => 'notifications/webhooks',
  'id' =>  123
);

function request($opt) {
  $request = curl_init();
  $headers = array(
    'Content-Type: application/json'        
  );

  $url = ENDPOINT . $opt['object'];
  if (isset($opt['id']))
    $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];

  curl_setopt($request, CURLOPT_URL, $url);
  curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

  $response = curl_exec($request);
  if ($response == FALSE) {
    die('<p>Curl failed: '.curl_error($request).'</p>');
  }

  return $response;
}

try {
  echo "<p>Get Notification Webhook</p>";
  $getResponse = request(options);
  echo "<p>".$getResponse."</p></br></br>";
}
catch (Exception $e) {
  echo "<p>'Get Notification Webhook' exception: ", $e.getMessage(), "</p></br></br>";
}
?>   
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class GetNotificationWebhook
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("notifications/webhooks/{id}", Method.GET);
            request.AddUrlSegment("id", 123); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}  
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetNotificationWebhook { 
  private static final String ENDPOINT = "api.pulseway.com/v3/";
  private static final String TOKEN_ID = "TOKEN_ID";
  private static final String TOKEN_SECRET = "TOKEN_SECRET";
  private static final int ID = 123;

  public static void main(String[] args) 
  {
    try 
    {               
      URIBuilder builder = new URIBuilder();
      builder.setScheme("https").setHost(ENDPOINT).setPath("/notifications/webhooks/"+ ID);          
      URI uri = builder.build();

      HttpGet request = new HttpGet(uri);      
      request.setHeader("Content-Type", "application/json");
      String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
      request.setHeader("Authorization", "Basic " + auth);

      HttpClient httpClient = HttpClients.createDefault();
      HttpResponse response = httpClient.execute(request);

      HttpEntity httpEntity = response.getEntity();
      String apiOutput = EntityUtils.toString(httpEntity);

      Gson gson = new Gson();
      Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

      System.out.println(resp.Data.Name);
    }
    catch (Exception ex) 
    {
      System.out.println("An exception has occurred: " +  ex.getMessage());
    }
  }  

  public class Response
  {
    public NotificationWebhook Data;
    public Meta Meta;                          
  }    
  public class NotificationWebhook
  {
    public int Id;
    public String Name;
    public String Description;
    public String[] Priorities;
    public int[] OrganizationIds;
    public HashMap<String, String> Headers;
    public String Url;
    public String CreatedAt;
    public String Language;
  }
  public class Meta
  {
    public int ResponseCode;
    public String ErrorMessage;      
  }  
}  
curl https://api.pulseway.com/v3/notifications/webhooks/123 \
     -u TOKEN_ID:TOKEN_SECRET    

The above command returns JSON structured like this:

{
  "Data": {
    "Id": 101,
    "Name": "MyNotificationWebhook1",
    "Description": "Some Description",
    "Priorities": ["Low", "Normal", "Elevated", "Critical"],
    "OrganizationIds": null,
    "Headers": { "MyHeader": "Value" },
    "Url": "https://some-webhook-url/test1",
    "CreatedAt": "2023-07-26T15:40:31",
    "Language": "en"
  },
  "Meta": {
    "ResponseCode": 200
  }
}   

Returns the notification webhook details.

HTTP Request

https://api.pulseway.com/v3/notifications/webhooks/:id

HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes The value of the Notification Webhook ID.

Notification Webhook Response Properties

Property Type Description
Id integer Webhook ID.
Name string Webhook Name.
Description string Webhook Description.
Priorities array of strings List of Notification Priorities that are sent through Webhook.
OrganizationIds array of integers List of Organization IDs used to limit scope of Notifications.
Headers key-value list List of additional headers sent to the Target URL.
Url string Webhook Target URL.
CreatedAt string Creation date and time.
Language string Language of Notifications send through webhook. Available values: en, de.

Create a Notification Webhook

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class NotificationWebhook < ActiveRestClient::Base
  request_body_type :json

  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'  

  post :create, "/notifications/webhooks"
end

begin  
  puts "Create..."  

  @result = NotificationWebhook.create(
    "Name": "MyNotificationWebhook1",
    "Description": "Some Description",
    "Priorities": ["Low", "Normal", "Elevated", "Critical"],
    "OrganizationIds": [123, 124],
    "Headers": { "CustomHeader" => "CustomValue" },
    "Url": "https://some-webhook-url/test1",
    "Language": "en"
  )

  puts @result.Meta['ResponseCode']

rescue Exception => e    
  puts e.message    
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:    
  api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
  result = api.notifications.webhooks.post(
  {
    "Name": "MyNotificationWebhook1",
    "Description": "Some Description",
    "Priorities": ["Low", "Normal", "Elevated", "Critical"],
    "OrganizationIds": [123, 124],
    "Headers": { "CustomHeader": "CustomValue" },
    "Url": "https://some-webhook-url/test1",
    "CreatedAt": "2023-07-26T15:40:31",
    "Language": "en"
  });

  print (result)

except Exception as e:
  print('Create raised an exception.')
  print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {  
  data: {
    "Name": "MyNotificationWebhook1",
    "Description": "Some Description",
    "Priorities": ["Low", "Normal", "Elevated", "Critical"],
    "OrganizationIds": [123, 124],
    "Headers": { "CustomHeader": "CustomValue" },
    "Url": "https://some-webhook-url/test1",
    "Language": "en"
  },
  headers: {"Content-Type": "application/json"}
}

client.registerMethod("create", endpoint + "notifications/webhooks", "POST");

client.methods.create(args, function (data, response) {  
  console.log(data);  
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON -support_by_pp;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'notifications/webhooks';

my $uri = URI->new($endpoint.$query_object);

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $create = {
  'Name' => "MyNotificationWebhook1",
  'Description' => "Some Description",
  'Priorities' => ["Low", "Normal", "Elevated", "Critical"],
  'OrganizationIds' => [123, 124],
  'Headers' => { 'CustomHeader" => 'CustomValue' },
  'Url' => "https://some-webhook-url/test1",
  'Language' => "en"
};  

my $json = new JSON;
my $data = $json->allow_nonref->pretty->utf8->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->encode($create);

my $client = HTTP::Request->new( 'POST', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");
$client->content($data);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
  my $jsonobj = JSON::decode_json($response->decoded_content);

  # Data::Dumper makes it easy to see what the JSON returned actually looks like 
  # when converted into Perl data structures.

  print Dumper($jsonobj->{'Meta'});
  print Dumper($jsonobj->{'Data'});
} else {
  die $response->status_line;
}
<?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

$options = array(
  'object' => 'notifications/webhooks'    
);

$createRequest = array(
  "Name" => "MyNotificationWebhook1",
  "Description" => "Some Description",
  "Priorities" => array("Low", "Normal", "Elevated", "Critical"),
  "OrganizationIds" => array(123, 124),
  "Headers": array("CustomHeader" => "CustomValue"),
  "Url" => "https://some-webhook-url/test1",
  "Language" => "en"
);

function request($opt, $data) {
  $request = curl_init();
  $data_string = json_encode($data);
  $headers = array(
    'Content-Type: application/json',
    'Content-Length: '.strlen($data_string)
  );

  $url = ENDPOINT . $opt['object'];

  curl_setopt($request, CURLOPT_URL, $url);
  curl_setopt($request, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt($request, CURLOPT_POST, TRUE);
  curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

  $response = curl_exec($request);
  if ($response == FALSE) {
    die('<p>Curl failed: '.curl_error($request).'</p>');
  }

  return $response;
}

try {
  echo "<p>Create</p>";
  $createResponse = request($options, $createRequest);
  echo "<p>".$createResponse."</p></br></br>";
}
catch (Exception $e) {
  echo "<p>'Create' exception: ", $e->getMessage(), "</p></br></br>";
}
?> 
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class Create
    {
        private const string Endpoint = "https://api.pulseway.com/v3/";
        private const string TokenId = "TOKEN_ID";
        private const string TokenSecret = "TOKEN_SECRET";

        static void Main(string[] args)
        {
            var client = new RestClient(Endpoint);
            client.Authenticator = new HttpBasicAuthenticator(TokenId, TokenSecret);

            var request = new RestRequest("notifications/webhooks", Method.POST);            
            request.RequestFormat = DataFormat.Json;
            request.AddBody(GetCreateRequest());

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }

        private static CreateRequest GetCreateRequest()
        {
            CreateRequest createRequest = new CreateRequest()
            { 
              Name = "MyNotificationWebhook1",
              Description = "Some Description",
              Priorities = new [] { "Low", "Normal", "Elevated", "Critical" },
              OrganizationIds = new [] { 123, 124 },
              Headers = new Dictionary<string, string> {{ "CustomHeader": "CustomValue" }},
              Url = "https://some-webhook-url/test1",
              Language = "en"
            }

            return createRequest;
        }

        public class CreateRequest
        {
            public string Name { get; set; }

            public string Description { get; set; }

            public string[] Priorities { get; set; }

            public long[] OrganizationIds { get; set; }

            public Dictionary<string, string> Headers { get; set; }

            public string Url { get; set; }

            public string Language { get; set; }
        }
    }
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class Create 
{ 
  private static final String ENDPOINT = "api.pulseway.com/v3/";
  private static final String TOKEN_ID = "TOKEN_ID";
  private static final String TOKEN_SECRET = "TOKEN_SECRET";

  private static CreateRequest getCreateRequest()
  {    
    CreateRequest request = new CreateRequest();

    request.setName("MyNotificationWebhook1");
    request.setDescription("Some Description");
    request.setPriorities(new String[] { "Low", "Normal", "Elevated", "Critical" });
    request.setOrganizationIds(new int[] { 123, 124 });
    request.setHeaders(new HashMap<String, String>() {{ put("CustomHeader", "CustomValue"); }});
    request.setUrl("https://some-webhook-url/test1");
    request.setLanguage("en");

    return request;
  }

  public static void main(String[] args) 
  {
    try 
    {               
      URIBuilder builder = new URIBuilder();
      builder.setScheme("https").setHost(ENDPOINT).setPath("/notifications/webhooks");          
      URI uri = builder.build();

      HttpPost request = new HttpPost(uri);      
      request.setHeader("Content-Type", "application/json");

      String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
      request.setHeader("Authorization", "Basic " + auth);

      Gson gson = new Gson();

      CreateRequest createRequest = getCreateRequest();
      StringEntity createJson = new StringEntity(gson.toJson(createRequest));

      request.setEntity(createJson);

      HttpClient httpClient = HttpClients.createDefault();
      HttpResponse response = httpClient.execute(request);

      HttpEntity httpEntity = response.getEntity();
      String apiOutput = EntityUtils.toString(httpEntity);

      Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

      System.out.println(resp.Meta.ResponseCode);
    }
    catch (Exception ex) 
    {
      System.out.println("An exception has occurred: " +  ex.getMessage());
    }
  }

  public static class Response
  {
    public NotificationWebhookResponse Data;
    public Meta Meta;

    public Response() {}
  }

  public static class Meta
  {
    public String ResponseCode;
    public String ErrorMessage;               

    public Meta() {}      
  }

  public static class NotificationWebhookResponse
  {
    public int Id;
    public String Name;
    public String Description;
    public String[] Priorities;
    public int[] OrganizationIds;
    public HashMap<String, String> Headers;
    public String Url;
    public String Language;
    public String SecretKey;
  }

  public static class CreateRequest
  {
    public String Name;
    public String Description;
    public String[] Priorities;
    public int[] OrganizationIds;       
    public HashMap<String, String> Headers;
    public String Url;
    public String Language;

    public CreateRequest() {}

    public void setName(String name) {
      this.Name = name;
    }

    public void setDescription(String description) {
      this.Description = description;
    }

    public void setPriorities(String[] priorities) {
      this.Priorities = priorities;
    }

    public void setOrganizationIds(int[] organizationIds) {
      this.OrganizationIds = organizationIds;
    }

    public void setHeaders(HashMap<String, String> headers) { 
      this.Headers = headers;
    }

    public void setUrl(String url) {
      this.Url = url;
    }

    public void setLanguage(String language) {
      this.Language = language;
    }
  }
}  
curl https://api.pulseway.com/v3/notifications/webhooks \
   -u TOKEN_ID:TOKEN_SECRET \
   -X POST \
   -H "Content-Type: application/json" \
   -d '{"Name": "MyNotificationWebhook1", "Description": "Some Description", "Priorities": ["Low", "Normal", "Elevated", "Critical"], "OrganizationIds": [123, 124], "Headers": { "CustomHeader": "CustomValue" }, "Url": "https://some-webhook-url/test1", "Language": "en"}'

The above command returns JSON structured like this:

{
  "Data": {
    "SecretKey": "88b10925b4224a6abbf2b674ef181a6fb545d33d3aed4d19899454321e019b0b",
    "Id": 101,
    "Name": "MyNotificationWebhook1",
    "Description": "Some Description",
    "Priorities": ["Low", "Normal", "Elevated", "Critical"],
    "OrganizationIds": [123, 124],
    "Headers": { "CustomHeader": "CustomValue" },
    "Url": "https://some-webhook-url/test1",
    "Language": "en",    
    "CreatedAt": "2023-07-26T15:40:31"
  },
  "Meta": {
    "ResponseCode": 200
  }
}   

Creates a Pulseway Notification Webhook.

HTTP Request

https://api.pulseway.com/v3/notifications/webhooks

HTTP Verb

POST

Fields

Name Value Required Description
Name string yes Webhook Name. (maximum 100 characters)
Description string no Webhook Description. (maximum 255 characters)
Priorities array of strings yes List of Notification Priorities that are sent through the Webhook. Available values: Low, Normal, Elevated, Critical
OrganizationIds array of integers no List of Organization IDs used to limit the scope of Notifications. The scope is not limited if Organization IDs are null.
Headers key-value list no List of additional headers sent to the Target URL. (maximum 4000 characters)
Url string yes Webhook Target URL. It should start with “http://” or “https://” protocol. (maximum 2000 characters)
Language string no Language of Notifications title and message send through webhook. Available values: en, de. Default: en

Response Data Fields

Name Value Description
Id string Webhook ID.
Name string Webhook Name.
Description string Webhook Description.
Priorities array of strings List of Notification Priorities that are sent through the Webhook.
OrganizationIds array of integers List of Organization IDs used to limit the scope of Notifications.
Headers key-value list List of additional headers sent to the Target URL.
Url string Webhook Target URL.
Language string Language of Notifications title and message send through webhook.
CreatedAt string Creation date and time.
SecretKey string Key that is used to calculate HMAC SHA-256 signature when sending Notifications to target URL.

Web Hook message Payload

When a notification is created and matches all criteria specified in the webhook, a POST request will be sent to the specified Webhook URL. This request contains the following properties as part of the JSON Body:

Name Value Description
Id int Notification ID.
Title string Notification Message Title.
Message string Text of the Notification Message.
DateTime string Notification creationg date and time in ISO format.
Priority string Notification message priority. Possible values: Low, Normal, Elevated, Critical.
DeviceIdentifier string ID of the device related to the Notification.
OrganizationId string Organization ID of the related device.

The request also contains an x-hmac-signature, which includes a base64 encoded SHA-256 hash based on the JSON body and Secret Key.

Update a Notification Webhook

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class NotificationWebhook < ActiveRestClient::Base
  request_body_type :json

  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'  

  put :update, "/notifications/webhooks/123"
end

begin  
  puts "Update..."  

  @result = NotificationWebhook.update(
    "Name": "MyNotificationWebhook1",
    "Description": "Some Description",
    "Priorities": ["Low", "Normal", "Elevated", "Critical"],
    "OrganizationIds": [123, 124],
    "Headers": { "CustomHeader" => "CustomValue" },
    "Url": "https://some-webhook-url/test1",
    "Language": "en"
  )

  puts @result.Meta['ResponseCode']

rescue Exception => e    
  puts e.message    
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:    
  api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
  result = api.notifications.webhooks(123).put(
  {
    "Name": "MyNotificationWebhook1",
    "Description": "Some Description",
    "Priorities": ["Low", "Normal", "Elevated", "Critical"],
    "OrganizationIds": [123, 124],
    "Headers": { "CustomHeader": "CustomValue" },
    "Url": "https://some-webhook-url/test1",
    "UpdatedAt": "2023-07-26T15:40:31",
    "Language": "en"
  });

  print (result)

except Exception as e:
  print('Update raised an exception.')
  print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";
var webhook_id = 123;

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {  
  data: {
    "Name": "MyNotificationWebhook1",
    "Description": "Some Description",
    "Priorities": ["Low", "Normal", "Elevated", "Critical"],
    "OrganizationIds": [123, 124],
    "Headers": { "CustomHeader": "CustomValue" },
    "Url": "https://some-webhook-url/test1",
    "Language": "en"
  },
  headers: {"Content-Type": "application/json"}
}

client.registerMethod("update", endpoint + "notifications/webhooks" + webhook_id, "PUT");

client.methods.update(args, function (data, response) {  
  console.log(data);  
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON -support_by_pp;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'notifications/webhooks/123';

my $uri = URI->new($endpoint.$query_object);

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $update = {
  'Name' => "MyNotificationWebhook1",
  'Description' => "Some Description",
  'Priorities' => ["Low", "Normal", "Elevated", "Critical"],
  'OrganizationIds' => [123, 124],
  'Headers' => { "CustomHeader" => "CustomValue" },
  'Url' => "https://some-webhook-url/test1",
  'Language' => "en"
};  

my $json = new JSON;
my $data = $json->allow_nonref->pretty->utf8->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->encode($update);

my $client = HTTP::Request->new('PUT', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");
$client->content($data);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
  my $jsonobj = JSON::decode_json($response->decoded_content);

  # Data::Dumper makes it easy to see what the JSON returned actually looks like 
  # when converted into Perl data structures.

  print Dumper($jsonobj->{'Meta'});
  print Dumper($jsonobj->{'Data'});
} else {
  die $response->status_line;
}
<?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

$options = array(
  'object' => 'notifications/webhooks/123'    
);

$updateRequest = array(
  "Name" => "MyNotificationWebhook1",
  "Description" => "Some Description",
  "Priorities" => array("Low", "Normal", "Elevated", "Critical"),
  "OrganizationIds" => array(123, 124),
  "Headers" => array("CustomHeader" => "CustomValue"),
  "Url" => "https://some-webhook-url/test1",
  "Language" => "en"
);

function request($opt, $data) {
  $request = curl_init();
  $data_string = json_encode($data);
  $headers = array(
    'Content-Type: application/json',
    'Content-Length: '.strlen($data_string)
  );

  $url = ENDPOINT . $opt['object'];

  curl_setopt($request, CURLOPT_URL, $url);
  curl_setopt($request, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt($request, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

  $response = curl_exec($request);
  if ($response == FALSE) {
    die('<p>Curl failed: '.curl_error($request).'</p>');
  }

  return $response;
}

try {
  echo "<p>Update</p>";
  $updateResponse = request($options, $updateRequest);
  echo "<p>".$updateResponse."</p></br></br>";
}
catch (Exception $e) {
  echo "<p>'Update' exception: ", $e->getMessage(), "</p></br></br>";
}
?> 
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class Update
    {
        private const string Endpoint = "https://api.pulseway.com/v3/";
        private const string TokenId = "TOKEN_ID";
        private const string TokenSecret = "TOKEN_SECRET";
        private const int WebhookId = 123;

        static void Main(string[] args)
        {
            var client = new RestClient(Endpoint);
            client.Authenticator = new HttpBasicAuthenticator(TokenId, TokenSecret);

            var request = new RestRequest($"notifications/webhooks/{WebhookId}", Method.PUT);            
            request.RequestFormat = DataFormat.Json;
            request.AddBody(GetUpdateRequest());

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }

        private static UpdateRequest GetUpdateRequest()
        {
            UpdateRequest updateRequest = new UpdateRequest()
            { 
              Name = "MyNotificationWebhook1",
              Description = "Some Description",
              Priorities = new [] { "Low", "Normal", "Elevated", "Critical" },
              OrganizationIds => new [] { 123, 124 },
              Headers = new Dictionary<string, string>() {{ "CustomHeader": "CustomValue" }},
              Url = "https://some-webhook-url/test1",
              Language = "en"
            }

            return updateRequest;
        }

        public class UpdateRequest
        {
            public string Name { get; set; }

            public string Description { get; set; }

            public string[] Priorities { get; set; }

            public long[] OrganizationIds { get; set; }

            public Dictionary<string, string> Headers { get; set; }

            public string Url { get; set; }

            public string Language { get; set; }
        }
    }
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class Update 
{ 
  private static final String ENDPOINT = "api.pulseway.com/v3/";
  private static final String TOKEN_ID = "TOKEN_ID";
  private static final String TOKEN_SECRET = "TOKEN_SECRET";
  private static final int WEBHOOK_ID = 123;

  private static UpdateRequest getUpdateRequest()
  {    
    UpdateRequest request = new UpdateRequest();

    request.setName("MyNotificationWebhook1");
    request.setDescription("Some Description");
    request.setPriorities(new String[] { "Low", "Normal", "Elevated", "Critical" });
    request.setOrganizationIds(new int[] { 123, 124 });
    request.setHeaders(new HashMap<String, String>() {{ put("CustomHeader", "CustomValue"); }});
    request.setUrl("https://some-webhook-url/test1");
    request.setLanguage("en");

    return request;
  }

  public static void main(String[] args) 
  {
    try 
    {               
      URIBuilder builder = new URIBuilder();
      builder.setScheme("https").setHost(ENDPOINT).setPath("/notifications/webhooks/" + WEBHOOK_ID);          
      URI uri = builder.build();

      HttpPut request = new HttpPut(uri);      
      request.setHeader("Content-Type", "application/json");

      String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
      request.setHeader("Authorization", "Basic " + auth);

      Gson gson = new Gson();

      UpdateRequest updateRequest = getUpdateRequest();
      StringEntity updateJson = new StringEntity(gson.toJson(updateRequest));

      request.setEntity(updateJson);

      HttpClient httpClient = HttpClients.updateDefault();
      HttpResponse response = httpClient.execute(request);

      HttpEntity httpEntity = response.getEntity();
      String apiOutput = EntityUtils.toString(httpEntity);

      Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

      System.out.println(resp.Meta.ResponseCode);
    }
    catch (Exception ex) 
    {
      System.out.println("An exception has occurred: " +  ex.getMessage());
    }
  }

  public static class Response
  {
    public NotificationWebhookResponse Data;
    public Meta Meta;

    public Response() {}
  }

  public static class Meta
  {
    public String ResponseCode;
    public String ErrorMessage;               

    public Meta() {}      
  }

  public static class NotificationWebhookResponse
  {
    public int Id;
    public String Name;
    public String Description;
    public String[] Priorities;
    public int[] OrganizationIds;
    public HashMap<String, String> Headers;
    public String Url;
    public String Language;
  }

  public static class UpdateRequest
  {
    public String Name;
    public String Description;
    public String[] Priorities;
    public int[] OrganizationIds;
    public HashMap<String, String> Headers;
    public String Url;
    public String Language;

    public UpdateRequest() {}

    public void setName(String name) {
      this.Name = name;
    }

    public void setDescription(String description) {
      this.Description = description;
    }

    public void setPriorities(String[] priorities) {
      this.Priorities = priorities;
    }

    public void setOrganizationIds(int[] organizationIds) {
      this.OrganizationIds = organizationIds;
    }

    public void setHeaders(HashMap<String, String> headers) { 
      this.Headers = headers;
    }

    public void setUrl(String url) {
      this.Url = url;
    }

    public void setLanguage(String language) {
      this.Language = language;
    }
  }
}  
curl https://api.pulseway.com/v3/notifications/webhooks/123 \
   -u TOKEN_ID:TOKEN_SECRET \
   -X PUT \
   -H "Content-Type: application/json" \
   -d '{"Name": "MyNotificationWebhook1", "Description": "Some Description", "Priorities": ["Low", "Normal", "Elevated", "Critical"], "OrganizationIds": [123, 124], "Headers": { "CustomHeader": "CustomValue" }, "Url": "https://some-webhook-url/test1", "Language": "en"}'

The above command returns JSON structured like this:

{
  "Data": {
    "Id": 101,
    "Name": "MyNotificationWebhook1",
    "Description": "Some Description",
    "Priorities": ["Low", "Normal", "Elevated", "Critical"],
    "OrganizationIds": [123, 124],
    "Headers": { "CustomHeader": "CustomValue" },
    "Url": "https://some-webhook-url/test1",
    "Language": "en",
    "UpdatedAt": "2023-07-26T15:40:31"
  },
  "Meta": {
    "ResponseCode": 200
  }
}   

Updates a Pulseway Notification Webhook.

HTTP Request

https://api.pulseway.com/v3/notifications/webhooks

HTTP Verb

PUT

Fields

Name Value Required Description
Name string yes Webhook Name. (maximum 100 characters)
Description string no Webhook Description. (maximum 255 characters)
Priorities array of strings yes List of Notification Priorities that are sent through the Webhook. Available values: Low, Normal, Elevated, Critical
OrganizationIds array of integers no List of Organization IDs used to limit the scope of Notifications. The scope is not limited if Organization IDs are null.
Headers key-value list no List of additional headers sent to the Target URL. (maximum 4000 characters)
Url string yes Webhook Target URL. It should start with “http://” or “https://” protocol. (maximum 2000 characters)
Language string no Language of Notifications title and message send through webhook. Available values: en, de. Default: en

Response Data Fields

Name Value Description
Id string Webhook ID.
Name string Webhook Name.
Description string Webhook Description.
Priorities array of strings List of Notification Priorities that are sent through the Webhook.
OrganizationIds array of integers List of Organization IDs used to limit the scope of Notifications.
Headers key-value list List of additional headers sent to the Target URL.
Url string Webhook Target URL.
Language string Language of Notifications title and message send through webhook.
CreatedAt string Creation date and time.

Re-generate a Notification Webhook Secret Key

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class NotificationWebhook < ActiveRestClient::Base
  request_body_type :json

  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'  

  post :regenerateSecretKey, "/notifications/webhooks/123/regenerateSecretKey"
end

begin  
  puts "Re-generate Secret Key..."  

  @result = NotificationWebhook.regenerateSecretKey()

  puts @result.Meta['ResponseCode']

rescue Exception => e    
  puts e.message    
end
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:    
  api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
  result = api.notifications.webhooks(123).regenerateSecretKey.post();

  print (result)

except Exception as e:
  print('Update raised an exception.')
  print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";
var webhook_id = 123;

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {
  headers: {"Content-Type": "application/json"}
}

client.registerMethod("update", endpoint + "notifications/webhooks" + webhook_id + "/regenerateSecretKey", "POST");

client.methods.update(args, function (data, response) {  
  console.log(data);  
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON -support_by_pp;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $query_object = 'notifications/webhooks/123/regenerateSecretKey';

my $uri = URI->new($endpoint.$query_object);

my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";

my $json = new JSON;

my $client = HTTP::Request->new('POST', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
  my $jsonobj = JSON::decode_json($response->decoded_content);

  # Data::Dumper makes it easy to see what the JSON returned actually looks like 
  # when converted into Perl data structures.

  print Dumper($jsonobj->{'Meta'});
  print Dumper($jsonobj->{'Data'});
} else {
  die $response->status_line;
}
<?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

$options = array(
  'object' => 'notifications/webhooks/123/regenerateSecretKey'
);

function request($opt, $data) {
  $request = curl_init();
  $data_string = json_encode($data);
  $headers = array(
    'Content-Type: application/json',
    'Content-Length: '.strlen($data_string)
  );

  $url = ENDPOINT . $opt['object'];

  curl_setopt($request, CURLOPT_URL, $url);
  curl_setopt($request, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

  $response = curl_exec($request);
  if ($response == FALSE) {
    die('<p>Curl failed: '.curl_error($request).'</p>');
  }

  return $response;
}

try {
  echo "<p>Re-generate Secret Key</p>";
  $secretKeyResponse = request($options);
  echo "<p>".$secretKeyResponse."</p></br></br>";
}
catch (Exception $e) {
  echo "<p>'Re-generate Secret Key' exception: ", $e->getMessage(), "</p></br></br>";
}
?> 
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class ReGenerateSecretKey
    {
        private const string Endpoint = "https://api.pulseway.com/v3/";
        private const string TokenId = "TOKEN_ID";
        private const string TokenSecret = "TOKEN_SECRET";
        private const int WebhookId = 123;

        static void Main(string[] args)
        {
            var client = new RestClient(Endpoint);
            client.Authenticator = new HttpBasicAuthenticator(TokenId, TokenSecret);

            var request = new RestRequest($"notifications/webhooks/{WebhookId}/regenerateSecretKey", Method.POST);
            request.RequestFormat = DataFormat.Json;

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class ReGenerateSecretKey 
{ 
  private static final String ENDPOINT = "api.pulseway.com/v3/";
  private static final String TOKEN_ID = "TOKEN_ID";
  private static final String TOKEN_SECRET = "TOKEN_SECRET";
  private static final int WEBHOOK_ID = 123;

  public static void main(String[] args) 
  {
    try 
    {               
      URIBuilder builder = new URIBuilder();
      builder.setScheme("https").setHost(ENDPOINT).setPath("/notifications/webhooks/" + WEBHOOK_ID + "/regenerateSecretKey");          
      URI uri = builder.build();

      HttpPost request = new HttpPost(uri);      
      request.setHeader("Content-Type", "application/json");

      String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
      request.setHeader("Authorization", "Basic " + auth);

      Gson gson = new Gson();

      HttpClient httpClient = HttpClients.updateDefault();
      HttpResponse response = httpClient.execute(request);

      HttpEntity httpEntity = response.getEntity();
      String apiOutput = EntityUtils.toString(httpEntity);

      Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

      System.out.println(resp.Meta.ResponseCode);
    }
    catch (Exception ex) 
    {
      System.out.println("An exception has occurred: " +  ex.getMessage());
    }
  }

  public static class Response
  {
    public RegenerateSecretKeyResponse Data;
    public Meta Meta;

    public Response() {}
  }

  public static class Meta
  {
    public String ResponseCode;
    public String ErrorMessage;               

    public Meta() {}      
  }

  public static class RegenerateSecretKeyResponse
  {
    public String SecretKey;
  }
}  
curl https://api.pulseway.com/v3/notifications/webhooks/123/regenerateSecretKey \
   -u TOKEN_ID:TOKEN_SECRET \
   -X POST \
   -H "Content-Type: application/json"

The above command returns JSON structured like this:

{
  "Data": {
    "SecretKey": "77b10925b4224a6abbf2b674ef181a6fb545d33d3aed4d19899454321e019b0b"
  },
  "Meta": {
    "ResponseCode": 200
  }
}   

Re-generates a Pulseway Notification Webhook Secret Key. This will cause the previous Secret Key to become outdated, and it will be replaced by a new one in the calculation of the x-hmac-signature header when sending a Notification Message to the Webhook URL.

HTTP Request

https://api.pulseway.com/v3/notifications/webhooks/:id/regenerateSecretKey

HTTP Verb

POST

URL Parameters

Parameter Value Required Description
id string yes Notification Webhook ID

Response Data Fields

Name Value Description
SecretKey string Key that is used to calculate HMAC SHA-256 signature when sending Notifications to target URL.

Delete a Specific Notification Webhook

require 'rubygems'
require 'active_rest_client'
require 'openssl'

silence_warnings do
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class NotificationWebhook < ActiveRestClient::Base
  base_url 'https://api.pulseway.com/v3/'
  username 'TOKEN_ID'
  password 'TOKEN_SECRET'  

  delete :del, "/notifications/webhooks/:id"
end

begin  
  puts "Delete Notification Webhook..."    
  @result = NotificationWebhook.del(2643)
  puts @result.Meta.to_json

rescue Exception => e    
  puts e.message    
end   
import slumber

ENDPOINT = "https://api.pulseway.com/v3/"
TOKEN_ID = "TOKEN_ID"
TOKEN_SECRET = "TOKEN_SECRET"

try:    
  api = slumber.API(ENDPOINT, auth=(TOKEN_ID, TOKEN_SECRET))  
  result = api.notifications/webhooks(2643).delete()
  print (result)

except Exception as e:
  print('DeleteNotificationWebhook raised an exception.')
  print(e.strerror)
var endpoint       = "https://api.pulseway.com/v3/";
var token_id       = "TOKEN_ID";
var token_secret       = "TOKEN_SECRET";

var Client = require('node-rest-client').Client;
var auth = { user: token_id, password: token_secret };

var client = new Client(auth);

var args = {  
  path: { "id": 2643 },
}

client.registerMethod("deleteNotificationWebhook", endpoint + "notifications/webhooks/${id}", "DELETE");

client.methods.deleteNotificationWebhook(args, function (data, response) {
  console.log(data);  
});   
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;   

my $endpoint = 'https://api.pulseway.com/v3/';
my $token_id = "TOKEN_ID";
my $token_secret = "TOKEN_SECRET";
my $id = 2643;

my $uri = URI->new($endpoint.'notifications/webhooks/'.$id);

my $client = HTTP::Request->new( 'DELETE', $uri);

$client->header('Content-Type' => 'application/json' );
$client->authorization_basic("$token_id", "$token_secret");

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
  my $jsonobj = JSON::decode_json($response->decoded_content);

  # Data::Dumper makes it easy to see what the JSON returned actually looks like 
  # when converted into Perl data structures.

  print Dumper($jsonobj->{'Meta'});
  print Dumper($jsonobj->{'Data'});
} else {
  die $response->status_line;
}   
 <?php
const ENDPOINT       = "https://api.pulseway.com/v3/";
const TOKEN_ID       = "TOKEN_ID";
const TOKEN_SECRET       = "TOKEN_SECRET";

const options = array(
  'object' => 'notifications/webhooks',
  'id' => 2643
);

function request($opt) {
  $request = curl_init();
  $headers = array(
    'Content-Type: application/json'        
  );

  $url = ENDPOINT . $opt['object'];
  if (isset($opt['id']))
    $url = ENDPOINT . $opt['object'] . '/' . $opt["id"];

  curl_setopt($request, CURLOPT_URL, $url);
  curl_setopt($request, CURLOPT_CUSTOMREQUEST, "DELETE");
  curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($request, CURLOPT_USERPWD, TOKEN_ID.":".TOKEN_SECRET);

  $response = curl_exec($request);
  if ($response == FALSE) {
    die('<p>Curl failed: '.curl_error($request).'</p>');
  }

  return $response;
}

try {
  echo "<p>Delete Notification Webhook</p>";
  $publishResponse = request(options);
  echo "<p>".$publishResponse."</p></br></br>";
}
catch (Exception $e) {
  echo "<p>'Delete Notification Webhook' exception: ", $e.getMessage(), "</p></br></br>";
}
?>   
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
    class DeleteNotificationWebhook
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3/";
        private const string TOKEN_ID = "TOKEN_ID";
        private const string TOKEN_SECRET = "TOKEN_SECRET";

        static void Main1(string[] args)
        {
            var client = new RestClient(ENDPOINT);
            client.Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET);

            var request = new RestRequest("notifications/webhooks/{id}", Method.DELETE);
            request.AddUrlSegment("id", "2643"); 

            var response = client.Execute(request) as RestResponse;
            var content = response.Content;
            dynamic result = JsonConvert.DeserializeObject(content);
        }
    }
}

package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class DeleteNotificationWebhook { 
  private static final String ENDPOINT = "api.pulseway.com/v3/";
  private static final String TOKEN_ID = "TOKEN_ID";
  private static final String TOKEN_SECRET = "TOKEN_SECRET";
  private static final int ID = 2643;

  public static void main(String[] args) 
  {
    try 
    {               
      URIBuilder builder = new URIBuilder();
      builder.setScheme("https").setHost(ENDPOINT).setPath("/notifications/webhooks/"+ ID);          
      URI uri = builder.build();

      HttpDelete request = new HttpDelete(uri);      
      request.setHeader("Content-Type", "application/json");
      String auth = new String(Base64.encodeBase64((TOKEN_ID + ":" + TOKEN_SECRET).getBytes()), StandardCharsets.UTF_8.toString());
      request.setHeader("Authorization", "Basic " + auth);

      HttpClient httpClient = HttpClients.createDefault();
      HttpResponse response = httpClient.execute(request);

      HttpEntity httpEntity = response.getEntity();
      String apiOutput = EntityUtils.toString(httpEntity);

      Gson gson = new Gson();

      Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

      System.out.println(resp.Meta.ResponseCode);
    }
    catch (Exception ex) 
    {
      System.out.println("An exception has occurred: " +  ex.getMessage());
    }
  }    
  public class Response
  {    
    public Meta Meta;                          
  }         
  public class Meta
  {
    public String ResponseCode;
    public String ErrorMessage;      
  }  
}  
curl -X DELETE https://https://api.pulseway.com/v3/notifications/webhooks/2643 \
     -u TOKEN_ID:TOKEN_SECRET 

The above command returns JSON structured like this:

{
  "Meta": {
    "ResponseCode": 200
  }
}   

Deletes a Specific Notification Webhook.

HTTP Request

https://api.pulseway.com/v3/notifications/webhooks/:id

HTTP Verb

DELETE

URL Parameters

Parameter Value Required Description
id string yes Notification Webhook ID

Errors

Pulseway REST API uses conventional HTTP response codes to indicate success or failure of an API request.

In general, codes in the 2xx range indicate success, codes in the 4xx range indicate a validation error that resulted from provided information (e.g. a required parameter was missing, invalid characters used, etc.), and codes in the 5xx range indicate an error with Pulseway’s servers.

Error Code Meaning
200 OK
400 Bad Request
401 Unauthorized
403 Request Failed
404 Not Found
500 Internal Error
502 Internal Error
503 Internal Error
504 Internal Errors