Signing (SDK-HMAC-SHA256)

Every business API request must be signed with this process. A ready-to-run signing script for cURL is in the HTTP API quick start.

Algorithm

FieldValue
AlgorithmSDK-HMAC-SHA256
Date formatYYYYMMDDTHHMMSSZ (UTC)
Date headerX-Sdk-Date
Authorization headerAuthorization: Bearer <base64 of header value>
HashSHA-256

Steps

1. Build the canonical request

CanonicalRequest =
  HTTPMethod + '\n' +
  CanonicalURI + '\n' +
  CanonicalQueryString + '\n' +
  CanonicalHeaders + '\n' +
  SignedHeaders + '\n' +
  HashedRequestPayload

Rules:

  • HTTPMethod: uppercase, such as GET or POST.
  • CanonicalURI: the URL path, with a trailing / added if missing.
  • CanonicalQueryString: sort by decoded key, then re-encode as key=value&.... Follow Python's parse_qs and urlencode(..., doseq=True): drop empty values, keep the order of values for repeated keys, and encode spaces as +.
  • CanonicalHeaders: one lowercase(name):trim(value) line per header, sorted by header name and separated by a single newline. The last line is also followed by a single newline before SignedHeaders.
  • SignedHeaders: the names of the signed headers, lowercase, sorted, and separated by ;.
  • HashedRequestPayload: hex(sha256(body)). If the request has an X-Sdk-Content-Sha256 header, use its value instead.

2. Build the string to sign

StringToSign =
  Algorithm + '\n' +
  RequestDateTime + '\n' +
  hex(sha256(CanonicalRequest))
  • Algorithm is always SDK-HMAC-SHA256.
  • RequestDateTime is the value of X-Sdk-Date.

3. Compute the signature

Signature = hex(HMAC_SHA256(SecretKey, StringToSign))

Encode the SK as UTF-8 bytes and use them directly as the HMAC key.

4. Build the Authorization header

headerValue =
  "SDK-HMAC-SHA256 Access=" + AK +
  ", SignedHeaders=" + signedHeaders +
  ", Signature=" + signatureHex

Authorization = "Bearer " + base64(headerValue)

Minimal Python implementation

import hashlib, hmac, base64, datetime
from urllib.parse import urlparse, parse_qs, urlencode

ALGO = "SDK-HMAC-SHA256"

def _canonical_uri(path):
    if not path or not path.endswith("/"):
        path = (path or "") + "/"
    return path

def _canonical_query(query):
    pairs = sorted(parse_qs(query).items())
    return urlencode(pairs, doseq=True)

def sign(ak, sk, method, url, headers, body=""):
    headers = {k: v for k, v in headers.items()}
    if "X-Sdk-Date" not in headers:
        headers["X-Sdk-Date"] = datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%dT%H%M%SZ")

    low = {k.lower(): v.strip() for k, v in headers.items()}
    signed = sorted(low.keys())
    canonical_headers = "\n".join(f"{k}:{low[k]}" for k in signed)
    signed_str = ";".join(signed)

    u = urlparse(url)
    payload_hash = headers.get("X-Sdk-Content-Sha256") or hashlib.sha256(body.encode()).hexdigest()
    canonical = f"{method}\n{_canonical_uri(u.path)}\n{_canonical_query(u.query)}\n{canonical_headers}\n{signed_str}\n{payload_hash}"
    string_to_sign = f"{ALGO}\n{headers['X-Sdk-Date']}\n{hashlib.sha256(canonical.encode()).hexdigest()}"

    signature = hmac.new(sk.encode(), string_to_sign.encode(), hashlib.sha256).hexdigest()
    header_value = f"{ALGO} Access={ak}, SignedHeaders={signed_str}, Signature={signature}"
    headers["Authorization"] = "Bearer " + base64.b64encode(header_value.encode()).decode()
    return headers

Fixed-input test

Use POST https://wapi-skill.vmake.ai/skill/config.json with the body {"gid":"","supported_schemas":["v2"]} (no trailing newline) and the headers Host: wapi-skill.vmake.ai and Content-Type: application/json. Set the AK and SK to example-ak and example-sk, and add X-Sdk-Date: 20260101T000000Z to the two headers you pass in. The released signer produces the result below, which you can compare locally. Use the current UTC time when you send real requests.

SignedHeaders=content-type;host;x-sdk-date
Signature=9ded9788ce2e0415b77c23cbf46e6a7acc98fb85c0d3ee7645d8e5d759a37de2

Tips

  • If signing fails, check your signer against the fixed input above, then compare the newlines, trailing slash, and query order in CanonicalRequest and StringToSign with the reference implementation character by character.
  • Every header in SignedHeaders must be sent with the request, with the same value used for signing. Compute the signature before adding Authorization.
  • Do not include Content-Length in SignedHeaders. Let the HTTP client handle it.

Next steps