Authentifizierung

Geheime Schlüssel, Publishable Keys und die Grenze zwischen Test und Live.

Noch nicht live — api.baynoy.com löst nicht auf, die Beispiele unten laufen heute also nicht. Sie beschreiben den Vertrag, auf den wir hinarbeiten; die Formen auf dieser Seite können sich noch ändern.

Secret keys, server-side only

A secret key (bk_test_ or bk_live_) authenticates your server and can do only what its scopes allow — and never more than the role of the person who created it. There are no publishable keys yet: the customer pays on Baynoy's hosted page, so nothing secret ever needs to reach a browser. If a secret key can reach a browser, it is already compromised.

cURL
# server-to-server: secret key, never in a browser or an app bundle
Authorization: Bearer bk_live_...

Test and live are separate universes

bk_test_ keys operate on simulated money and never touch live data; bk_live_ keys move real money. There is no flag that turns one into the other, which is deliberate — the environments cannot be mixed by accident.

Scopes, signing and rolling

Each key carries the scopes you chose when you made it. Requests that move money (payouts, refunds, card actions, crypto withdrawals) are also signed with the key's signing secret in a Baynoy-Signature header, so a leaked bearer token alone cannot move money. Revoke a key whenever someone leaves or it might have been logged, and make a new one.

Node
import { createHash, createHmac, randomUUID } from "node:crypto";

// The canonical string, line by line — exactly what the API rebuilds.
function sign({ keyId, secret, method, path, query = "", body = "" }) {
  const ts = Math.floor(Date.now() / 1000);
  const nonce = randomUUID();
  const canonical = [
    "BAYNOY-HMAC-SHA256",
    method.toUpperCase(),
    path,                                   // e.g. /v1/payouts
    query,                                  // sorted k=v&k=v, or ""
    createHash("sha256").update(body).digest("hex"),
    String(ts),
    nonce,
  ].join("\n");
  const v1 = createHmac("sha256", secret).update(canonical).digest("hex");
  return `kid=${keyId},ts=${ts},nonce=${nonce},v1=${v1}`;
}