diff --git a/res/res_ari_events.c b/res/res_ari_events.c
index c8f28f97b1214fa3b18be0576632b79c53c21a7d..1c4655f82742287e7202222b641681834542f79f 100644
--- a/res/res_ari_events.c
+++ b/res/res_ari_events.c
@@ -150,6 +150,8 @@ static void ast_ari_events_event_websocket_ws_established_cb(struct ast_websocke
 	RAII_VAR(struct ast_websocket *, s, ws_session, ast_websocket_unref);
 	RAII_VAR(struct ast_ari_websocket_session *, session, NULL, ao2_cleanup);
 
+	SCOPED_MODULE_USE(ast_module_info->self);
+
 	response = ast_calloc(1, sizeof(*response));
 	if (!response) {
 		ast_log(LOG_ERROR, "Failed to create response.\n");
diff --git a/rest-api-templates/res_ari_resource.c.mustache b/rest-api-templates/res_ari_resource.c.mustache
index 85948fba16469a7e781614a35f78ef18e0cbce01..e320f19fc3d9ccb239ff7de6e7de77d3621c5e8c 100644
--- a/rest-api-templates/res_ari_resource.c.mustache
+++ b/rest-api-templates/res_ari_resource.c.mustache
@@ -211,6 +211,8 @@ static void ast_ari_{{c_name}}_{{c_nickname}}_ws_established_cb(struct ast_webso
 	struct ast_variable *path_vars = NULL;
 {{/has_path_parameters}}
 
+	SCOPED_MODULE_USE(ast_module_info->self);
+
 {{#has_parameters}}
 	response = ast_calloc(1, sizeof(*response));
 	if (!response) {