generate API errors - handlers and template