Errors
In this guide, we will talk about what happens when something goes wrong while you work with the API. Mistakes happen, and mostly they will be yours, not ours. Let's look at some status codes and error types you might encounter.
You can tell if your request was successful by checking the status code when receiving an API response. If a response comes back unsuccessful, you can use the error message and code to figure out what has gone wrong and do some rudimentary debugging (before contacting support).
Before reaching out to support with an error, please be aware that 99% of all reported errors are, in fact, user errors. Therefore, please carefully check your code before contacting Fystack support.
Status codes
Here is a list of the different categories of status codes returned by the Fystack API. Use these to understand if a request was successful.
- Name
2xx
- Type
- Description
A 2xx status code indicates a successful response.
- Name
4xx
- Type
- Description
A 4xx status code indicates a client error — this means it's a you problem.
- Name
5xx
- Type
- Description
A 5xx status code indicates a server error — you won't be seeing these.
Error response format
Whenever a request is unsuccessful, the Fystack API will return an error response with a structured format. All error responses include a success
field set to false
, a descriptive message
, and an error code
. For validation errors, you'll also see an errors
array containing details about which fields failed validation.
Here are the common components of an error response:
- Name
success
- Type
- Description
Always
false
for error responses.
- Name
message
- Type
- Description
A human-readable description of what went wrong.
- Name
code
- Type
- Description
An internal error code that can help with debugging.
- Name
errors
- Type
- Description
For validation errors, contains details about which fields failed validation and why.
Standard error response
{
"success": false,
"message": "Resource not found",
"code": 404
}
Validation error response
{
"success": false,
"message": "validation error",
"code": 400,
"errors": [
{
"field": "email",
"reason": "required"
},
{
"field": "password",
"reason": "min=8"
}
]
}
Error codes
The Fystack API uses specific error codes to help identify the exact issue that occurred. These codes provide more granular information than HTTP status codes alone.
Code | Name | Description |
---|---|---|
2407 | ValidationErrCode | Returned when request data fails validation requirements. |
2408 | GenerationErrCode | Indicates an error occurred during content or resource generation. |
2409 | DatabaseErrCode | Returned when a database operation fails. |
2410 | ConflictErrCode | Indicates a conflict with the current state of the resource. |
2411 | InfraErrCode | Returned when an infrastructure-related error occurs. |
2412 | RedisErrCode | Indicates a problem with Redis cache operations. |
2413 | ForbiddenResourceErrCode | Returned when the user does not have access to the requested resource. |
2414 | ForbiddenActionErrCode | Indicates the user is not allowed to perform the requested action. |
2415 | UnauthorizedErrCode | Returned when authentication is required but missing or invalid. |
2416 | ExecutionErrCode | Indicates an error during the execution of a command or process. |
2417 | NotFoundErrCode | Returned when the requested resource doesn't exist. |
2418 | EncodingErrCode | Indicates an error occurred while encoding data. |
2419 | DecodingErrCode | Returned when there's an error decoding data. |
2420 | InternalResourceNotFound | Indicates a required internal resource could not be found. |
2421 | BadRequestErrCode | Returned when the request is malformed or contains invalid parameters. |
2422 | InternalErrCode | Indicates an unexpected internal server error occurred. |
These error codes provide specific information about what went wrong with your request. When contacting support, always include the error code to help us diagnose issues more quickly.