Output Charts

Blog

How to send data to a dashboard from n8n

Build an n8n workflow that pushes fresh numbers to a live dashboard on a schedule, with a Schedule Trigger and one HTTP Request node.

If your numbers already flow through n8n, you can put them on a dashboard without writing a script. An Output Charts visual is a JSON document with its own URL, and n8n's HTTP Request node can replace that document whenever the workflow runs.

This guide builds a workflow that runs every morning, counts yesterday's signups, and pushes the number to a KPI. A second version sends a whole chart.

What you need

  • A Solo plan, since API push is part of Solo.
  • An API key from Account → API keys. It starts with oc_live_ and is shown once.
  • The visual's push URL: in the Output Charts editor, select the visual and choose Copy push URL under Push from code. It looks like https://api.outputcharts.com/visuals/<visual-id>/data.

1. Store the key as a credential

Keep the key out of the workflow itself, so it does not end up in exports. In n8n, create a Header Auth credential:

  • Name: Authorization
  • Value: Bearer oc_live_... (the word Bearer, a space, then your key)

2. Start with a Schedule Trigger

Add a Schedule Trigger node and give it a rule: Trigger Interval set to Days, Days Between Triggers 1, Trigger at Hour 6. Any interval works; one push a day or an hour is plenty for most dashboards.

3. Get the number

Add whatever node fetches your data. With the Postgres node, an Execute a SQL query operation like this returns one item with a count field:

select count(*)::int as count
from signups
where created_at >= current_date - 1 and created_at < current_date

The ::int matters: Postgres returns count(*) as a big integer, which arrives in n8n as text, and the dashboard expects a number.

4. Push it with an HTTP Request node

Add an HTTP Request node after it:

  • Method: PUT
  • URL: the push URL you copied
  • Authentication: Generic Credential Type, then Header Auth, and pick the credential from step 1
  • Send Body: on
  • Body Content Type: JSON
  • Specify Body: Using JSON

For the JSON, switch the field to an expression and refer to the previous node's output:

{
  "label": "Signups yesterday",
  "value": {{ $json.count }},
  "format": "number"
}

Run the node once by hand. A successful push answers with the visual's id and the time of the change, and any open copy of the dashboard shows the new number within 15 seconds.

5. Publish the workflow

A Schedule Trigger only fires once the workflow is saved and published (older versions of n8n call this activating it). After that, the dashboard keeps itself current.

Sending a whole chart

For a chart, the workflow has to turn many items into one document. Change the query to return a row per day:

select to_char(d.day, 'Mon DD') as day, count(s.id)::int as signups
from generate_series(current_date - 7, current_date - 1, interval '1 day') as d(day)
left join signups s on s.created_at >= d.day and s.created_at < d.day + interval '1 day'
group by d.day
order by d.day

Add a Code node in Run Once for All Items mode to build a line chart's document from the rows:

const rows = $input.all().map((item) => item.json);

return [{
  json: {
    xKey: "day",
    curve: "monotone",
    series: [{ key: "signups", label: "Signups" }],
    data: rows.map((row) => ({ day: row.day, signups: Number(row.signups) })),
  },
}];

Then point the HTTP Request node at the chart's push URL and send the whole item as the body:

{{ JSON.stringify($json) }}

Each push replaces the whole document, so always send every row, not only the new ones.

When a push fails

The HTTP Request node stops the workflow on an error, and the execution log shows the API's answer:

  • 401 invalid_api_key: check the credential's value starts with Bearer and the key has not been revoked.
  • 403 requires_solo: the account is on Free. Keys pause and work again after an upgrade.
  • 422 invalid_document: the JSON does not fit the visual's type. The details list names the field, for example value: Expected number when a number arrived as text.
  • 429 rate_limited: one key can push 60 times a minute, which a schedule will not come near; check for a loop that pushes once per item.

Before wiring up a workflow, you can paste a document into JSON to chart to check its shape. Create a free account to build the dashboard; upgrading to Solo turns on API keys.

More from the blog