1. API-Key erstellen
Loggen Sie sich im Kundenportal unter "Reseller API" ein und erstellen Sie einen Key. Wählen Sie nur die Scopes die Sie tatsächlich brauchen (Standard: lesend). Das Secret wird nur einmal angezeigt, speichern Sie es sicher in Ihrem Secret-Manager.
2. Credentials hinterlegen
Speichern Sie Key und Secret als Umgebungsvariablen, niemals im Code, niemals im Repository.
# .env oder Shell-Profil
export KH_KEY="kh_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
export KH_SECRET="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
3. Erste Anfrage senden
Liste der verfügbaren Produkte abrufen. Die Signatur wird über Methode, Pfad, Timestamp, Nonce und Body-Hash gebildet.
TS=$(date +%s)
NONCE=$(openssl rand -hex 16)
BODY_SHA256=$(printf '' | openssl dgst -sha256 -hex | awk '{print $2}')
SIG_INPUT=$(printf 'GET\n/v1/products\n%s\n%s\n%s' "$TS" "$NONCE" "$BODY_SHA256")
SIG=$(printf '%s' "$SIG_INPUT" | openssl dgst -sha256 -hmac "$KH_SECRET" -hex | awk '{print $2}')
curl https://www.kernelhost.com/cp/kh_reseller_api/v1/products \
-H "KH-Key: $KH_KEY" \
-H "KH-Timestamp: $TS" \
-H "KH-Nonce: $NONCE" \
-H "KH-Signature: $SIG"
4. Bestellung aufgeben
Wichtig: POST /v1/orders erfordert einen Idempotency-Key. Bei Netzwerk-Retry mit demselben Key bekommen Sie dieselbe Response zurück, keine doppelte Bestellung.
BODY='{"product_id":42,"billing_cycle":"monthly"}'
BODY_SHA256=$(printf '%s' "$BODY" | openssl dgst -sha256 -hex | awk '{print $2}')
TS=$(date +%s)
NONCE=$(openssl rand -hex 16)
IDEM=$(openssl rand -hex 16)
SIG_INPUT=$(printf 'POST\n/v1/orders\n%s\n%s\n%s' "$TS" "$NONCE" "$BODY_SHA256")
SIG=$(printf '%s' "$SIG_INPUT" | openssl dgst -sha256 -hmac "$KH_SECRET" -hex | awk '{print $2}')
curl -X POST https://www.kernelhost.com/cp/kh_reseller_api/v1/orders \
-H "KH-Key: $KH_KEY" \
-H "KH-Timestamp: $TS" \
-H "KH-Nonce: $NONCE" \
-H "KH-Signature: $SIG" \
-H "Idempotency-Key: $IDEM" \
-H "Content-Type: application/json" \
--data "$BODY"
5. Webhook einrichten (optional)
Hinterlegen Sie eine HTTPS-URL pro Key um Events asynchron zu empfangen (order.paid, service.provisioned, invoice.created). Die Payload-Signatur folgt dem Stripe-Schema.

