Hello, I am using self hosted N8N where we are trying to upload our own templates to our own library.
We have set up the env variable: N8N_TEMPLATES_HOST on our docker and we have our own backend service which pulls JSON’s of workflows we exported and uploaded to a database.
When we are trying to use a specific template from the menu of existing templates there is an API reqeust to our backend service to this route:
templates/workflow/{workflowID}.
As I understand this reqeust expects to receive the JSON of that specific workflow and allow the user to starting working on that workflow.
However I can’t find any information about which response this end point needs to return.
Has anyone worked with their own library and has successfully was able to use this endpoint?
This does not work the way you are trying to use it, and it is not a mistake on your side.
The N8N_TEMPLATES_HOST environment variable is not meant for custom template libraries. It is only used to point n8n to the official templates service (or a mirror of it).
When n8n calls /templates/workflow/{id}, it does not expect only a workflow JSON.
It expects additional internal metadata that is not documented or publicly available.
Because of that, even if you return a valid exported workflow, the template will not load.
Correct solution:
Store your workflows as JSON and import them manually or via the n8n REST API (POST /workflows). This is the only supported and stable way to use custom templates in self-hosted n8n.
Thank you for the quick response, which internal metadata should be included?
Is it the position of the nodes? Is there an example somewhere I can use for us?