n8n Public REST API
Use the public /api/v1 API in a version-aware, least-privilege way. This skill was validated against stable n8n 2.36.8 on 2026-08-29, but the target instance's discovery response and OpenAPI document are authoritative.
Required inputs
Establish these before calling the API:
- the instance base URL, including any configured path prefix and excluding a trailing slash
- an API key available through an environment variable or secret manager
- the intended operation and exact target resource
- explicit authorization for any mutation, especially publish, retry, stop, delete, package, settings, or source-control operations
Do not ask the user to paste an API key into chat. Do not print, log, commit, or persist the key. If no key is available, explain how to create one in Settings > n8n API and let the user place it in the environment.
Use N8N_BASE_URL and N8N_API_KEY in examples. If the user's environment already uses N8N_HOST, preserve it rather than renaming configuration unnecessarily.
Workflow
1. Classify the request
- Read-only inspection can proceed once the target instance is known and credentials are available.
- A write requires the user's requested outcome to clearly authorize that write.
- Bulk changes, execution retries, workflow publication, source-control pulls, and destructive operations require a preview of the exact scope before execution.
- If the user asks only for code or instructions, do not call their instance.
2. Discover what this instance and key support
Prefer capability discovery over a memorized endpoint list:
curl --silent --show-error --fail-with-body \
-H "Accept: application/json" \
-H "X-N8N-API-KEY: $N8N_API_KEY" \
"$N8N_BASE_URL/api/v1/discover?resource=workflow&include=schemas"
GET /discover returns the scopes, resources, operations, endpoint paths, and a specUrl visible to the current API key. Use resource and operation filters to keep the response focused. Add include=schemas when constructing a request body.
For self-hosted instances, the built-in Swagger UI is at /api/v1/docs. It operates on live data. The hosted documentation playground proxies calls through Scalar; never enter a production key there. Use a limited-scope test key and test data if a playground is necessary.
If discovery is unavailable on an older instance, use that instance's /api/v1/docs or the official endpoint reference. Never fall back to undocumented /rest/* routes.
3. Resolve the exact endpoint and schema
- Confirm the method, path, query parameters, request schema, required scope, and feature availability from discovery/OpenAPI.
- Treat IDs and cursors as opaque strings. URL-encode path and query values.
- Do not assume Cloud, Community, Business, and Enterprise instances expose identical capabilities.
- Do not infer that a
403 means an endpoint is absent; check API-key scopes, project role, ownership, license, and instance configuration.
- For credential payloads, retrieve
/credentials/schema/{credentialTypeName} instead of guessing fields.
Read references/public-api.md for the stable-version capability map, migration notes, and high-risk operation rules.
4. Read before writing
For an existing resource, fetch its current state and verify its ID, project, name, and relevant version before mutation. Build the smallest valid body from the discovered request schema.
- Do not send a GET response back unchanged as a create/update body: remove read-only fields and preserve only supported writable fields.
- A workflow update is a structural operation. Preserve
nodes, connections, and required settings unless the requested change intentionally replaces them.
- On current n8n versions, updating a published workflow republishes it by default. Use
publishIfActive=false when the user wants a draft and the target schema supports it.
- Credential reads omit secret data. Never treat a metadata response as a restorable credential backup.
- A webhook URL is not an authenticated public-API endpoint. Its authentication and payload contract come from the workflow's trigger configuration.
5. Execute safely
Use the API key only in the X-N8N-API-KEY header and send Accept: application/json. Add Content-Type: application/json only when sending JSON.
curl --silent --show-error --fail-with-body \
-X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-N8N-API-KEY: $N8N_API_KEY" \
--data-binary @payload.json \
"$N8N_BASE_URL/api/v1/<discovered-path>"
Avoid verbose HTTP tracing around secrets or credential payloads. Set reasonable connect and request timeouts in unattended code. Retry only idempotent reads automatically; do not blindly retry creates, retries, imports, pulls, or other side-effecting requests.
6. Paginate completely
List endpoints use cursor pagination. The documented default page size is 100 and the maximum is 250. Follow nextCursor until it is absent/null, preserving all original filters and URL-encoding the cursor. Do not silently report a first page as the complete result.
7. Verify the outcome
After a successful mutation:
- read the affected resource or use a filtered list call
- verify the requested state, project/folder placement, and publish/archive status as applicable
- for execution actions, verify the resulting execution ID and status without dumping execution data unnecessarily
- for data-table writes, verify the affected row count or returned rows
- for source-control pull, inspect the returned file list and publication result
Report partial success explicitly. A 2xx response proves request acceptance, not necessarily the user's end-to-end outcome.
Current terminology and boundaries
- Prefer publish/unpublish. The legacy
/activate and /deactivate workflow endpoints are deprecated on current stable n8n.
- The public API doesn't provide a generic "run any workflow" operation. Trigger a production webhook only when the workflow exposes one and the user authorizes the run.
/webhook-test works only while the editor is listening. Evaluation test-run endpoints are a separate feature.
- Use the public API, not the internal editor API. Session cookies and undocumented endpoints are outside this skill.
- n8n API availability, scoped keys, projects, source control, log streaming, SSO, and other capabilities vary by hosting plan, license, role, and configuration.
Error handling
400: inspect the discovered schema and rejected fields.
401: missing, expired, or invalid API key.
403: insufficient API-key scope, project permission, ownership, license, or policy restriction.
404: wrong base path/ID, inaccessible resource, unsupported endpoint, or hidden resource.
409: state conflict; inspect the response and current resource state before deciding whether to retry.
429 or transient 5xx: honor Retry-After when present and use bounded exponential backoff only where replay is safe.
Preserve the response status and body for diagnosis, but redact secrets, credential data, webhook URLs, and sensitive execution payloads from user-facing output.
1---2name: n8n-api3description: Use for authenticated work with an n8n instance through its public REST API: discover capabilities, inspect or manage workflows and executions, credentials, tags, variables, projects, folders, data tables, users, audits, insights, source-control pulls, and supported instance settings. Do not use for ordinary workflow design with no API calls, undocumented internal /rest endpoints, or webhook handling alone.4---56# n8n Public REST API78Use the public `/api/v1` API in a version-aware, least-privilege way. This skill was validated against stable n8n `2.36.8` on 2026-08-29, but the target instance's discovery response and OpenAPI document are authoritative.910## Required inputs1112Establish these before calling the API:1314- the instance base URL, including any configured path prefix and excluding a trailing slash15- an API key available through an environment variable or secret manager16- the intended operation and exact target resource17- explicit authorization for any mutation, especially publish, retry, stop, delete, package, settings, or source-control operations1819Do not ask the user to paste an API key into chat. Do not print, log, commit, or persist the key. If no key is available, explain how to create one in **Settings > n8n API** and let the user place it in the environment.2021Use `N8N_BASE_URL` and `N8N_API_KEY` in examples. If the user's environment already uses `N8N_HOST`, preserve it rather than renaming configuration unnecessarily.2223## Workflow2425### 1. Classify the request2627- Read-only inspection can proceed once the target instance is known and credentials are available.28- A write requires the user's requested outcome to clearly authorize that write.29- Bulk changes, execution retries, workflow publication, source-control pulls, and destructive operations require a preview of the exact scope before execution.30- If the user asks only for code or instructions, do not call their instance.3132### 2. Discover what this instance and key support3334Prefer capability discovery over a memorized endpoint list:3536```bash37curl --silent --show-error --fail-with-body \38 -H "Accept: application/json" \39 -H "X-N8N-API-KEY: $N8N_API_KEY" \40 "$N8N_BASE_URL/api/v1/discover?resource=workflow&include=schemas"41```4243`GET /discover` returns the scopes, resources, operations, endpoint paths, and a `specUrl` visible to the current API key. Use `resource` and `operation` filters to keep the response focused. Add `include=schemas` when constructing a request body.4445For self-hosted instances, the built-in Swagger UI is at `/api/v1/docs`. It operates on live data. The hosted documentation playground proxies calls through Scalar; never enter a production key there. Use a limited-scope test key and test data if a playground is necessary.4647If discovery is unavailable on an older instance, use that instance's `/api/v1/docs` or the official endpoint reference. Never fall back to undocumented `/rest/*` routes.4849### 3. Resolve the exact endpoint and schema5051- Confirm the method, path, query parameters, request schema, required scope, and feature availability from discovery/OpenAPI.52- Treat IDs and cursors as opaque strings. URL-encode path and query values.53- Do not assume Cloud, Community, Business, and Enterprise instances expose identical capabilities.54- Do not infer that a `403` means an endpoint is absent; check API-key scopes, project role, ownership, license, and instance configuration.55- For credential payloads, retrieve `/credentials/schema/{credentialTypeName}` instead of guessing fields.5657Read [references/public-api.md](references/public-api.md) for the stable-version capability map, migration notes, and high-risk operation rules.5859### 4. Read before writing6061For an existing resource, fetch its current state and verify its ID, project, name, and relevant version before mutation. Build the smallest valid body from the discovered request schema.6263- Do not send a GET response back unchanged as a create/update body: remove read-only fields and preserve only supported writable fields.64- A workflow update is a structural operation. Preserve `nodes`, `connections`, and required `settings` unless the requested change intentionally replaces them.65- On current n8n versions, updating a published workflow republishes it by default. Use `publishIfActive=false` when the user wants a draft and the target schema supports it.66- Credential reads omit secret data. Never treat a metadata response as a restorable credential backup.67- A webhook URL is not an authenticated public-API endpoint. Its authentication and payload contract come from the workflow's trigger configuration.6869### 5. Execute safely7071Use the API key only in the `X-N8N-API-KEY` header and send `Accept: application/json`. Add `Content-Type: application/json` only when sending JSON.7273```bash74curl --silent --show-error --fail-with-body \75 -X POST \76 -H "Accept: application/json" \77 -H "Content-Type: application/json" \78 -H "X-N8N-API-KEY: $N8N_API_KEY" \79 --data-binary @payload.json \80 "$N8N_BASE_URL/api/v1/<discovered-path>"81```8283Avoid verbose HTTP tracing around secrets or credential payloads. Set reasonable connect and request timeouts in unattended code. Retry only idempotent reads automatically; do not blindly retry creates, retries, imports, pulls, or other side-effecting requests.8485### 6. Paginate completely8687List endpoints use cursor pagination. The documented default page size is 100 and the maximum is 250. Follow `nextCursor` until it is absent/null, preserving all original filters and URL-encoding the cursor. Do not silently report a first page as the complete result.8889### 7. Verify the outcome9091After a successful mutation:9293- read the affected resource or use a filtered list call94- verify the requested state, project/folder placement, and publish/archive status as applicable95- for execution actions, verify the resulting execution ID and status without dumping execution data unnecessarily96- for data-table writes, verify the affected row count or returned rows97- for source-control pull, inspect the returned file list and publication result9899Report partial success explicitly. A `2xx` response proves request acceptance, not necessarily the user's end-to-end outcome.100101## Current terminology and boundaries102103- Prefer **publish/unpublish**. The legacy `/activate` and `/deactivate` workflow endpoints are deprecated on current stable n8n.104- The public API doesn't provide a generic "run any workflow" operation. Trigger a production webhook only when the workflow exposes one and the user authorizes the run. `/webhook-test` works only while the editor is listening. Evaluation test-run endpoints are a separate feature.105- Use the public API, not the internal editor API. Session cookies and undocumented endpoints are outside this skill.106- n8n API availability, scoped keys, projects, source control, log streaming, SSO, and other capabilities vary by hosting plan, license, role, and configuration.107108## Error handling109110- `400`: inspect the discovered schema and rejected fields.111- `401`: missing, expired, or invalid API key.112- `403`: insufficient API-key scope, project permission, ownership, license, or policy restriction.113- `404`: wrong base path/ID, inaccessible resource, unsupported endpoint, or hidden resource.114- `409`: state conflict; inspect the response and current resource state before deciding whether to retry.115- `429` or transient `5xx`: honor `Retry-After` when present and use bounded exponential backoff only where replay is safe.116117Preserve the response status and body for diagnosis, but redact secrets, credential data, webhook URLs, and sensitive execution payloads from user-facing output.