Self Hosted Workflow Templates

n8n version: 1.114.0
Database (default: SQLite): SQLte
n8n EXECUTIONS_PROCESS setting (default: own, main): Main.
Running n8n via (Docker, npm, n8n cloud, desktop app): Docker.

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?

Thank you.

Hi @Nikita_Karpushin

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.

Hello Tamy,

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?

Hello @Nikita_Karpushin

For self-hosted setups, the only supported approach is:

  • Store workflows as JSON
  • Import them via the UI or via the REST API (POST /workflows)

Anything else would rely on reverse-engineering internals and may break on any update.

I know that’s not ideal, but that’s the current state of support.

Hope that clarifies it

Hi @Nikita_Karpushin, welcome!

The minimal response that should work is:

{
  "workflow": {
    "id": 1,
    "workflow": {}
  }
}

The result looks something like this:

If you want all the other fields as well, like in this example:

you’ll need to retrieve the schema and edit the properties you need, for example you can get it from:

https://api.n8n.io/templates/workflows/1

This documentation is also useful:

Hello Mohamed3nan,

Thank you we will try this.

1 Like