Skip to main content
Skip table of contents

Access the Armor API System via an API token - BASH

You can use the API tokenization feature (BASH) in the Armor Management Portal (AMP) to create an API key. This key will help you log into the Armor API system.


Step 1: Create an API key

When you create an API Key, you will generate a Secret Key. This key does not expire; you must securely store this key because Armor cannot retrieve this key for you. 

If you lose the Secret Key, then you must delete the corresponding API Key in AMP. Afterwards, you must create a new API Key.

Armor cannot retrieve your Secret Key.

  1. In the Armor Management Portal (AMP), in the left-side navigation, click Account

  2. Click Users

  3. Click API Keys

  4. Click the plus icon. 

  5. Enter a descriptive name, and then click Create Key

  6. Copy the Key ID and Secret Key

  7. Click Close

  8. The API Keys table will display a new entry.


Step 2: Authenticate into the Armor API system

To authenticate, you need to build a header with the following components:

Parameter

Description

app_id

Enter the Key ID generated from AMP.

secret_key

Enter the Secret Key generated from AMP.

request_path


http_method

Enter POST.

timestamp

Enter a Unix time stamp within 5 minutes of the current time.

nonce

Enter a unique ID.

  • This ID should be unique per request.

  • This ID cannot be longer than 128 characters.

  • This ID cannot contain a colon ( : ).


For all v2 API's, the request body should be empty.

This uses a bash script with the assumption the following commands are installed uuidgenopensslbase64, and curl

The script is called with `./script "{apiKey}" "{secret}"


Review sample code for BASH:

CODE
#!/bin/bash
 
 
 
apikey=$1
printf "\n  API KEY: $apikey"
 
secret=$2
# don't print secret
#printf "\n Secret: $secret"
 
authType="ARMOR-PSK"
printf "\n authType: $authType"
 
httpMethod="GET"
printf "\n Method: $httpMethod"
 
timestamp=$(date +%s)
printf "\n timestamp: $timestamp"
 
nonce=$(uuidgen)
printf "\n nonce: $nonce"
 
# Only the path portion of the url, no https, host, port, or query string values
requestPath="/core/avam"
requestBase="https://api.armor.com"
printf "\n requestPath: $requestPath"
 
# Empty string for GET
requestBody=""
 
requestData="${apikey}${httpMethod}${requestPath}${nonce}${timestamp}${requestBody}"
printf "\n requestData: $requestData"
 
# openssl needs the binary option
# set line wrapping to 0 to force base64 output on one line
signature=$(echo -n "$requestData" | openssl dgst -sha512 -hmac "$secret" -binary | base64 -w 0)
printf "\n Mac: $mac"
 
authHeaderValue="${authType} ${apikey}:${signature}:${nonce}:${timestamp}"
printf "\n authHeaderValue: $authHeaderValue \n"
echo '========================================================================'
echo ''
 
 
#Options are before the URL
curl -v \
     --location \
     -H "Authorization: ${authHeaderValue}" \
     -H 'Content-Type: application/json' \
     --request $httpMethod \
     "${requestBase}${requestPath}"



Step 3: Make an API Call

To learn about the different calls that you can make, see Armor API Guide.


Related Documentation



JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.