Skip to content

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.

When an operation fails, the API returns a JSON object with this shape:

{
"error": {
"code": "<error_code>",
"detail": "<error_message>",
"extraDetail": {}
},
"status": 400,
"ref": "<request_reference>"
}

Each field has a distinct job:

FieldUse it for
error.codeProgrammatic branching in your application.
error.detailLogs, dashboards, and operator-facing messages.
error.extraDetailAny additional context the API includes.
statusThe HTTP status code, repeated in the body.
refSupport follow-up and request tracing.

If you keep only one field beyond the status line, keep ref. It is the quickest way to identify a failing request afterwards.

The exact response set varies by endpoint, but these codes appear throughout the APIs.

Success responses:

CodeMeaning
200The request succeeded and returned a body.
201The resource was created.
202The request was accepted and continues asynchronously.
204The request succeeded with no response body.

Client-side problems:

CodeMeaningWhat to do next
400Bad RequestRecheck the path, query parameters, and body format.
401UnauthorizedRecheck the bearer token and Authorization header.
403ForbiddenRecheck organization, project, and operation access for the token’s user.
404Not FoundRecheck names and path parameters, especially project-scoped names.
409ConflictRecheck the resource state, or whether the operation conflicts with an existing reference.
429Too Many RequestsBack off and retry later. See Rate limits.

Server-side problems:

CodeMeaningWhat to do next
500Internal Server ErrorRetry carefully and keep the ref value.
503Service UnavailableTreat it as temporary and keep the ref value if it persists.

When a request fails:

  1. Record the HTTP status code.
  2. Parse error.code and error.detail.
  3. Record ref.
  4. Decide whether to fix the request, retry it, or surface it to an operator.

As a guide to that decision:

  • 400, 401, 403, and many 404 responses mean the request needs correcting.
  • 409 usually means the operation is valid, but the target resource is not in the right state yet, or is still referenced elsewhere.
  • 429, 500, and 503 are the cases where careful retry logic pays off.

When you debug from the command line, print the transport status alongside the body so a log line captures both:

Terminal window
curl -sS \
-H "Authorization: Bearer <YOUR_TOKEN>" \
-H "Accept: application/json" \
-w "\nHTTP Status: %{http_code}\n" \
"https://app.mk.io/api/v1/projects/<PROJECT_NAME>/media/assets/nonexistent"
© 2026 MediaKind. All rights reserved.