Errors
Error types, HTTP status codes, and how the SDK reports them.
Error responses
Every error is JSON with a type, a readable message that says what to do, and param when one field is at fault. Messages are written to be shown to a developer or read by an agent as they are.
Response
{
"error": {
"type": "invalid_request",
"message": "unit_amount must be at least 50.",
"param": "unit_amount"
}
}Types and status codes
| Status | type | Means |
|---|---|---|
| 400 | invalid_request | A field is missing or wrong. param names it. |
| 401 | authentication | No key, a revoked key, an expired sandbox, or a test key on the live API (or the other way round). |
| 402 | processor | Stripe or PayPal refused or failed, for example on a refund. (402, not 502, so the body always reaches you.) |
| 403 | forbidden | Not allowed: a read-only key making a change, view-only team access, Munim Autopilot Pricing not turned on, or a step only a person can do. |
| 404 | not_found | No such object, or no such endpoint. The message says which. |
| 409 | conflict | The object's state doesn't allow it: refunding a disputed payment, claiming a sandbox twice, or connecting the same database again. |
| 413 | too_large | An export over 50,000 rows. Narrow the dates or make a report. |
| 429 | rate_limited | Too many at once, for example sandboxes from one address, or five reports already building. Try again later. |
| 500 | internal | Something broke on our side. Safe to retry reads; email [email protected] if it keeps happening. |
In the SDK
Every failure throws a MunimBillingError with type, status (null when there was no response), param and message. Its type is one of invalid_request, authentication (also used for 403), not_found, conflict, processor, internal, connection (network failure or timeout; the default timeout is 30 seconds) and signature_verification (a webhook that didn’t verify).
Node
import { MunimBilling, MunimBillingError } from 'munim-billing'
try {
await munim.transactions.refund('txn_…')
} catch (err) {
if (err instanceof MunimBillingError) {
console.log(err.type, err.status, err.param, err.message)
if (err.type === 'processor') {
// Stripe or PayPal said no: retry later or tell the person
}
}
throw err
}Common mistakes
| Message | Fix |
|---|---|
| Munim Billing secret keys start with mb_test_sk_ or mb_live_sk_ | You passed another key (perhaps a Stripe one). Create a key in the dashboard. |
| MunimBilling uses your secret key and must run on your server | You created the client in a browser or an app. Create checkouts on your server and send only the url to the client. |
| Webhook signature does not match | Verify the raw request body, not JSON.stringify(req.body), with that endpoint's secret from the right mode. |
| Webhook timestamp is outside the tolerance | Your server's clock is off, or you're replaying an old delivery. |
| Web Crypto (crypto.subtle) is not available | Use Node 20 or newer. |
| This sandbox expired because nobody claimed it | Make a new sandbox, or sign in with an email. |