Quickstart
Go from zero to a paid invoice in a few minutes. This walks through getting a key, making your first call, and taking a real payment.
1. Get an API key
Sign in to your MG Crypto dashboard, open Business → Developers, and create an API key. Keys look like sk_live_… and are shown once at creation — store them somewhere safe.
Keep keys secret
API keys grant full access to your account's payments. Never expose them in client-side code, mobile apps, or public repositories. Use them only from your server.2. Make your first request
Verify your key by reading your balance. Export it as an environment variable so it never lands in your shell history:
A successful response returns your balance in satoshis:
3. Create an invoice
Create an invoice for a USD amount. We convert it to BTC at the live rate and mint a dedicated deposit address. Pass an Idempotency-Key so a retry never double-creates it.
4. Collect the payment
The invoice response includes a hosted pay_url. Redirect your customer there — it shows the amount, a QR code, and the deposit address, and updates itself when the payment confirms. You don't need to build a checkout UI.
5. Confirm and fulfil
Poll the invoice (or list payments) until status is paid, then fulfil the order:
Webhooks are coming
Polling works well today. Outbound webhooks that push a notification the moment an invoice is paid are on the roadmap.