github.com/monigo-africa/go-monigo) is a thin, zero-dependency wrapper around the Monigo REST API. It follows the same resource-based structure as the REST API and uses functional options for configuration — familiar to anyone who has used the Stripe or Plaid Go SDKs.
Installation
Quick start
Client configuration
Default client
https://api.monigo.co with a standard http.Client and no timeout. For production use, always set a timeout.
Custom HTTP client (recommended)
Custom base URL
For self-hosted deployments or a local development server:Idempotency
Every POST, PUT, and PATCH request to the Monigo API must include anIdempotency-Key header. The SDK handles this automatically — a UUID v4 is generated for each request. To supply your own key (recommended for retryable operations), pass WithIdempotencyKey:
Error handling
All methods return a standarderror. When the API responds with a 4xx or 5xx status, the error is an *APIError with a status code, message, and optional field-level details.
Sentinel helpers
Instead of inspecting status codes manually, use the provided helpers:Events
Theclient.Events service handles usage event ingestion and event replay.
Ingest events
idempotency_key. Sending the same key twice is safe — the second call will appear in resp.Duplicates and won’t be counted again.
A single Ingest call can contain up to 1,000 events.
Replay events
Replay reprocesses all events in a time window through the metering pipeline. This corrects rollups after an outage or after a metric definition change.Customers
Metrics
A metric defines what gets counted (e.g. “API calls”, “GB stored”) and how the raw event values are aggregated.Plans
A plan combines billing period, currency, and one or more prices. Each price links a metric to a pricing model.Pricing models
Plan types and billing periods
Subscriptions
A subscription links a customer to a plan and defines the current billing period.Payout accounts
Payout accounts are bank or mobile-money accounts that a customer can receive payouts to. They are scoped to a customer.Invoices
Invoices are generated from subscriptions and contain line items derived from the customer’s usage in that billing period.All monetary amounts (
Subtotal, VATAmount, Total, UnitPrice) are returned as decimal strings (e.g. "1500.00") to preserve precision across currencies.Usage
Query aggregated usage rollups to see how much a customer has consumed in a period.Portal tokens
Portal tokens grant an end-customer read-only access to their invoices, payout slips, subscriptions, and payout accounts in the Monigo hosted portal. ThePortalURL field of the returned token is what you share with your customer — embed it in an email, redirect the browser, or open it inside an iframe.
Create a portal link
ExpiresAt (RFC3339) for a time-limited link:
List tokens for a customer
customerID accepts either a Monigo UUID or the customer’s ExternalID.
Revoke a token
Wallets
Customer wallets hold prepaid balances. They are the foundation of Prepaid Billing and can also be used for any credit/debit workflow. See the full Wallet Management guide for details.Wallet constants
All wallet amounts (
Balance, ReservedBalance, ledger Amount) are decimal strings to preserve precision.Example programs
The SDK ships with seven runnable example programs underexamples/:
Run any example by setting
MONIGO_API_KEY and executing:
Testing
The SDK has 77 unit tests with zero external dependencies. Each test spins up an in-process mock HTTP server vianet/http/httptest:
WithBaseURL at it:

