I learned that I can fetch it on a remote machine using curl:
curl -X POST http://hassos:8123/api/template -H "Content-Type: application/json" -H "Authorization: Bearer TOKEN" \
-d '{"template": "{% set devices = sta.... THE WHOLE TWIG CODE HERE ....s.devices }}"}'
This works well, but as the TWIG code gets larger it becomes really ugly to read, format and maintain. I know that it’s possible to define a template sensor in a YAML file. Is it then possible to request the output (long JSON text in my case) of this YAML sensor via curl?