Authentication
Every request is signed with AWS Signature Version 4. There is no bearer token and no session — the signature is computed per request from your access key.
Algorithm
AWS SigV4
Region
ap-southeast-5
Service
sqlaccount
Credentials
Access key IDs issued for SQL Account follow the format <key_id>.sql.my/APIUSER. Use the full string as the access key ID when signing, and keep the secret in an environment variable — never in client-side code.
SQL_ACCOUNT_ACCESS_KEY_ID=<key_id>.sql.my/APIUSER
SQL_ACCOUNT_SECRET_ACCESS_KEY=<secret>Signing a request
Sign the final URL including the query string, then send the generated headers unchanged.
import { SignatureV4 } from "@smithy/signature-v4";
import { Sha256 } from "@aws-crypto/sha256-js";
import { HttpRequest } from "@smithy/protocol-http";
const signer = new SignatureV4({
credentials: {
accessKeyId: process.env.SQL_ACCOUNT_ACCESS_KEY_ID,
secretAccessKey: process.env.SQL_ACCOUNT_SECRET_ACCESS_KEY,
},
region: "ap-southeast-5",
service: "sqlaccount",
sha256: Sha256,
});
async function call(path: string, method: string, body?: unknown) {
const request = new HttpRequest({
protocol: "https:",
hostname: "api.sql.my",
path,
method,
headers: {
"content-type": "application/json",
host: "api.sql.my",
},
body: body ? JSON.stringify(body) : undefined,
});
const signed = await signer.sign(request);
const response = await fetch(`https://${signed.hostname}${signed.path}`, {
method: signed.method,
headers: signed.headers as Record<string, string>,
body: typeof signed.body === "string" ? signed.body : undefined,
});
return response.json();
}
await call("/currency?offset=0", "GET");Rules that cause 401s
- Query parameters must be part of the signed payload. Adding
?offset=0after signing returns 401. - The Host header must match the hostname used in the signature.
- Sending a body on GET changes the payload hash and invalidates the signature.
- Region and service must be exactly
ap-southeast-5andsqlaccount.
Headers
content-type: application/json
host: api.sql.my
x-amz-date: 20260930T074500Z
authorization: AWS4-HMAC-SHA256 Credential=.../ap-southeast-5/sqlaccount/aws4_request, SignedHeaders=..., Signature=...Continue with Base URL & Format to understand response envelopes and pagination.
