API design¶
See also
Use the parameter
idonly for application IDs, to avoid accidental errors.Don’t use
status.HTTP_400_BAD_REQUEST. FastAPI uses it for request validation errors, which are reported to Sentry. Instead, use:status.HTTP_403_FORBIDDEN, if not authenticated or authorizedNote
401 is only relevant to HTTP authentication. RFC 7325 states: “The server generating a 401 response MUST send a WWW-Authenticate header field”
status.HTTP_404_NOT_FOUND, if the resource is not foundstatus.HTTP_409_CONFLICT, if the resource already existsstatus.HTTP_501_NOT_IMPLEMENTED, if the code path is not implementedstatus.HTTP_422_UNPROCESSABLE_ENTITYfor problems with the request, otherwise
See also