2xx means the request worked, with one exception: POST /v1/usage_events answers 207 when some events were stored and others rejected, so read its results. A 4xx means something in the request needs fixing. A 5xx means something went wrong on our side.
Error format
Every error has the same shape.Error types
Error codes
Authentication and permission
Invalid requests
Unit changes
Unit change errors are422, and param names the field. The code is one of these.
A change can also be refused when
document is sent before the renewal invoice exists, or names a choice that isn’t available, such as amend for an invoice that can no longer be changed. The error message says why. See Change units.
Not found
Conflicts
Server errors
New codes can be added to any family. Handle the ones you care about, and treat the rest by their status.