In the Bokio API, standard HTTP status codes are used to indicate errors. These status codes provide a standardized way of communicating the outcome of a request. In addition to the status code we provide, when possible, both a human-readable and machine-readable JSON body.
HTTP Status Codes
The following HTTP status codes are commonly used in the Bokio API for error handling:
Status code | Bokio error body | Description |
---|---|---|
400 Bad Request | โ | The request was invalid or could not be understood by the server. |
401 Unauthorized | โ | The request requires authentication, but the user is not authenticated. |
403 Forbidden | โ | The server understood the request, but refuses to authorize it. |
404 Not Found | โ | The requested resource could not be found. |
429 Too Many Requests | โ | The request was not processed as rate limits have been surpassed. See Rate Limits . |
500 Internal Server Error | โ | An unexpected error occurred on the server. |
It is important to handle these status codes appropriately in your application to provide a good user experience.
Bokio error body
The Bokio error body provides additional information about an error. By using JSON Pointer it's possible to narrow down which field in the request body that was wrong. For example, a #/lineItems/1/quantity
tells you that the error is specifically for quantity field on the second line item in the request body.
apiError:
type: object
title: apiError
description: |
Represents an error response from the API with details about the error(s).
The `errors` array contains specific validation errors, each with a `message` and a `resource` to the field that caused the error. This array will be empty for other types of errors.
required:
- message
- code
- bokioErrorId
properties:
message:
type: string
code:
type: string
errors:
type: array
items:
type: object
properties:
message:
type: string
field:
description: JSON Pointer to the incorrect element
type: string
bokioErrorId:
type: string
format: uuid
example:
code: "ValidationError"
message: "The request contains invalid data."
errors:
- message: "The 'name' field is required."
field: "#/data/attributes/1/name"
- message: "The 'email' field must be a valid email address."
field: "#/data/attributes/0/email"
bokioErrorId: "123e4567-e89b-12d3-a456-426614174000"
Common error codes are specified in Error codes, but please explore the API operation that you use because there you'll find detailed information on which error codes to expect for the specific operation.
Error codes
Error code | description |
---|---|
not-found | The requested resource was not found |
validation-error | The request is invalid. Inspect the errors array to pin-point the issue. |
operation-not-allowed | The request is not allowed due to the state of the resource |
limit-exceeded | A limit was exceeded for the resource. For example, size of a file on an invoice attachment. |
internal-server-error | A internal server error was encountered. |
OAuth errors
For OAuth related endpoints /authorize
and /token
the Bokio API following the OAuth 2.0 specification. These errors will either come as a 302
to the specified redirect_uri
but can also be return as a response from the endpoint. In those cases it would normally come in form of 400
.
Field | Description |
---|---|
error | An error code per Section 4.1.2.1 of the OAuth 2.0 spec. |
error_description | A user-friendly description of the error that occurred. |
state | The state content, if valid, originally passed to /oauth2/authorize. |