M
MJK.Supplies
Home / n8n / n8n API Tutorial…
n8n

n8n API Tutorial

n8n has its own REST API that allows programmatic management of workflows, executions, credentials, and instances. For technical teams running n8n at scale — managing workflows across environments, building internal tools on top of n8n, or integrating n8n into DevOps pipelines — the n8n API is essential. This guide covers the n8n API's key endpoints and common use cases.

M
MJK Supplies · Jan 19, 2026 · 3 min read
ShareXinf↗
n8n API Tutorial

What the n8n API Enables

The n8n API provides programmatic access to your n8n instance:

  • List, create, update, delete workflows — manage your automation portfolio via code
  • Execute workflows — trigger workflow runs programmatically
  • Get execution history — retrieve logs and results from past executions
  • Manage credentials — create and update integration credentials
  • Manage tags and annotations — organise workflows systematically

Common use cases: deploying workflows to production as part of a CI/CD pipeline, building internal dashboards that show automation performance, programmatically triggering workflows from custom applications, and bulk operations on large workflow portfolios.

Authentication

The n8n API uses API key authentication. Create an API key in n8n's settings: Settings → API → Create API key.

Include the key in all requests:

X-N8N-API-KEY: your-api-key

For self-hosted instances, the API base URL is your n8n URL + /api/v1. For n8n cloud, use the cloud instance URL.

Key Endpoints

List all workflows:

GET /api/v1/workflows

Returns all workflows with their metadata (not full definition). Add ?active=true to filter active workflows only.

Get a specific workflow:

GET /api/v1/workflows/{workflow-id}

Returns the full workflow definition as JSON — the same format as a workflow export.

Create a workflow:

POST /api/v1/workflows Content-Type: application/json { "name": "My New Workflow", "nodes": [...], "connections": {...}, "active": false }

Accepts the workflow definition JSON. Used to deploy workflows programmatically.

Activate/deactivate a workflow:

PATCH /api/v1/workflows/{workflow-id} { "active": true }

Execute a workflow:

POST /api/v1/workflows/{workflow-id}/execute { "data": { "myField": "myValue" } }

Starts a workflow execution. The optional data object is available in the workflow as input.

Get execution history:

GET /api/v1/executions?workflowId={workflow-id}&limit=10&status=error

Returns execution records. Filter by workflow ID, status (success/error), or date range.

Programmatic Workflow Deployment

For teams managing n8n workflows as code, a deployment pipeline:

# Export workflow from development curl -H "X-N8N-API-KEY: $DEV_API_KEY" \ https://dev.n8n.example.com/api/v1/workflows/123 \ > workflow.json # Deploy to production (create or update) curl -X POST \ -H "X-N8N-API-KEY: $PROD_API_KEY" \ -H "Content-Type: application/json" \ -d @workflow.json \ https://prod.n8n.example.com/api/v1/workflows

This pattern allows version-controlling n8n workflows in git and deploying them through your standard CI/CD process.

Monitoring Dashboard with the API

Build an execution monitoring dashboard using the n8n API:

// Daily summary script async function getDailySummary() { const yesterday = new Date(); yesterday.setDate(yesterday.getDate() - 1); const executions = await fetch( `https://n8n.example.com/api/v1/executions?startedAfter=${yesterday.toISOString()}`, { headers: { 'X-N8N-API-KEY': process.env.N8N_API_KEY } } ).then(r => r.json()); const total = executions.data.length; const errors = executions.data.filter(e => e.status === 'error').length; const successRate = ((total - errors) / total * 100).toFixed(1); return { total, errors, successRate }; }

Run this script daily (via n8n itself or a cron job) to generate performance reports.

Triggering Workflows via API

The Webhook trigger provides one way to trigger workflows externally. The Execute endpoint provides another — useful for internal applications.

From a web application (Node.js example):

async function triggerWorkflow(workflowId, inputData) { const response = await fetch( `https://n8n.example.com/api/v1/workflows/${workflowId}/execute`, { method: 'POST', headers: { 'X-N8N-API-KEY': process.env.N8N_API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ data: inputData }) } ); return response.json(); } // Trigger a lead enrichment workflow when a new user signs up triggerWorkflow('workflow-123', { email: newUser.email, name: newUser.name });

Recommended Tools

  • n8n — The platform with API access
  • Postman — Test n8n API calls during development
  • GitHub Actions — CI/CD for workflow deployment
  • Airtable — Dashboard for monitoring data
“The n8n API turns n8n from a visual tool into an automation platform that developers can manage programmatically. For teams running n8n in production, the API is essential.”
#n8n#api#tutorial

Related articles

MJK Supplies · Automation Services

Want this built for you?

We design and ship custom AI agents and automation systems for teams that want results, not a backlog. Book a free 30-minute consult — no commitment, no pitch deck.