The Nebula API lets you remotely manage the security of your endpoints. To use the API, a client credential pair and Account ID are required.
Generate client credentials
To generate the credentials, log into Nebula and go to Integrate.
For more information on APIs, see Nebula API Documentation or hover over the tooltip next to OAuth2 Clients on the Integrate page and click the link.
Retrieve access token
An access token is required for all public API requests. For examples of obtaining an access token with JavaScript or Python, see Nebula API examples.
Below is an example of retrieving an access token using Ruby.
require "uri"
require "net/http"
require "json"
require "base64"
# Replace with the appropriate credentials
# The easy place to get the Account ID is in the URL when accessing
# the Nebula console
client_id = "mwb-cloud-94c08f6443417110b4eab91234567890"
client_secret = "b45222ae73036d5de278debff151f4572f5888d98a31ef41c358011234567890"
account_id = "9aea7003-1234-5678-abcd-123456789012"
credentials = client_id + ":" + client_secret
credentialsEncoded = Base64.strict_encode64(credentials)
url = URI("https://api.malwarebytes.com/oauth2/token")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/x-www-form-urlencoded"
request["Authorization"] = "Basic " + credentialsEncoded
request.body = "grant_type=client_credentials&scope=read"
response = https.request(request)
results = JSON.parse(response.read_body)
token = results["access_token"]
puts token
url2 = URI("https://api.malwarebytes.com/nebula/v1/account")
request2 = Net::HTTP::Get.new(url2)
request2["accountid"] = account_id
request2["Authorization"] = "Bearer " + token
response2 = https.request(request2)
results2 = JSON.parse(response2.read_body)
puts JSON.pretty_generate(results2)