Authorization

HMAC-SHA256 Authentication

All authenticated endpoints use HMAC-SHA256 signature verification. Each request must include three custom headers that prove your identity and protect against replay attacks.

Required Headers

HeaderDescription
X-Public-KeyYour business public key. Identifies which business is making the request.
X-TimestampCurrent Unix timestamp in seconds. Requests older than 5 minutes are rejected.
X-SignatureHMAC-SHA256 signature of the request (see below).

Generating the Signature

The signature is an HMAC-SHA256 hash of a signing string, using your private key as the secret.
Signing string format:
{timestamp}\n{METHOD}\n{path}\n{body}
ComponentDescriptionExample
timestampSame value sent in X-Timestamp1709836800
METHODUppercase HTTP methodGET
pathFull URI including query string, with leading //api/v1/events?count=5
bodyRaw request body (empty string for GET)(empty)
Components are joined by literal newline characters (\n).

Authentication Errors

StatusCodeDescription
401MISSING_CREDENTIALSOne or more required headers are missing.
401REQUEST_EXPIREDX-Timestamp is more than 5 minutes from server time.
401INVALID_CREDENTIALSPublic key not found, or signature does not match.
403ACCOUNT_INACTIVEBusiness account exists but is not active.

Example Code

PUBLIC_KEY="your-public-key"
PRIVATE_KEY="your-private-key"
TIMESTAMP=$(date +%s)
PATH_URI="/api/v1/events?count=5"

# Build signing string: timestamp\nMETHOD\npath\nbody
SIGNATURE=$(printf '%s\n%s\n%s\n' "$TIMESTAMP" "GET" "$PATH_URI" \
  | openssl dgst -sha256 -hmac "$PRIVATE_KEY" | awk '{print $2}')

curl -H "X-Public-Key: $PUBLIC_KEY" \
     -H "X-Timestamp: $TIMESTAMP" \
     -H "X-Signature: $SIGNATURE" \
     "https://backend.localbusiness.pro$PATH_URI"