Errors
Every response has the same envelope. A failure carries a stable code you can branch on and a message written for a person.
The envelope
A successful response puts the result in data:
A failure puts the reason in error:
error.codeis stable. Branch on it, never on the message.error.messageis for people and logs. It can change.error.detailsis present on some errors and holds facts about the refusal, such asearliest_effective_atoneffective_at_too_soon._agentis a short plain-language summary of what happened, for AI agents calling the API.warningsis worth logging: it is where the API says a secret will not be shown again.
Money in any response is a string of whole minor units, such as "1999".
Status codes
| Status | Meaning |
|---|---|
200, 201, 202 | Done, created, or accepted to be processed shortly. |
400 | The request cannot be read: the body is not valid JSON, or something required is missing, such as a required Idempotency-Key. |
401 | No valid key or session. |
402 | Your workspace is over its GlobalyMint plan's monthly billed-volume limit, so new live subscriptions are paused until it upgrades. |
403 | The key or role is not allowed to do this. |
404 | No such route or resource in this workspace and mode. |
409 | The request conflicts with the current state. |
422 | The request was understood and refused. |
413 | The request body is too large. |
415 | The Content-Type is not supported. Send application/json. |
429 | Too many requests. Wait for Retry-After seconds. |
500 | Our fault. Safe to retry with the same idempotency key. |
Common codes
| Code | Status | What to do |
|---|---|---|
unauthorized | 401 | Send a valid key. Check that it is not revoked or expired, and that it matches the mode you expect. |
forbidden | 403 | The message names the missing scope or role. See Scopes. |
tenant_suspended | 403 | The workspace is suspended. Contact us. |
not_found | 404 | Check the id and the mode. A test key cannot see live data. |
validation_failed | 422 | The message starts with the field that failed. |
unprocessable | 422 | The request is well formed but cannot be carried out; the message says why. |
conflict | 409 | The thing already exists, or the same reference was used with different values. |
invalid_transition | 409 | The resource is not in a state that allows this, such as voiding a paid invoice. |
idempotency_key_required | 400 | Add an Idempotency-Key header. See Idempotency. |
idempotency_key_reused | 409 | The key was used before with a different body. Use a new key for a new operation. |
idempotency_in_progress | 409 | The first request with this key is still running. Retry shortly with the same key. |
idempotency_outcome_unknown | 409 | The first request with this key started over 2 hours ago and never finished. Check whether it took effect; if not, retry with a new key. See Idempotency. |
idempotency_key_invalid | 400 | The key starts with the reserved prefix internal:. Choose another key. |
invalid_json | 400 | The body is not valid JSON. |
payload_too_large | 413 | The body is too large. |
unsupported_media_type | 415 | The Content-Type is not supported. Send application/json. |
rate_limited | 429 | Wait for Retry-After seconds. See Rate limits. |
internal_error | 500 | Retry. If it continues, send us the request id. |
Some operations have their own codes. The ones you are most likely to meet:
| Code | Status | When |
|---|---|---|
gateway_not_configured | 422 | No Stripe credentials are saved for this mode. |
currency_locked | 409 | A customer's currency cannot change once they have been billed. |
invoice_already_paid | 409 | A payment was recorded on an invoice that is already settled. |
amount_mismatch | 422 | A recorded payment is not exactly the amount due. |
currency_mismatch | 422 | A one-off invoice names a currency that is not the customer's. |
plan_not_one_time | 422 | A one-off invoice line names a recurring plan. |
promotion_code_invalid | 422 | The promotion code does not apply. |
items_locked | 422 | A checkout created with lock_items was asked to change its items. |
change_not_allowed | 422 | The product's portal settings do not allow this change. |
session_closed | 409 | The checkout session is complete or expired. |
payment_method_not_ready | 422 | The payment method has not been confirmed yet. |
effective_at_too_soon | 422 | A price change must be at least 30 days away. |
plan_limit_reached | 402 | A new live subscription was refused because your workspace is over its plan's billed-volume limit and the grace period has ended. Existing subscriptions keep renewing; test mode is never refused. Upgrade under Settings › Plan and billing. |
not_replayable | 422 | A webhook delivery cannot be replayed: the endpoint is disabled (enable it first), it was a test event, or the event is older than 30 days. |
insufficient_credits | 409 | The customer's credit pool cannot cover the amount. |
Check a request without running it
Many write endpoints accept ?dry_run=true. The body is validated and nothing is executed; a valid request answers 200 with { "dry_run": true, "valid": true }, and an invalid one answers 422 as usual. An endpoint that does not support it ignores the parameter and runs the request, so try it in test mode first.
In the SDK
Every error extends MintError, which has code and message.
| Class | When |
|---|---|
MintApiError | Any non-2xx response. Has status, code, message, requestId and details. |
AuthenticationError | 401 |
ForbiddenError | 403 |
NotFoundError | 404 |
ValidationError | 400 and 422 |
InsufficientCreditsError | 409 insufficient_credits |
RateLimitError | 429. Has retryAfterSeconds. |
MintConnectionError | No HTTP answer: a network error or a timeout. |
PlanLimitError | Thrown by Entitlements#assert, never by the network. |
WebhookVerificationError | A webhook failed verification. |