Skip to content
Dashboard

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 n8n or 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 FieldValue
Credential TypeHeader Auth
Name (Label)Brainpercent API
Header Auth — NameAuthorization
Header Auth — ValueBearer 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 FieldValue
MethodPOST
URLhttps://brainpercent.app/api/v1/articles/generate
AuthenticationGeneric Credential Type
Generic Auth TypeHeader Auth
Credential for Header AuthSelect your "Brainpercent API" credential
Send HeadersON
Header ParametersAdd one header (see below)
Send BodyON
Body Content TypeJSON
Specify BodyUsing JSON
JSONYour request body (see below)
Options → Response FormatJSON (auto-detected, default)
Options → Always Output DataON (for error handling)
Options → Timeout30000 ms (30 seconds)

Header Parameters

Under "Header Parameters", add one header (the Authorization is handled by the credential):

NameValue
Content-Typeapplication/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

FieldValue
NodeSchedule Trigger (previously "Cron")
Rule — Trigger IntervalDays
Rule — Hour9
Rule — Minute0

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

FieldValue
NodeWait
ResumeAfter Time Interval
Wait Amount5
Wait UnitMinutes

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)

FieldValue
MethodGET
URLhttps://brainpercent.app/api/v1/articles/{{ $json.data.article_id }}/status
AuthenticationSame "Brainpercent API" Header Auth credential
Send BodyOFF (GET request)

Node 5: IF (Check Generation Status)

IF FieldValue
ConditionString
Value 1{{ $json.data.status }}
Operationis not equal to
Value 2generating
OutputConnect 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)

FieldValue
MethodPOST
URLhttps://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.

1

Schedule Trigger or Webhook

2

HTTP Request: GET https://brainpercent.app/api/v1/user/credits

3

IF Node: Check credits

IF FieldValue
ConditionNumber
Value 1{{ $json.data.available_credits }}
OperationLarger or Equal
Value 240 (cost of one article)
4a

True: HTTP Request → POST /articles/generate

4b

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

FieldValue
NodeWebhook
HTTP MethodPOST
Pathgenerate-article
RespondUsing '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:

Datan8n ExpressionExample
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:

SettingValue
Error Workflow trigger nodeError Trigger
Connected toSlack/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 SettingValue
Retry On FailON
Max Tries3
Wait Between Tries60000 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