Error Handling response

The body of the general error response follows the basic format shown here.

Field Type Description
message string A description of the error intended for the developer. Provides additional information about the error.
code string A machine readable error code string indicates the problem in general. For a complete list of all error codes visit the error reference.
error_user_title string A short title. When you encounter this you could show the title directly to the user. It will be correctly translated per the locale of the API request.
error_user_msg string A user message. When you encounter this you could show the message directly to the user. It will be correctly translated per the locale of the API request.
violations Array A list of input violation errors.

Invalid JSON

If the JSON sent to the server could not be parsed, a HTTP 400 Bad Request with the appropriate message will be returned.

HTTP 400 Bad Request
{
  "error": {
    "message": "The request content was malformed: Unexpected character '}' at input index 58 (line 4, position 1), expected '\"':\n}\n^\n",
    "code": "InvalidRequestContent",
    "error_user_title": null,
    "error_user_msg": null
  }
}

Invalid Validation

If the JSON itself is valid, but contains invalid or missing data, a HTTP 422 Unprocessable Entity is returned. The body will contain a list of validation errors with a corresponding field error code.

Validation Error format

Field Type Description
message string A description of the error intended for the developer. Provides additional information about the error.
field string The name of the field that was invalid.
code string A machine readable error code string indicates the problem in general. For a complete list of all field error codes visit the error reference.
error_user_msg string A user message. When you encounter this you could show the message directly to the user. It will be correctly translated per the locale of the API request.
HTTP 422 Unprocessable Entity
{
  "error": {
    "error_user_title": "Invalid input",
    "error_user_msg": "One of the request inputs is not valid.",
    "code": "InvalidInput",
    "message": "Validation failed",
    "violations": [
      {
        "code": "InvalidValueField",
        "field": "roles",
        "message": "Invalid value found",
        "user_msg": "The field value was malformed, or its value was invalid for some other reason."
      }
    ]
  }
}

You can find a list of all error-codes here.

Permissions

There are quite a few authorization related errors, but they all use the proper HTTP codes. For more information about authorization in general, visit the Authentication page.

Not Logged In

When trying to access the API without a valid api-token or api-key, you will receive a HTTP 401 Unauthorized.

HTTP 401 Unauthorized
{
  "error": {
    "message": "The provided auth token 'F0SzqBvOeaQTPNSLnRl2qzAD21YHv3Z_' is invalid.",
    "code": "InvalidAuthToken",
    "error_user_title": null,
    "error_user_msg": null
  }
}

No Access

If you try to access a resource you are not authorized for, we will usually return a HTTP 403 Forbidden.

HTTP 403 Forbidden
{
  "error": {
    "message": "Not permitted to act on behalf.",
    "code": "InsufficientPermissions",
    "error_user_title": null,
    "error_user_msg": null
  }
}

Under some circumstances we may also return a HTTP 404 Not Found, in order to conceal the existence of resources from unauthorized access. This will for example happen when requesting a question specific in a network you do not have access for.

HTTP 404 Not Found
{
  "error": {
    "message": "User with id '17304' not found.",
    "code": "ResourceNotFound",
    "error_user_title": "Resource not found",
    "error_user_msg": "The requested operation failed because a resource associated with the request could not be found."
  }
}