n8n Integration
Automate content workflows with n8n's HTTP Request node — exact field-by-field configuration for self-hosted and cloud instances.
Overview
n8n is a self-hosted (and cloud-hosted) workflow automation tool. Use the HTTP Request node to connect to Brainpercent's API. This guide covers every field in n8n's node configuration, credential setup, and workflow patterns.
Prerequisites
- An n8n instance — self-hosted (
npx n8nor Docker) or n8n.cloud - A Brainpercent API key (
bp_prefix) with read + write permissions - n8n version 0.220+ (for latest HTTP Request node features)
Step 1: Create Header Auth Credential
Before configuring the HTTP Request node, create a reusable credential. Go to Settings → Credentials → Add Credential and search for "Header Auth".
| Credential Field | Value |
|---|---|
| Credential Type | Header Auth |
| Name (Label) | Brainpercent API |
| Header Auth — Name | Authorization |
| Header Auth — Value | Bearer bp_your_api_key_here |
Self-hosted alternative: You can use environment variables instead. Set BRAINPERCENT_API_KEY=bp_your_key in your n8n environment and reference it as {{ $env.BRAINPERCENT_API_KEY }} in the credential value.
Step 2: HTTP Request Node Configuration
Add an HTTP Request node to your workflow. Here is every field in the node settings panel:
| n8n Field | Value |
|---|---|
| Method | POST |
| URL | https://brainpercent.app/api/v1/articles/generate |
| Authentication | Generic Credential Type |
| Generic Auth Type | Header Auth |
| Credential for Header Auth | Select your "Brainpercent API" credential |
| Send Headers | ON |
| Header Parameters | Add one header (see below) |
| Send Body | ON |
| Body Content Type | JSON |
| Specify Body | Using JSON |
| JSON | Your request body (see below) |
| Options → Response Format | JSON (auto-detected, default) |
| Options → Always Output Data | ON (for error handling) |
| Options → Timeout | 30000 ms (30 seconds) |
Header Parameters
Under "Header Parameters", add one header (the Authorization is handled by the credential):
| Name | Value |
|---|---|
Content-Type | application/json |
JSON Body
In the "JSON" field, paste your request body. Use n8n expressions with {{ }} to reference data from previous nodes:
{
"topic": "Your Article Topic",
"keywords": ["keyword1", "keyword2"],
"tone": "professional",
"length": "long"
}Workflow: Content Automation Pipeline
Cron → Generate Article → Wait → Check Status → IF Ready → Generate Social
Node 1: Schedule Trigger
| Field | Value |
|---|---|
| Node | Schedule Trigger (previously "Cron") |
| Rule — Trigger Interval | Days |
| Rule — Hour | 9 |
| Rule — Minute | 0 |
Node 2: HTTP Request (Generate Article)
Configured as shown in the HTTP Request Node Configuration above. POST to /api/v1/articles/generate.
{
"topic": "Daily SEO Insights — {{ $now.format('MMMM D, YYYY') }}",
"keywords": ["SEO", "daily insights"],
"tone": "professional",
"length": "medium"
}Node 3: Wait
| Field | Value |
|---|---|
| Node | Wait |
| Resume | After Time Interval |
| Wait Amount | 5 |
| Wait Unit | Minutes |
The Wait node pauses the entire workflow execution. On self-hosted n8n, the workflow stays in memory during the wait. For production, use n8n's queue mode (EXECUTIONS_MODE=queue) so waits don't block other workflows.
Node 4: HTTP Request (Check Status)
| Field | Value |
|---|---|
| Method | GET |
| URL | https://brainpercent.app/api/v1/articles/{{ $json.data.article_id }}/status |
| Authentication | Same "Brainpercent API" Header Auth credential |
| Send Body | OFF (GET request) |
Node 5: IF (Check Generation Status)
| IF Field | Value |
|---|---|
| Condition | String |
| Value 1 | {{ $json.data.status }} |
| Operation | is not equal to |
| Value 2 | generating |
| Output | Connect To |
|---|---|
| True (article ready) | → Node 6: Generate Social Content |
| False (still generating) | → Loop back to Node 3: Wait (creates a polling loop) |
Node 6: HTTP Request (Generate Social)
| Field | Value |
|---|---|
| Method | POST |
| URL | https://brainpercent.app/api/v1/social/generate |
{
"source_url": "https://brainpercent.app/articles/{{ $json.data.slug }}",
"platforms": ["twitter", "linkedin"],
"tone": "professional"
}Workflow: Conditional Generation
Check credits before generating to avoid failures and wasted workflow runs.
Schedule Trigger or Webhook
HTTP Request: GET https://brainpercent.app/api/v1/user/credits
IF Node: Check credits
| IF Field | Value |
|---|---|
| Condition | Number |
| Value 1 | {{ $json.data.available_credits }} |
| Operation | Larger or Equal |
| Value 2 | 40 (cost of one article) |
True: HTTP Request → POST /articles/generate
False: Send Notification (Slack/Email node) — "Low credits!"
Workflow: Webhook Listener
Expose an n8n webhook endpoint that triggers article generation when called externally.
Webhook Node Configuration
| Field | Value |
|---|---|
| Node | Webhook |
| HTTP Method | POST |
| Path | generate-article |
| Respond | Using 'Respond to Webhook' Node |
The full webhook URL will be: https://your-n8n-instance.com/webhook/generate-article
n8n Expressions Reference
n8n uses JavaScript expressions inside {{ }} to reference data from previous nodes:
| Data | n8n Expression | Example |
|---|---|---|
| Article ID | {{ $json.data.article_id }} | f8c9d0e1-2345-... |
| Article status | {{ $json.data.status }} | draft |
| Article slug | {{ $json.data.slug }} | ai-content-marketing |
| Credit balance | {{ $json.data.available_credits }} | 850 |
| First social item | {{ $json.data.items[0].id }} | d5b2f9c3-a0e4-... |
| Current date | {{ $now.format('YYYY-MM-DD') }} | 2026-02-02 |
| Webhook body field | {{ $json.body.topic }} | AI Marketing |
| Env variable | {{ $env.BRAINPERCENT_API_KEY }} | bp_abc123... |
Error Handling & Workflow Settings
Error Trigger Workflow
Create a separate "Error Workflow" in n8n that catches failures from all workflows:
| Setting | Value |
|---|---|
| Error Workflow trigger node | Error Trigger |
| Connected to | Slack/Email node for alerts |
Then in your main workflow's settings (gear icon), set Error Workflow to point to this error handler.
Retry on Failure
| Workflow Setting | Value |
|---|---|
| Retry On Fail | ON |
| Max Tries | 3 |
| Wait Between Tries | 60000 ms (1 minute) |
Tips & Best Practices
- Use Header Auth credentials — never hardcode API keys in HTTP Request nodes
- Enable "Always Output Data" on HTTP Request nodes so subsequent nodes receive data even on error
- Use the Wait node (not Code node with
sleep()) for workflow pauses - Set up an Error Trigger workflow to catch failures across all workflows
- Use "Split In Batches" node when processing large arrays of articles
- For self-hosted: use environment variables for secrets —
{{ $env.BRAINPERCENT_API_KEY }} - For self-hosted: enable queue mode in production for concurrent workflow execution
- Enable "Retry On Fail" on HTTP Request nodes with a 60-second interval for rate limit resilience