Errors
Every failure is a GoodchargeError with status, code, details ({ path, message }[]) and retryAfter.
| Status | code | What to do |
|---|---|---|
| 400 | invalid_json | Send valid JSON. |
| 401 | unauthorized | Check or regenerate the key. |
| 409 | not_published | Call publish before updatePoints or heartbeat. |
| 413 | payload_too_large | Keep the body under 64 KB. |
| 422 | invalid_payload | Fix the fields listed in details. |
| 429 | too_many_requests | One request per second per key; retried automatically. |
| 5xx | internal_error | Retried automatically. |
| 0 | timeout, network_error | Retried automatically. |
| 0 | invalid_api_key | The key given to the constructor is malformed. |
| 0 | invalid_option | A constructor or startHeartbeat option is malformed; thrown synchronously, never through a rejected promise. |
| 2xx | invalid_response | goodcharge answered success but the body was not JSON; not retried. |
A 429 or 5xx is retried honouring Retry-After (seconds, or an HTTP-date) when the response carries one; a Retry-After above 60 seconds is not retried — the error is thrown instead, still carrying retryAfter so you can decide yourself whether and when to try again.
A rejected request is also shown on the station page of the portal, with its reason.