Rest v2 - Error Codes Question

Hi, we are working on adding error catching to our implementation.

We see that Keap Restv2 documentation has examples for every endpoint and error response as such:

{

  • “code”: 0,

  • “message”: “string”,

  • “status”: “string”,

  • “details”: [

    • {

      • “domain”: “string”,
      • “resource”: “string”

      }

    ]

}

So if the response was a 400, does the code come back as 400? Or are there different internal codes set inside of Keap? If so is there a list of internal error codes?

The response doesn’t actually come back with code 0 every time does it?

Just wanted to get some clarification on how to interpret the documentation.

Hi,

The code field may vary depending on the specific error and should not be assumed to match the HTTP status code. In some cases (such as 400 or 401 responses), the actual response body may differ from the example shown in the documentation.

For determining the type of error, I recommend relying on the HTTP response status code itself rather than the status or code fields in the response body. The body contents can vary depending on the endpoint and error condition, whereas the HTTP status code is the most consistent indicator of the result.

Sorry, what do you mean by “the actual response body may differ from the example shown in the documentation.” Do you mean it won’t always appear in same format like in the example?

The documentation regarding errors is very barebones. It will probably be at the bottom of Keap’s To Do list but it may be a good idea to update it at some point. I’m sure others will have the same question as me eventually.

Thanks.

Yes, an example I can think of right now is 401, the response format for that type of error is different from the example shown in the docs. The long-term plan is to further unify and standardize the error format across our APIs in future iterations.

Ok thank you for letting us know, I’ll let my team know to check that case out.

It will be a good idea to update the official docs now when you have a chance. Thanks.