home / skills / openclaw / skills / n8n-api

n8n-api skill

/skills/codedao12/n8n-api

This skill enables programmatic control of n8n via REST API to manage workflows, executions, and credentials across self-hosted and cloud instances.

npx playbooks add skill openclaw/skills --skill n8n-api

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
3.7 KB
---
name: n8n-api
description: Operate n8n via its public REST API from OpenClaw. Use for workflow management, executions, and automation tasks such as listing, creating, publishing, triggering, or troubleshooting. Works with both self-hosted n8n and n8n Cloud.
---

# n8n Public REST API

Use this skill when you need to drive n8n programmatically. It covers the same core actions you use in the UI: workflows, executions, tags, credentials, projects, and more.

## Availability
- The public API is unavailable during the free trial.
- Upgrade your plan to enable API access.

## Configuration

Recommended environment variables (or store in `.n8n-api-config`):

```bash
export N8N_API_BASE_URL="https://your-instance.app.n8n.cloud/api/v1"  # or http://localhost:5678/api/v1
export N8N_API_KEY="your-api-key-here"
```

Create the API key in: n8n Settings → n8n API → Create an API key.

## Auth header

All requests require this header:

```
X-N8N-API-KEY: $N8N_API_KEY
```

## Playground

The API playground is only available on self-hosted n8n and operates on real data. For safe experiments, use a test workflow or a separate test instance.

## Quick actions

### Workflows: list
```bash
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" "$N8N_API_BASE_URL/workflows" \
  | jq '.data[] | {id, name, active}'
```

### Workflows: details
```bash
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" "$N8N_API_BASE_URL/workflows/{id}"
```

### Workflows: activate or deactivate
```bash
# Activate (publish)
curl -s -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"versionId":"","name":"","description":""}' \
  "$N8N_API_BASE_URL/workflows/{id}/activate"

# Deactivate
curl -s -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" \
  "$N8N_API_BASE_URL/workflows/{id}/deactivate"
```

### Webhook trigger
```bash
# Production webhook
curl -s -X POST "$N8N_API_BASE_URL/../webhook/{webhook-path}" \
  -H "Content-Type: application/json" \
  -d '{"key":"value"}'

# Test webhook
curl -s -X POST "$N8N_API_BASE_URL/../webhook-test/{webhook-path}" \
  -H "Content-Type: application/json" \
  -d '{"key":"value"}'
```

### Executions: list
```bash
# Recent executions
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" \
  "$N8N_API_BASE_URL/executions?limit=10" \
  | jq '.data[] | {id, workflowId, status, startedAt}'

# Failed only
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" \
  "$N8N_API_BASE_URL/executions?status=error&limit=5"
```

### Executions: retry
```bash
curl -s -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"loadWorkflow":true}' \
  "$N8N_API_BASE_URL/executions/{id}/retry"
```

## Common flows

### Health check summary
Count active workflows and recent failures:
```bash
ACTIVE=$(curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" \
  "$N8N_API_BASE_URL/workflows?active=true" | jq '.data | length')

FAILED=$(curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" \
  "$N8N_API_BASE_URL/executions?status=error&limit=100" \
  | jq '[.data[] | select(.startedAt > (now - 86400 | todate))] | length')

echo "Active workflows: $ACTIVE | Failed (24h): $FAILED"
```

### Debug a failed run
1. List failed executions to get the execution ID.
2. Fetch execution details and identify the failing node.
3. Review node parameters and input data.
4. Suggest a fix based on the error message.

## Endpoint index

See `assets/n8n-api.endpoints.md` for the full list of endpoints.

## REST basics (optional)
If you want a refresher, these are commonly recommended:
- KnowledgeOwl: working with APIs (intro)
- IBM Cloud Learn Hub: what is an API / REST API
- MDN: overview of HTTP

## Notes and tips
- The n8n API node can call the public API from inside workflows.
- Webhook URLs are not the same as API URLs and do not use the API key header.
- Execution records may be pruned based on instance retention settings.

Overview

This skill lets you operate n8n via its public REST API from OpenClaw to manage workflows, executions, credentials, webhooks, and related automation objects. Use it to list, create, publish, trigger, retry, and troubleshoot workflows on both self-hosted n8n and n8n Cloud. It exposes the core actions you normally use in the UI so you can automate CI/CD, monitoring, and incident responses.

How this skill works

The skill issues authenticated HTTP requests to the n8n public API using an API key in the X-N8N-API-KEY header and a configured base URL. It maps common tasks—workflow listing, activate/deactivate, execution listing and retry, webhook triggers, and fetching execution details—into programmatic calls. For safety, use a test instance or test workflows when exercising the API playground on self-hosted deployments.

When to use it

  • Automate publishing or deactivating multiple workflows
  • Trigger or test webhooks programmatically from other systems
  • Monitor executions and automatically retry failed runs
  • Build integrations that manage credentials, tags, and projects
  • Fetch execution details for structured debugging and root-cause analysis

Best practices

  • Store the base URL and API key in environment variables or a secure config file and never hard-code secrets
  • Use a dedicated test instance or isolated workflows when experimenting with the API playground
  • Respect retention and pruning: export important execution records before they get pruned
  • Limit scope: request only the endpoints and fields you need to reduce noise and rate usage
  • When retrying executions, use loadWorkflow=true to ensure workflow state is restored for accurate replays

Example use cases

  • Health-check script that counts active workflows and 24h failures, alerting on thresholds
  • CI/CD step to publish a workflow version after successful tests
  • Automated incident flow: detect failed executions, fetch details, create a ticket with failing node info, and optionally retry
  • Integration that triggers production or test webhooks from external systems
  • Scheduled audit that lists workflows, checks active status, and reports drift in workflow metadata

FAQ

Is the public API available during the free trial?

No. The public API is unavailable during the free trial; upgrade your plan to enable access.

How do I authenticate requests?

Include your API key in the X-N8N-API-KEY header and point requests to your instance base URL (e.g., https://your-instance.app.n8n.cloud/api/v1).

Can I safely test requests?

Use the API playground on self-hosted instances or a separate test instance/workflow. Webhook-test endpoints exist for safe webhook experiments.