Klarna's APIs use HTTP status codes together with error objects to handle errors. When an API call fails Klarna will respond with a 4xx or 5xx status code together with a response body containing an error object with the error code, an array of error messages and a unique correlation id to be used to identify the request.
The Error object MUST contain an
error_code and an
error_messages property (or
error_codevalue is an
ALL_CAPS_SNAKE_CASEDand enumerable as appropriate per service (e.g.,
INVALID_POSTAL_CODE). The intent of the
error_codeis that it is machine readable and so that you can act properly solely on its value.
error_messagevalue is a human readable English message to aid in debugging. The
error_messageis not meant to be displayable to end-users, nor it is meant to be machine readable. It should be seen as something that the client would log to aid in the debugging, but it's never meant to be in any way parsed by the client. The
error_messageshould not be internationalized. If internationalization of error messages is necessary to show an end user, then it should always be possible to do that on the client side based on the