How to render a Twig template in the element-api plugin (v2.5)
You didn’t tell where that Twig file is located, but I assume your issue has to do with being in the wrong “Template Mode”.

Here’s how you can switch mode:

Craft::$app-&gt;view-&gt;setTemplateMode()


Documentation: https://docs.craftcms.com/v3/extend/updating-plugins.html#rendering-plugin-templates-on-front-end-requests