Skip to main content

SDK API Reference

Detailed reference for the browser SDK shipped at https://www.mimbla.com/js/sdk.js.

Initialization

const sdk = await Mimbla.init({
clientId: "YOUR_CLIENT_ID", // required
apiBase: "https://www.mimbla.com/api/v1/sdk", // optional override
});

All requests include MB-CLIENT-ID and default to Accept: application/json / Content-Type: application/json.

Mimbla.init preloads enabled cryptos and public rates so sdk.cryptos() and sdk.rates() are ready immediately. If you need a factory without preload, Mimbla.createClient(opts) returns the client without fetching cryptos/rates.

Data helpers

rates()

Returns the cached rates map (e.g., { BTC: { usd: 65998, eur: ... } }) fetched during init().

cryptos()

Returns the enabled cryptos list fetched during init().

Methods

createInvoice(payload)

POST /invoice

FieldTypeNotes
amountnumberRequired; must be >= 10 USD equivalent.
currencystringOptional; default USD. Uses ISO code supported by platform.
cryptostringOptional; ALL (default) or BTC, LTC, BCH, XMR.
due_datestringOptional; m/d/Y, must be today or future.
close_urlstringOptional redirect target when user closes.
redirect_urlstringOptional success redirect target.
automatic_redirectbooleanAuto-redirect after payment.
webhook_urlstringHTTPS URL to receive status updates.

Response includes id (slug), invoice_url, amount, crypto, due_date.

note: popup helpers removed

The SDK no longer includes openInvoice or createInvoiceAndOpen. Use the returned invoice object and open invoice.invoice_url yourself if you need to show the hosted payment page in a new window.

getInvoice(slug)

GET /invoice/{slug}

Returns invoice details including status, amount, crypto, payment (if created), and URLs.

getInvoiceStatus(slug)

GET /invoice/status/{slug}

Returns a compact status payload for quick checks.

requestPayment(slug, body)

POST /invoice/rp/{slug}

FieldTypeNotes
cryptostringRequired when invoice crypto = ALL (one of BTC, LTC, BCH, XMR). Omit when invoice has fixed crypto.

Creates a payment address, amount in crypto, and exchange rates for the selected coin.

Error handling

Errors are thrown as Error with message and optional details (e.g., { status, payload }). Network failures throw Network error.

Environments

  • Production default: https://www.mimbla.com/api/v1/sdk
  • Override per-script with data-api-base or per-client with apiBase in createClient.

Headers used by the SDK

  • MB-CLIENT-ID: your client ID (required)
  • Accept: application/json
  • Content-Type: application/json

Rate limits & best practices

  • Cache the clientId securely; do not expose any private API keys in the browser.
  • For fixed-crypto invoices, omit the crypto field on requestPayment to prevent mismatches.
  • Use pollInvoice for short-lived checkout sessions; for backoffice workflows prefer webhooks plus occasional getInvoiceStatus queries.
  • For checkout flows prefer the hosted page and webhooks; avoid client-side polling in production.