Error handling
The MK.IO APIs return the same error body for every failure. Once your client handles that one shape, the rest of error handling is consistent across the platform: inspect the HTTP status, branch on the machine-readable code, log the human-readable detail, and keep the request reference for follow-up.
The standard error body
When an operation fails, the API returns a JSON object with this shape:
Each field has a distinct job:
If you keep only one field beyond the status line, keep ref. It is the quickest way to identify a failing request afterwards.
Status codes across the platform
The exact response set varies by endpoint, but these codes appear throughout the APIs. Success responses:
Client-side problems:
Server-side problems:
A handling order that works
When a request fails:
Record the HTTP status code.
-
Parse
error.codeanderror.detail. -
Record
ref. -
Decide whether to fix the request, retry it, or surface it to an operator.
As a guide to that decision:
-
400,401,403, and many404responses mean the request needs correcting. -
409usually means the operation is valid, but the target resource is not in the right state yet, or is still referenced elsewhere. -
429,500, and503are the cases where careful retry logic pays off.
See the status and body together
When you debug from the command line, print the transport status alongside the body so a log line captures both: