# Authentication: BRIDGE-HMAC-SHA256-V1 Every request to the ServerBike Reseller Public API is signed with your credential and must come from one of your registered public egress addresses. The protocol is frozen: implementations in any language must produce exactly the bytes described here. Runnable signers with known-answer vectors are in [`examples/`](examples/). ## 1. Your credential ServerBike issues two values once, over a secure channel: | Value | Format | Use | | --- | --- | --- | | Credential ID | opaque string, e.g. `rescred_...` | Sent in `X-Reseller-Credential-Id`. Not secret. | | Secret | 43 characters, unpadded base64url (`A-Z a-z 0-9 - _`) | Decode to **32 raw bytes**; those bytes are the HMAC key. | Decode strictly: the 43 characters must decode to exactly 32 bytes and re-encode to the same 43 characters. Store the secret in your backend's secret store (never in a browser, a mobile app, logs, tickets or source control). ServerBike cannot show an issued secret again; rotation issues a new credential with a finite overlap, and a compromised credential is revoked immediately on request. ## 2. Headers Send exactly one value for each header: | Header | Value | | --- | --- | | `X-Reseller-Credential-Id` | Your credential ID. | | `X-Request-Timestamp` | Unix time in seconds, decimal ASCII, no sign, no leading zeros. Accepted within ±300 s of ServerBike's clock (keep NTP running). | | `X-Request-Nonce` | 16 fresh random bytes as **22** unpadded base64url characters. Never reuse a nonce. | | `X-Request-Signature` | `v1=` followed by 64 lowercase hex characters (the HMAC). | Do not send `Content-Encoding` other than absent or `identity`. Send `Accept-Encoding: identity`. ## 3. The signed message Join these eight fields with a single LF (`0x0A`) and **no trailing LF**: ```text BRIDGE-HMAC-SHA256-V1 reseller-public <"-" if the target has no "?", otherwise "?" + the exact raw bytes after the first "?"> ``` * `METHOD` is the uppercase method you send (`GET`, `POST`). * The raw path and query are the exact bytes you put on the request line — no decoding, re-encoding, sorting or normalization. Sign the target you send; send the target you signed. * The body hash covers the exact body bytes on the wire. An empty body hashes to `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`. Never re-serialize JSON after signing. `X-Request-Signature = "v1=" + hex(HMAC-SHA256(key = 32 secret bytes, message = the bytes above))`. ## 4. Known-answer vectors (synthetic material) Secret wire `AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8` (bytes `00..1f`), timestamp `1787850000`, nonce `AAECAwQFBgcICQoLDA0ODw`: | Method | Target | Body | Signature | | --- | --- | --- | --- | | GET | `/api/v1/auth/verify` | empty | `v1=52ab049c2545d42eb9e25914a788659902bff5fb77e39d765c1a69213ec37ab7` | | GET | `/api/v1/catalog?limit=10` | empty | `v1=0511cf41afda8fcb12aff4a3d6f62624e9da4e17883d23841bc19f9a53e03753` | | POST | `/api/v1/purchases` | `{"operation_uuid":"0b7f6f1e-2c3d-4e5f-8a9b-0c1d2e3f4a5b","external_product_ref":"prd_example","term_ref":"term:monthly","requested_image_ref":"ubuntu-24.04"}` | `v1=e4e7c68e303138604000c7ed285c0a1cb3fb512dee1036baac1a0754be20077b` | | POST | `/api/v1/services/123/actions?b=2&a=1&a=0` | `{"action":"restart"}` | `v1=e8f8836f29cbd8f993469f2b5ed4d7f52609250f6bd437979f104228fc14e2ca` | | GET | `/api/v1/test` | empty | `v1=68d54a7c424ecdeae0209e2823878a52c7bfe33ce3f79c9ece417ea078a59e15` | [`examples/vectors.json`](examples/vectors.json) also holds each canonical message. The Python, Node.js, PHP and Go examples, and ServerBike's own verifier, all reproduce these values. (The last two are the original V1 vectors.) ## 5. Source addresses ServerBike admits signed requests only from the public IPv4 and/or IPv6 addresses registered for your account (1–16 exact addresses; no ranges). Register every address your backend can leave from: * If your server has IPv6 and the API hostname has an IPv6 address, your connection may use IPv6 — register both families, or make sure your client prefers the family you registered. * NAT, cloud egress gateways and changing outbound addresses must be registered before you use them. * An outer ingress `403` stops the request before Bridge sees it or processes its nonce. A valid signature that reaches Bridge and fails the reseller's exact source-IP policy receives `401` after its nonce was claimed. * An invalid signature, expired timestamp or unrecognized credential fails before a fresh nonce is claimed. A replay is refused because that nonce was already claimed. Use fresh signing material for every attempt. ## 6. Replay and retries A nonce is accepted once, for the life of its timestamp window. Every attempt — including a retry of the same business operation — needs a new timestamp, a new nonce and a new signature. The business identity of a retry is the `operation_uuid` inside the body, not the nonce. See [`RETRY_AND_ERRORS.md`](RETRY_AND_ERRORS.md). ## 7. Transport requirements * HTTPS only, TLS 1.2 or newer, certificate and hostname verification always on. * Do not follow redirects; a redirect is an error. * Do not send API calls through a forward proxy that may rewrite requests. * Expect `Content-Type: application/json` and no `Content-Encoding`; treat anything else as a transport failure.