Skip to main content

Error Handling

The GeniSpace API uses standard HTTP status codes to indicate request results and provides a flat error body in the response.

HTTP Status Codes

Status CodeMeaningDescription
200SuccessRequest processed normally
201CreatedResource created successfully
400Bad RequestInvalid or missing request parameters
401UnauthorizedMissing or invalid credentials
402Payment RequiredInsufficient token balance or quota
403ForbiddenNo permission to perform this operation
404Not FoundRequested resource does not exist
429Too Many RequestsDaily token usage limit exceeded
500Internal Server ErrorServer-side internal error

Error Response Format

The error body is flat — message and code sit at the top level alongside success: false. There is no nested error object.

{
"success": false,
"message": "Validation failed: name cannot be empty",
"code": "VALIDATION_ERROR"
}

Validation failures may additionally include an errors array with field-level detail.

Common Error Codes

Error CodeHTTP StatusDescription
VALIDATION_ERROR400Invalid request parameter (express-validator failure)
BAD_REQUEST400Malformed request
UNAUTHORIZED401Credentials are invalid or expired
PAYMENT_ERROR400Payment or billing failure
FORBIDDEN403No permission to access this resource
NOT_FOUND404Resource does not exist
SERVER_ERROR500Internal server error

Token & Billing Errors

When a request cannot be served because of token balance or quota constraints, the API returns one of the following:

Error CodeHTTP StatusDescription
INSUFFICIENT_TOKENS402Token balance is depleted
BELOW_MINIMUM_BALANCE402Balance is below the minimum required for the operation
REQUEST_TOO_LARGE400Request payload exceeds the per-request token limit
DAILY_LIMIT_EXCEEDED429Daily token usage limit reached

Error Handling Recommendations

  1. Check the status code: Determine whether the request was successful based on the HTTP status code
  2. Parse the error message: Read the top-level message and branch on code for the specific reason
  3. Retry strategy: Implement backoff retries for 429 and 5xx errors
  4. Handle billing errors: Treat 402 responses as a signal to top up the space's token balance
  5. Logging: Record error information for troubleshooting