Skip to content

API Error Catalog

This project uses a business-code response envelope for all API responses:

json
{
  "code": "1003",
  "msg": "Forbidden",
  "data": {},
  "requestId": "177f2e17-c4ad-4976-b681-fd3230884f15",
  "traceId": "44ad0b87d4a14bf19f9be41ce53bff7a"
}

Standard Codes

CodeMeaningTypical Scenario
0000SuccessRequest completed successfully
1001Login/credential validation failedInvalid username/password or auth form error
1002Parameter/validation errorForm request validation failed
1003ForbiddenAuthenticated but missing permission
1009ConflictOptimistic lock/version mismatch
4020Two-factor requiredLogin requires OTP before session issuance
4040Not foundRoute/model not found
4050Method not allowedWrong HTTP method for endpoint
4290Too many requestsThrottle / rate-limit triggered
5000Server errorUnhandled backend exception
8888UnauthorizedMissing/invalid authentication
9999Token expiredAccess token expired

Notes

  • API always returns the response envelope, but HTTP status now follows semantic transport/auth/business outcomes where applicable.
  • Some business states, such as 4020 (two-factor required), still intentionally return HTTP 200 with a non-success code.
  • requestId and traceId should be logged by frontend for support/debugging.
  • For OpenAPI consumers, see docs/openapi.yaml (x-error-catalog, components.schemas.ApiErrorResponse).

Pair with Obsidian Admin Vue for the full contract-driven stack.