Postman collection for accessing Ninja RMM APIs using the custom authentication headers.
The Ninja authentication requirement doesn't easily lend itself to the more traditional authorization options found in API client tools such as Postman or Insomnia.
The NinjaRMM REST API uses a custom HTTP scheme based on a keyed-HMAC (Hash Message Authentication Code) for authentication. To authenticate a request, you first concatenate selected elements of the request to form a string. You then use your API secret access key to calculate the HMAC of that string.
This project is an attempt to eliminate this pain-point, and provides a Postman pre-script option to build the required auth headers based on your Ninja api keys.
The easiest method to get started with this project is to launch the Run in Postman button
below. The collection contains the latest Ninja Api 2.0 yaml definitions at the time of this post.
You must update the Collection variables with your own API Keys!
You can also download the Collection export directly, or the pre-script file if that's all you need.
These are the Postman variables you will need to configure:
- baseUrl - defaults to https://app.ninjarmm.com/
- ninja_accessKeyId
- ninja_secretAccessKey
The access keys can be found in your main NinjaRMM portal, under Configuration -> Integrations -> API
Variables allow you to store and reuse values in your requests and scripts. This script will use variables defined at the Global, Collection, Environment, or Local scopes. They Ninja keys are defaulted to the sample values used in their documentation.
To edit a variable for this collection, select the collection in Collections on the left of the Postman app, open the View more actions (...) menu, and click Edit.
Postman provides a runtime based on Node.js that allows to add dynamic behavior to requests.
The pm-ninja-pre-request
script retrieves the key variables and constructs the authentication and date header for each request.
The script includes comments that should give enough details for each step used in construct & sign the request signature needed. The Ninja resource that provides the example code for signing requests can be found the ref's below.
If you found this helpful...
Ninja API Authentication
Ninja API 2.0 docs
Postman Download
Postman pre-request scripts
Postman sandbox - script refs