Skip to content
Myra Online Help Updated · 21 Aug 2026

Sending a request to the API using a signature

Note

The following example is a Bash script for Linux. For other operating systems, change the details according to the specific requirements.

For authentication using signatures, we recommend using shell scripts for simple and fast creation of API requests.

In the following examples, we explain how you can create a Bash script for GET and DELETE requests and for POST and PUT requests.

Bash scripts for GET and DELETE requests

To send GET or DELETE requests to the API, you must create a Bash script without BODY and with the following structure:

=== Start ===
#!/bin/bash
set -euo pipefail

=== Credentials ===
API_KEY="<your API key>"
API_SECRET="<your secret>"

=== Request target ===
HOST="https://apiv2.myracloud.com/"
URI="<Path to the resource to be requested, see end points>"
METHOD="<GET or DELETE>"
CONTENT_TYPE="application/json"
BODY=""

=== Date (with colon in timezone, like moment().format()) ===
DATE="$(date +"%Y-%m-%dT%H:%M:%S%:z")"

=== MD5 of body ===
if [[ -z "$BODY" ]]; then
  BODY_MD5="d41d8cd98f00b204e9800998ecf8427e"
else
  BODY_MD5="$(printf '%s' "$BODY" | md5sum | awk '{print $1}')"
fi

=== Signing string ===
SIGNING_STRING="${BODY_MD5}#${METHOD}#${URI}#${CONTENT_TYPE}#${DATE}"

=== Keys (CryptoJS semantics: hex string keys) ===
DATE_KEY_HEX="$(printf '%s' "$DATE" \
  | openssl dgst -sha256 -mac HMAC -macopt key:"MYRA${API_SECRET}" -hex \
  | awk '{print $2}')"      
SIGNING_KEY_HEX="$(printf '%s' "myra-api-request" \
  | openssl dgst -sha256 -mac HMAC -macopt key:"$DATE_KEY_HEX" -hex \
  | awk '{print $2}')"

=== Signature ===
SIGNATURE="$(printf '%s' "$SIGNING_STRING" \
  | openssl dgst -sha512 -mac HMAC -macopt key:"$SIGNING_KEY_HEX" -binary \
  | base64 | tr -d '\n')"

=== Debug (safe) ===
echo "DATE:           $DATE"
echo "SIGNING_STRING: $SIGNING_STRING"
echo "Authorization:  MYRA ${API_KEY}:${SIGNATURE}"

=== Request ===
curl -vvv "${HOST}${URI}" \
  -H "Content-Type: ${CONTENT_TYPE}" \
  -H "Date: ${DATE}" \
  -H "Authorization: MYRA ${API_KEY}:${SIGNATURE}" \
  -X "$METHOD"

Bash scripts for POST and PUT requests

To send POST or PUT requests to the API, you must create a Bash script with BODY and the required object information for the endpoint in it.

=== Start ===
#!/bin/bash
set -euo pipefail

=== Credentials ===
API_KEY="<your API key>"
API_SECRET="<your secret>"

=== Request target ===
HOST="https://apiv2.myracloud.com/"
URI="<Path to the resource to be requested, see end points>"
METHOD="<POST or PUT>"
CONTENT_TYPE="application/json"

=== JSON body with the needed VO object with relevant attributes for the request. ===
BODY='{
        "<attribute1>":"<value>",
        "<attribute2>":"<value>",
        "<attribute3>":"<value>"
      },'

=== Date (with colon in timezone, like moment().format()) ===
DATE="$(date +"%Y-%m-%dT%H:%M:%S%:z")"

=== MD5(body) ===
BODY_MD5="$(printf '%s' "$BODY" | md5sum | awk '{print $1}')"

=== Signing string ===
SIGNING_STRING="${BODY_MD5}#${METHOD}#${URI}#${CONTENT_TYPE}#${DATE}"

=== HMAC (CryptoJS semantics: hex-string keys) ===
DATE_KEY_HEX="$(printf '%s' "$DATE" \
  | openssl dgst -sha256 -mac HMAC -macopt key:"MYRA${API_SECRET}" -hex \
  | awk '{print $2}')"      
SIGNING_KEY_HEX="$(printf '%s' "myra-api-request" \
  | openssl dgst -sha256 -mac HMAC -macopt key:"$DATE_KEY_HEX" -hex \
  | awk '{print $2}')"      
SIGNATURE="$(printf '%s' "$SIGNING_STRING" \
  | openssl dgst -sha512 -mac HMAC -macopt key:"$SIGNING_KEY_HEX" -binary \
  | base64 | tr -d '\n')"

=== Debug ===
echo "DATE:           $DATE"
echo "SIGNING_STRING: $SIGNING_STRING"
echo "Authorization:  MYRA ${API_KEY}:${SIGNATURE}"

=== Request (verbose) ===
curl -vvv "${HOST}${URI}" \
  -H "Content-Type: ${CONTENT_TYPE}" \
  -H "Date: ${DATE}" \
  -H "Authorization: MYRA ${API_KEY}:${SIGNATURE}" \
  --data-binary "$BODY"