FastAPI's BackgroundTasks lets you run work after returning the response — so the client gets a fast reply while light follow-up work (sending an email, logging, cleanup) happens in the background. It's built in and simple, for lightweight tasks.
Using BackgroundTasks
fastapi BackgroundTasks
():
email_client.send(address, message)
():
save_user(user)
background_tasks.add_task(send_email, user.email, )
{: }
