User Registration API Best Practice

When implementing a User Registration API, when is the best time to call other functions like send the user an email, create initial internal user data, etc.

Is it done before you return a response from the Registration API or you have to implement a different API and call it from the frontend or something entirely different.

I need help.