Getting Started - V3 APIS
OpsRamp APIs
Follow these steps to configure your OpsRamp account to use OpsRamp APIs.
Step 1: Install an integration
- In the UI, go to: Setup > Integrations > Integrations.
- Select Available Integrations > Other > Custom Integration.
- Select Install.
- Note down the Key, Secret, API Endpoint from your integration (see examples). You will use these to call APIs:
- Key: x2AqYp2Ym4Wm2EgjWb2X28Estwn2hE58
- Secret: aw6Prm4mk5K5AFmuWfqbyqxcnRMmBnaDV74PvT4sDanb8h3yq9fgEXcGjzbKFrzv
- API Endpoint: https://api.opsramp.com
- Select Save
Step 2: Get an OAuth 2.0 access token
Call the authentication API, using your Key, Secret, and API Endpoint, to get your access token (see example below). Note:
- Use your Key as the OAuth client_id and Secret as the client_secret.
- Use your the OAuth client_credentials grant type.
curl https://api.opsramp.com/tenancy/auth/oauth/token \
-X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-d "grant_type=client_credentials&client_id=M7X9sn7xBpCUsdNAFG7P5UxUjvhJm7Xv&client_secret=UPZPQJVhez6H8cC6kMPzKEmHR7k2ppGPRD8F7d42nvbVYCg9CFqtDGXMUtTUwC7y"
If your API call is successful, you should see a response like the example below:
{
"access_token":"7ae76891-afa1-4d11-aa49-33367238e731",
"token_type":"bearer",
"expires_in":7199,
"scope":"global:manage"
}
Note down the access token (access_token). You will use this call APIs.
Step 3: Note down your Tenant ID
In the UI, go to Setup > Accounts and note down your Tenant ID. Your Tenant ID is a unique identifier of your OpsRamp account and has one of these formats:
- 5878ee58-8c5b-46a8-b975-3754c3c67977
- msp_1234.
Step 4: Call an API
Call an API, using your Access Token and Tenant ID to validate that they work (see example):
curl https://api.opsramp.com/api/v2/tenants/{clientId}/resources \
-X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 7ae76891-afa1-4d11-aa49-33367238e731" \
-d '{
"resourceName": "minimalistic-Generic-Device",
"resourceType": "Linux",
"managementProfile": "TestPro"
}'
Tenancy identifier in path parameter.
The APIs carry a path parameter to authorize the tenancy scope of the endpoint. Following he name of the parameter indicates which tenant scope that the API supports.
{tenantId}
: Supports both partner and client scope.{clientId}
: Supports only client scope.{partnerId}
: Supports only partner scope.
Gateway API's
Follow these steps to obtain the access token to call Gateway APIs.
Step 1: Get the username and password for the Gateway
To use the default username and password
- Login to OpsRamp platform using your credentials.
- In the UI, go to: Setup > Downloads > Gateway.
- On the top of the page find the default username and password for Gateway administrator account.
- Note down
admin
asusername
and copypassword
. You will use this information to call authentication API endpoint.
Step 2: Get an access token
Call the authentication
endpoint POST https://<GatewayIPAddress>:5480/v2/auth/token
to get your access token (see example request payload below).
Note:
- Use
admin
as username and password as copied in the request payload.
{
"username":"admin",
"password":"******",
}
For curl based, the example below.
curl https://<GatewayIPAddress>:5480/v2/auth/token \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"username":"admin","password":"Pass@12345"}'
If your API endpoint call is successful, you should see a response as example below:
{
"token":"7ae76891-afa1-4d11-aa49-33367238e731",
"expires_in":7199
}
Note down the token
value (token). You will use this only for calling Gateway APIs.
Step 3: Call the Gateway API
Call a Gateway API, using your token
value as token <token_value>
in Authorization
header as below to validate that they work (see example):
curl https://<GatewayIPAddress>:5480/v2/gateway/actions/{actionName} \
-X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: token 7ae76891-afa1-4d11-aa49-33367238e731" \
-d '{
"monitService": {
"service": "nginx",
"action": "status"
}
}