Skip to main content

cURL Examples — UnicyFalcon API

Use these examples to test the UnicyFalcon API from the command line.
API access requires the API plan or higher.

1) Bash helper script

Create a reusable script to sign and send requests.

unicyfalcon-api.sh

#!/bin/bash

API_KEY="ak_your_api_key_here"
HMAC_SECRET="your_hmac_secret_here"
BASE_URL="https://your-subdomain.unicyfalcon.com/api/v1"

sign() {
  local method="$1"
  local uri="$2"
  local body="$3"
  local timestamp="$4"

  local payload="${method}|${uri}|${body}|${timestamp}"
  echo -n "$payload" | openssl dgst -sha256 -hmac "$HMAC_SECRET" -binary | base64
}

request() {
  local method="$1"
  local endpoint="$2"
  local body=${3:-""}

  local url="${BASE_URL}${endpoint}"
  local timestamp=$(date +%s)
  local uri="/api/v1${endpoint}"
  local signature=$(sign "$method" "$uri" "$body" "$timestamp")

  if [ "$method" = "GET" ] || [ "$method" = "DELETE" ]; then
    curl -X "$method" "$url" \
      -H "Content-Type: application/json" \
      -H "X-API-Key: $API_KEY" \
      -H "X-Timestamp: $timestamp" \
      -H "X-Signature: $signature"
  else
    curl -X "$method" "$url" \
      -H "Content-Type: application/json" \
      -H "X-API-Key: $API_KEY" \
      -H "X-Timestamp: $timestamp" \
      -H "X-Signature: $signature" \
      -d "$body"
  fi
}

get()    { request "GET" "$1"; }
post()   { request "POST" "$1" "$2"; }
put()    { request "PUT" "$1" "$2"; }
del()    { request "DELETE" "$1"; }

if [ "$#" -lt 2 ]; then
  echo "Usage: $0 <get|post|put|delete> <endpoint> [json-body]"
  exit 1
fi

case "$1" in
  get) get "$2" ;;
  post) post "$2" "$3" ;;
  put) put "$2" "$3" ;;
  delete) del "$2" ;;
esac
Make it executable:
chmod +x unicyfalcon-api.sh

2) Common calls

./unicyfalcon-api.sh get /customers
./unicyfalcon-api.sh get /products
./unicyfalcon-api.sh post /orders '{"customer_id":"uuid","order_number":"ORD-2026-001","order_items":[{"product_id":"uuid","quantity":2,"unit_price":99.99}],"status":"pending","pickup_address_id":"uuid","dropoff_address_id":"uuid"}'

3) Troubleshooting

  • Ensure payload format: METHOD|URI|BODY|TIMESTAMP
  • URI must include /api/v1
  • Timestamp must be within 5 minutes of server time