Response codes

Beam uses standard HTTP codes to indicate the success or failure of your requests.

In general, 2xx HTTP codes correspond to success, 4xx codes are for user-related failures, and 5xx codes are for infrastructure issues.

200Successful request.
400Check that the parameters were correct.
401The auth token used was invalid.
5xxIndicates an API timeout or an error with Beam servers.

Returning Custom Status Codes with FastAPI

You might want to return special status codes from your REST API. Beam supports FastAPI responses, so you can return custom status codes.

For example, you could return a 404 status code with a custom message in your handler function:
from fastapi import FastAPI
from fastapi.responses import JSONResponse

def custom_api_response():
    return JSONResponse(
      content={"message": "You need more tokens"}

Was this page helpful?