cURL to HTTP node

Working with APIs in automation, you might have come across cURL in API documents.

Let's explore what cURL is and how to translate a cURL command to n8n HTTP node.

What is cURL?

cURL is a command-line tool to make API requests. It's commonly used in API documentation to show how to interact with an endpoint.

For example, you might see something like this:

curl -X POST "https://api.example.com/data" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -d '{"name": "John", "age": 30}'

Here's what each part of the command means:

  • -X POST → The HTTP method to use.

  • -H → These are the Headers - Adds extra info, like content type and authorization.

  • -d → This is the request body - JSON data.

Translating cURL to n8n’s HTTP Node

Import cURL

There is a very handy button at the top right of the HTTP node - 'Import cURL'

Instead of transferring each value manually, you can copy paste the cURL command and it will convert the values for you.

It imports the request body in a different way but that doesn't really matter.

After the import you can tweak it any way you want.

Query Parameters

Sometimes there are query parameters in the URL.

Query parameters are extra details added to a URL to filter or customize an API request.

They come in key-value pairs, start after a ?, and are separated by &.

For example, in the following URL there are 2 query params:

https://api.example.com/users?status=active&limit=10

  • status=active → Only returns active users

  • limit=10 → Limits results to 10 users

These parameters help refine API responses without changing the request body.

Example cURL

curl -X POST "https://api.example.com/users?ref=newsletter&source=web" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -d '{"name": "Alice", "email": "[email protected]"}'

Here's how they can be represented in the HTTP node.

Catch you in a week!