Execute a workflow with PHP

Describe the problem/error/question

I want to execute a workflow via PHP (with CURL?) or if that’s not possible then with Javascript.
I have just a little knowledge on API’s and even less with Authentication but I’m trying to figure out how to use the n8n API. I’ve created a key but am a little lost as to what to do next. I tried using the Sandbox and get a CURL command but not sure how to use that with PHP. Also running the CURL command on a windows machine generates a few errors. It seems like it doesn’t know what do do with the -H parameters.

C:> curl -X ‘GET’ ‘http://10…REDACTED…:5678/api/v1/workflows/38’ -H ‘accept: application/json’ -H ‘X-N8N-API-KEY: n8n_api_43865_REDACTED’
curl: (3) URL using bad/illegal format or missing URL
curl: (6) Could not resolve host: application
curl: (3) URL using bad/illegal format or missing URL

Any help would be much appreciated!

What is the error message (if any)?

see above

Please share your workflow


(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node


Information on your n8n setup

  • n8n version: 0.233.1 (Enterprise Version)
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): app/npm
  • Operating system: Ubuntu Linux

There is a much easier way to accomplish this. Create a new workflow and use a web hook trigger. This will by default have no api key or authentication, but should work to receive the curl command. Once you have it working, you can turn on authentication on the webhook trigger by choosing headers or query parameters, or even oauth. This should hopefully help make it a bit easier to start.

This will be the correct answer as we don’t have an option in the API to execute a workflow so you would need to create your own webhook to handle that.

The error itself though is because CURL is not happy with the data being sent, Possibly down to the quote characters being used.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.