Stepthrough Start free

n8n HTTP Request Bearer Auth: Send an API Key Header

Quick answer

To send an API key as a bearer token in the n8n HTTP Request node, set Authentication to Generic Credential Type, Generic Auth Type to Bearer Auth, then create a credential and paste the key into Bearer Token. n8n sends the header Authorization: Bearer <your key> on every call and keeps the key out of the URL. The free Litescrape in n8n lesson switches a price-tracking workflow from a key in the URL to a bearer header.

Last updated

Take the free module →Module 15 of the free n8n Jump Start course, about 7 minutes. No account needed.

n8nHTTP RequestAPI keys

Why not put the API key in the URL?

Keys in the URL end up in logs, browser history and screenshots. Many APIs, Litescrape among them, want the key in a header instead. A credential also means the key isn't visible in the workflow when you share or export it. The glossary entries on API keys and bearer tokens explain both.

How do I set up Bearer Auth?

From the lesson, where Northpeak Packs (made up) checks competitor prices every Monday:

  1. Double-click the HTTP Request node.
  2. Replace the old address in URL with the new endpoint.
  3. Under Query Parameters (turn on Send Query Parameters if you don't see them), delete parameters the new API doesn't need. Here: engine, because the URL already says Google Shopping, and api_key, because the key moves to a header.
  4. Scroll up to Authentication and choose Generic Credential Type.
  5. Open Generic Auth Type and choose Bearer Auth.
  6. Open the Bearer Auth credential drop-down and click + Create new credential.
  7. Paste the key into Bearer Token and click Save.
  8. Click Execute step to send one test request.

Which auth type do I need?

Read the API's docs for the header it expects.

API docs sayGeneric Auth Type
Authorization: Bearer YOUR_KEYBearer Auth
A custom header like X-API-Key: YOUR_KEYHeader Auth
?api_key=YOUR_KEY in the URLQuery Auth
Username and passwordBasic Auth
"Connect your account" with a login screenOAuth2 API

The list in n8n also has Custom Auth, Digest Auth and OAuth1 API for rarer cases.

What should the response look like?

In the lesson, results come back in shopping_results, with title, source, price and extracted_price, the same field names the next nodes already use, so nothing downstream changes. When you swap one API for another, compare field names before you run the whole workflow.

Try it free, step by step

Litescrape in n8n: Swap SerpApi for a Cheaper Search API. Switch a weekly n8n competitor-price workflow from SerpApi to Litescrape's Google Shopping API: change the HTTP Request URL, move the key into a Bearer Auth credential, test it and check the sheet. You do every step yourself in a practice copy of n8n, it checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, and nothing touches your real accounts.

Start the free lesson

Or read the full step-by-step guide

Why do I get 401 Unauthorized?

  • The key is wrong, expired or has no credit left.
  • The auth type doesn't match what the API expects (Bearer vs Header Auth).
  • The old api_key query parameter is still there and conflicts.
  • There's a stray space before or after the key.

Other codes are in HTTP Status Codes in n8n.

How do I keep a weekly API call cheap?

Free tiers are small (the lesson's key comes with 5 free calls). Test with Execute step once, not on a loop, and pin the response while you build the rest of the workflow so you don't spend calls. The query parameter and rate limit entries cover the rest.

Key takeaways

  • Use Generic Credential Type > Bearer Auth when an API wants Authorization: Bearer.
  • Remove api_key from query parameters once the key is in a credential.
  • Match the auth type to the API's docs: Bearer, Header, Query or Basic.
  • Compare response field names when you swap APIs.

Frequently asked questions

How do I add a bearer token in n8n?

In the HTTP Request node, set Authentication to Generic Credential Type, choose Bearer Auth, create a credential and paste the token.

What is the difference between Bearer Auth and Header Auth in n8n?

Bearer Auth always sends Authorization: Bearer plus your token. Header Auth sends any header name and value you choose, such as X-API-Key.

Is my API key visible in the workflow?

Not when it's stored in a credential. The workflow only references the credential.

Which course is this in?

The free n8n Jump Start course.

Free lessons in this post

Plain-English definitions, each with an example from a free lesson.

The full AI glossary

Keep reading

All blog posts · All free tutorials