API Documentation in InsightCloudSec
Welcome to the InsightCloudSec API documentation! Here you can learn how to interact with InsightCloudSec programmatically, enabling you to securely and simply automate your daily and/or most tedious workflows within the product.
- All endpoints can be used but we caution the use of
prototype
-namespaced endpoints as documentation and support may vary. - Contact us through the Customer Support Portal if you have any questions or concerns.
InsightCloudSec has three API specification files. The endpoints are organized by an arbitrary versioning; there's no relevant correlation to the endpoints that are available in each file. You can access the API documentation via the links below:
API Documentation Tips
This API documentation is currently offered “as-is” and as such we want to provide the following recommendations:
- If you are not familiar with our API or are working with these capabilities for the first time, we strongly recommend that you coordinate with your CSM or our support team. We make this recommendation because some use cases may require additional clarification and we are here to help. Working with us directly will ensure that you are able to use our API effectively for whatever goals you have.
- As part of our commitment to a great customer experience, we are actively working on productizing our API. This includes outlining a hardened and repeatable standard for future endpoints and identifying common/high-impact use cases for verification and possibly revision/versioning.
- Where possible, there are example requests and responses for the documented endpoints. See Working With Examples for more information.
If you have questions or concerns regarding the content here, or need support using our API reach out to us through the Customer Support Portal.
Using the API Docs
Below the name and short description for each endpoint, there are three sections:
- Security -- the security scheme (or authentication method) available for the endpoint
- Review Authentication for more information
- Request -- list of request parameters organized by type (path, body, query, and header)
- Most endpoints should have a description and type for each parameter as well as indicate if it's required for the request.
- If the parameter is an object and contains additional nested parameters, click the parameter name to expose the additional parameters.
- If the parameter has a default value, it will be displayed.
- Responses -- list of possible response schemas grouped by response code
- Each endpoint should have at least one response code associated with it.
- If there's a response schema associated with a particular response code, click the code to expand the schema.
To the right of the request/responses section are the endpoint URL and method as well as request and response samples. Each endpoint should have at least one request and response sample; we update samples as often as we are able but not every endpoint will have content.
- If there are multiple samples, use the drop-down menu to select an available sample.
- Click Copy to copy the sample
- Click Expand All / Collapse All to expand or collapse objects within the sample
User Type Affects Access
Remember that only certain types of InsightCloudSec users have access to all endpoints documented. Verify your user type and the endpoint description before testing anything out. See Users, Groups, and Roles for more information on InsightCloudSec Identity Management.
Authentication
There are currently two methods of authenticating when using the InsightCloudSec API:
- API Key -- The API Key is the preferred method of authentication. An active API key allows the user to programmatically access InsightCloudSec. API Keys can be associated with all types of InsightCloudSec user accounts, e.g., basic users, domain admins, etc.; you can even have an API-only user. See API Key Authentication for an example.
- Auth Token -- Auth tokens are generated using the Login endpoint in conjunction with a user's username and password. The token can then be passed to subsequent endpoints to allow the user to programmatically access InsightCloudSec. Tokens are available per session, so after the user is logged out of the product for whatever reason, they must generate a new token. See Auth Token Authentication for an example. InsightCloudSec highly recommends using the API Key authentication method instead.
Single Sign On (SSO) Users
If you're a customer that uses SSO to login to InsightCloudSec, we advise that you interact with the API using an API key, especially if you only want to create workflow automation scripts or you are planning to utilize API-only flows.
API Key Authentication
API Key Authentication
The InsightCloudSec API allows authentication via an API key that is explicitly passed in the header of a request. You can obtain an API key using the InsightCloudSec user interface or using the API with an existing user's ID. Any existing API key for a user will be deactivated upon generating a new API key. Below are examples of how you can use an API key with Python or Bash/cURL. This example lists all of the organizations inside InsightCloudSec.
Python example
python
1# Script to list all organizations in InsightCloudSec using an API Key23import json4import requests5import getpass67requests.packages.urllib3.disable_warnings() # verify=False throws warnings otherwise89# API Key10api_key = ''1112# API URL13base_url = ''1415# Param validation16if not api_key:17key = getpass.getpass('API Key:')18else:19key = api_key2021if not base_url:22base_url = input('Base URL (EX: http://localhost:8001 or http://45.59.252.4:8001): ')2324headers = {25'Content-Type': 'application/json;charset=UTF-8',26'Accept': 'application/json',27'Api-Key': key28}2930# Get Org info31def get_org():32data = {}33response = requests.get(34url = base_url + '/v2/prototype/domain/organizations/detail/get',35data = json.dumps(data),36verify = False,37headers = headers38)39return response.json()4041# Execute functions42org_info = get_org()43print(org_info)
Bash/cURL example
curl
1# API key to authenticate against the API2api_key=""3# DivvyCloud URL EX: http://localhost:8001 or http://45.59.252.4:80014base_url=""5# Get org info6org_url=`echo $base_url/v2/prototype/domain/organizations/detail/get`7curl \8--request GET \9--header "content-type: application/json" \10--header "accept-encoding: gzip" \11--header "Api-Key: $api_key" \12$org_url | gunzip | jq1314# Example output:15# {16# "organizations": [17# {18# "status": "ok",19# "smtp_configured": true,20# "clouds": 63,21# "name": "DivvyCloud Demo",22# "resource_id": "divvyorganization:1",23# "organization_id": 1,24# "bots": 17,25# "users": 2126# }27# ]28# }
Auth Token Authentication
Auth Token Authentication
Endpoints are authenticated via auth token when a user's session ID is passed in the header of a request. You can obtain this session ID from the object returned upon successfully using the Login endpoint with your InsightCloudSec username and password. If the session expires or the user logs out, the auth token will no longer be valid and the user will have to start a new session/generate a new session ID. InsightCloudSec highly recommends using the API Key authentication method instead.
Below is a example of how you can use the API with an auth token using Python. This example lists all of the organizations inside InsightCloudSec.
Python example
python
1# Script to list all organizations in InsightCloudSec using an Auth Token23import json4import requests5import getpass67requests.packages.urllib3.disable_warnings() # verify=False throws warnings otherwise89# Username & password10username = ''11password = ''1213# API URL14base_url = ''1516# Param validation17if not username:18username = input('InsightCloudSec username: ')1920if not password:21password = getpass.getpass('Password: ')22else:23password = password2425if not base_url:26base_url = input('Base URL (EX: http://localhost:8001 or http://45.59.252.4:8001): ')2728headers = {29'Content-Type': 'text/plain',30'Accept': 'application/json'31}3233# Get auth token34def get_token():35data = {36'username': username,37'password': password38}39print(data)40response = requests.request(41method = 'POST',42url = base_url + '/v2/public/user/login',43json = data,44verify = False,45headers = headers46)47headers['x-auth-token'] = response.json().get('session_id')4849# Get Org info50def get_org():51data = {}52response = requests.get(53url = base_url + '/v2/prototype/domain/organizations/detail/get',54data = json.dumps(data),55verify = False,56headers = headers57)58return response.json()5960# Execute functions61get_token()62org_info = get_org()63print(org_info)