I’m running a self-hosted n8n instance that already shows the login screen and requires my admin email/password. I would like to access workflow endpoints programmatically using curl.
My doubt is:
How do I first authenticate with my admin email/password using curl?
After logging in, how can I capture the session/cookie or token and reuse it for subsequent curl requests to protected endpoints?
A step-by-step example (login + follow-up request) would be really helpful.
when you start (trigger) your workflows you most certainly can do it with curl, For that you would need to create a webhook trigger in your workflow. Webhook allows to trigger your workflow with an http request. This way no need to deal with sessions, cookies or n8n authorization to begin with.
I understand that workflows can be triggered via webhooks, but my situation is a bit different.
When I start my n8n instance with the command:
n8n
the server starts successfully on port 5678, and when I open it in the browser I get the login page asking for my admin email and password. Example logs:
Hey @Nandhini_Subramaniya 'hope all is good.
Is there a reason you would like to do it this way? I would really like to know the use case, which automating the automation system is useful and cannot be simplified to just using a trigger specifically created for this sort of thing.
The reason I’m asking about logging in with curl is because when I start my self-hosted n8n instance it always shows the login page asking for my admin email and password.
I want to test accessing the instance programmatically (without a browser) — basically to log in using curl, get the session cookie or token, and then make further requests.
I understand that webhooks and API keys are the recommended way to trigger workflows, but in my case I’d like to simulate the normal login process programmatically for testing and learning purposes.
You are still not talking about the reason, you are talking about the way to overcome the login page. I am more interested in knowing why you need that, which problem are you trying to solve?
This is actually just part of my learning exercise. I’m experimenting with n8n to understand how authentication works under the hood.
For example, in a normal API I would first log in using curl with my email/password, receive a token or cookie, and then use that for subsequent requests. I’d like to practice the same flow with n8n, so I can better understand how its login/session mechanism works.
I know that in real use cases, webhooks or API keys are the right way to go — but here my goal is just to learn and replicate the login process programmatically using curl.
If you want to learn, you better choose another website for learning as you won’t be able to easily achieve what you want with n8n and here is why. The UI in n8n is heavily based on javascript, which in order to execute you would require a javascript engine to run and curl doesn’t have a javascript engine. This limitation includes both the login page as well as the editor.