Skip to main content
Every SDK method returns three values: the result, the HTTP response, and an error. Check err before you use the result. When err is nil, the result holds the decoded response. When err is set, the result is empty and you should handle the failure.
Only NewClient panics when the base URL is missing. SDK methods return errors for API and validation failures.

What each return value holds

After you confirm err == nil, use the result and optionally log resp.StatusCode.

Core error types

When Core rejects a request, the SDK wraps the failure in *blnkgo.ApiErrorResponse. Use errors.As to read structured fields instead of parsing message text.
The SDK also exports blnkgo.AsApiErrorResponse(err) as a shortcut for errors.As.

How to handle errors

1

Check err

On every call, confirm err is nil before you use the result.
Error handling
2

Read the error detail

Use the field that matches the failure:
  • Core rejection: errors.As matches *ApiErrorResponse. Read apiErr.ErrorDetail.Code for logic. Use apiErr.Status when you only need broad handling (401, 404, 409, 5xx).
  • SDK validation: plain error before any HTTP call. Read err.Error() and fix the payload before retrying.
See API error codes for the full list of codes Core returns and what each one means.
3

Handle transport failures

When the SDK cannot reach Core or the request times out, you get a network or timeout error from the HTTP client. Configure timeout and logging in your SDK client.

What Core sends on rejection

When Core rejects a request, the response body looks like this:
404 Not Found
The SDK maps that JSON into ApiErrorResponse. Read apiErr.ErrorDetail.Code in your app, not the message string. Message text can change between releases. When Core returns only a flat "error" string with no error_detail, the SDK sets ErrorDetail.Code to "UNKNOWN".
Do not match exact error message strings in application logic. Prefer apiErr.ErrorDetail.Code for routing and apiErr.ErrorDetail.Message for user-facing text only.

Client-side validation

Some methods validate input before sending a request. When validation fails, Core never receives the call.
Each Core API lists required fields for that call.

Need help?

We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool. To ask questions or discuss issues, please contact us or join our Discord community.