# Integrating without WHMCS This guide is for a reseller whose customer portal and billing are its own software (PHP/Laravel, Python, Node.js, Go, a billing panel, an automation system). WHMCS on your side is **optional**: ServerBike ships WHMCS modules for resellers who use WHMCS, and everything those modules do is available through this public API. ServerBike's own commercial system remains the authority for your wholesale account: products, wholesale prices, your credit, purchases, renewals, escrow and paid-through dates. You never need access to it, to ServerBike's databases, or to the virtualization platform. Your retail prices and your customers' billing are entirely yours. ## What your system must provide | You own | Why | | --- | --- | | Customer accounts and authorization | ServerBike authenticates *you*, not your customers. Check that a customer owns a service before every action you perform for them. | | Retail billing and invoices | ServerBike charges your credit at wholesale price; your prices and invoices are independent. | | A durable order record | Store each `operation_uuid` and its exact request body before sending, and the `service_uuid` you receive. | | A scheduler | Poll lookups after ambiguity, renew on time (when you hold renewal authority), reconcile settlements. | | A secret store | Keep the API secret server-side only. | ## 1. Enrollment (done by ServerBike) ServerBike creates your reseller account and gives you: 1. A **credential ID** and a **one-time secret** (see [`AUTHENTICATION.md`](AUTHENTICATION.md)). 2. Registration of your **public egress addresses** (IPv4 and/or IPv6, exact addresses). Send ServerBike every address your backend uses to reach the API. 3. Registration of your **portal hostname** (an FQDN you control, for example `portal.example.com`). It does not need to run WHMCS. It is used as the default allowed browser `Origin` for the console (`https://portal.example.com`). Additional console origins (another host, a non-default port) are added by ServerBike on request. 4. Your **credit** (prepaid balance or limit), the **products, terms and images** you may buy, any per-reseller **price rules** (fixed override, else percentage discount, else the standard wholesale price) and **purchase limits**. ## 2. First calls ```bash export SB_API_BASE=https://bridge.serverbike.com SB_CREDENTIAL_ID=... SB_SECRET=... # from your secret store python3 examples/python/serverbike_client.py verify # proves credential, clock and source address python3 examples/python/serverbike_client.py account # eligibility and credit balance python3 examples/python/serverbike_client.py catalog # products, terms, wholesale prices, images, capabilities ``` Use the opaque `external_product_ref`, `term_ref` and `image_ref` values exactly as returned. `list_price` (when present) is ServerBike's public price, offered as a reference for your retail pricing; you are never charged it. `capabilities` tell you which customer controls to show (`vps.start`, `vps.stop`, `vps.restart`, `vps.poweroff`, `vps.reinstall`, `vps.changepassword`, `vps.console`). ## 3. Purchase and provisioning 1. Generate a random UUID v4 `operation_uuid`. **Write it and the exact JSON body to your order record first.** 2. `POST /api/v1/purchases` with `{operation_uuid, external_product_ref, term_ref, requested_image_ref}`. 3. `committed` means your credit was debited once and a commercial service exists. Store `business_transaction_ref`, `commercial_service_ref` and `service_uuid` (if not present yet, read it from `GET /api/v1/operations/{operation_uuid}` later). 4. If the response is lost, times out, or is not a Bridge JSON answer: **do not buy again**. Poll `GET /api/v1/operations/{operation_uuid}` until `committed` or `rejected`. 5. Provisioning is automatic. Follow `GET /api/v1/services/{service_uuid}/runtime-state`: `queued`, `authorization_pending`, `provisioning`, `installing` → `running`. Typical Linux delivery takes a few minutes. 6. Reconcile the debit: `GET /api/v1/operations/{operation_uuid}/settlement` returns the recorded amount, currency and transaction reference. If provisioning fails definitively, the debit is refunded once ServerBike has proven that nothing was created (automatically where enabled, otherwise by support); the refund appears in the same settlement as a `credit` transaction. ## 4. Delivering the server to your customer * `GET /api/v1/services/{service_uuid}/guest-access` reports the effective image's OS family and login details. The configured Linux login is `ssh`/`root`/22 and the configured Windows login is `rdp`/`Administrator`/3389. A reinstall updates the projection only after the provider's successful completion is verified. An unresolved reinstall or a historical reinstall without a recorded technical target can return `os_family: "unknown"` and `login: null`. * While `initial_credential.state` is `available`, reveal it once with `POST /api/v1/services/{service_uuid}/access/initial-credential` `{"confirm":true}` and show it to the customer **once** (do not store it). Exactly one call ever gets the password; a lost response consumes it. * A verified password replacement or reinstall supersedes the original password. A reveal already consumed still reports `revealed` in guest access and never returns the plaintext again. * While a replacement is unresolved, an unused initial credential reports `unavailable` with `recovery: null`. Poll the existing operation before choosing a recovery action. A definitive no-effect outcome preserves an unused original credential if it is still valid. * `recovery: password_change` identifies the recovery route when the old password cannot be shown. Use `POST /api/v1/services/{service_uuid}/password` when the product grants `vps.changepassword`, or use the offered recovery options for that service. ## 5. Customer controls | Customer action | Call | Follow with | | --- | --- | --- | | Start / Stop / Restart / Power off | `POST /services/{s}/power/{action}` `{operation_uuid}` | `GET /services/{s}/power/operations/{o}` until `complete` or `failed_*` | | Reinstall | `POST /services/{s}/reinstall` `{operation_uuid, image_ref, new_password}` | `GET /services/{s}/reinstall/operations/{o}` | | Change password | `POST /services/{s}/password` `{operation_uuid, new_password}` | `GET /services/{s}/password/operations/{o}` | | Status and usage | `GET /services/{s}/runtime-state` | — | | History | `GET /services/{s}/activity` | — | | Console | `POST /services/{s}/console-sessions` `{origin}` | see [`CONSOLE.md`](CONSOLE.md) | One runtime action at a time per service. The platform continues restarts and provider-requested power cycles on its own; your polling only observes. Passwords: 16–128 bytes, no control characters; never log them. ## 6. Renewals `GET /api/v1/services/{service_uuid}/commercial` tells you `paid_through` and `renewal.authority`: * `reseller_api` — you renew: `POST /api/v1/renewals` `{operation_uuid, commercial_service_ref, service_uuid, term_ref}` before `paid_through`. The settlement reports the new `paid_through`. * `serverbike_automatic` — ServerBike renews from your credit; API renewals are refused (`409`). Keep enough credit. Your customers' billing cycle is yours; never derive ServerBike's paid-through date from your retail schedule. ## 7. Upgrades (deferred plan change) 1. `GET /api/v1/services/{service_uuid}/commercial` → `plan_change.available` and `targets` (each with the wholesale difference and `qualified`). This is a preview: it reserves nothing. 2. `POST /api/v1/commercial-changes` with the target. ServerBike holds the wholesale difference in escrow. 3. Poll `GET /api/v1/services/{service_uuid}/plan-changes/{operation_uuid}`. When both `activation_ready` and `customer_power_cycle_permitted` are true, ask the customer to shut the server down (Stop or Power off) and start it again. The customer controls power for the upgrade. 4. The platform verifies the new resources, ServerBike captures the held amount exactly once (`completed`), or releases it if nothing was applied (`released`). `operator_review` means ServerBike support decides. 5. Keep the customer on the old retail plan until `completed`. ## 8. Termination `POST /api/v1/commercial-terminations` `{operation_uuid, commercial_service_ref, service_uuid}`. The commercial termination commits first; the server is then deleted by the platform. Follow `runtime-state` to `terminated`. ## 9. Recovery and reconciliation * Keep a list of every open `operation_uuid`. After any outage, poll each one; never resend under a new UUID. * Reconcile money daily: for each committed operation, `GET /operations/{o}/settlement`; compare with `GET /account/commercial` (credit balance). * `reconciliation_required` or `operator_review` that persists for more than an hour: contact ServerBike support with the `operation_uuid` and the `X-Request-Id` of the last response. ## 10. Credential rotation Ask ServerBike for a new credential; both work during a finite overlap. Switch your secret store, verify with `/auth/verify`, then ask ServerBike to revoke the old one. Revocation on request is immediate. ## 11. Limits Production limits per minute: 60 reads, 60 polls, 10 mutations, 10 auth probes, 60 per source address, 60 per credential, 60 per reseller, 10 authentication failures. Poll with backoff (3 s, then up to 30 s). Runtime actions also have per-service hourly limits (12 power actions per hour, 3 reinstalls per hour, 5 password changes per day).