n8n:public-api

Add, migrate, or update n8n Public API v1 endpoints with controllers, DTOs, and OpenAPI wiring.

203k|60.5k|Updated Jun 22, 2019
One-click install
npx skills add https://github.com/n8n-io/n8n --skill n8n-public-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n:public-api
Source: https://github.com/n8n-io/n8n/tree/main/.agents/skills/public-api
Command: npx skills add https://github.com/n8n-io/n8n --skill n8n-public-api

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Building or modifying n8n's Public API v1 endpoints requires strict adherence to architectural rules, decorator patterns, and OpenAPI generation conventions. Without guidance, developers risk breaking public contracts, leaking secrets, or violating ESLint guardrails.

Core Features & Use Cases

  • Controller Creation: Scaffold new @PublicApiController classes with proper decorators for API-key scopes, RBAC, pagination, and OpenAPI metadata.
  • Legacy Migration: Migrate endpoints from the legacy express-openapi-validator (EOV) handler system to the modern decorator-based controller architecture.
  • DTO and Pagination: Build strict input DTOs, allowlist output DTOs, and implement cursor-based pagination for list endpoints.
  • Use Case: Expose a new internal service (e.g., data tables) through /api/v1 by creating a public controller, defining DTOs in @n8n/api-types, registering the route, and regenerating the OpenAPI spec.

Quick Start

Add a new public API endpoint for the workflows resource by creating a controller class with the @PublicApiController decorator and registering it in the controllers index.

Frequently Asked Questions about n8n:public-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new endpoint to n8n Public API v1?

Create a class decorated with @PublicApiController('/base') under v1/controllers/, inject the shared service, add route methods with @Get/@Post/@Put/@Delete, and register the controller via a side-effect import in v1/controllers/index.ts.

What is the difference between @ApiKeyScope and @ProjectScope?

@ApiKeyScope checks what an API key is granted to do, while @ProjectScope or @GlobalScope checks what a user may do via RBAC. Use both independently when the authorization model requires both API-key grants and user permissions.

How does cursor pagination work in n8n Public API?

List endpoints use cursor-based pagination with limit and an opaque cursor query parameter. Decode incoming cursors with decodeCursor, pass offset/limit to the service, and return { data, nextCursor } with nextCursor: null on the last page.

Can I migrate a legacy EOV endpoint to the new controller system?

Yes, migrate legacy express-openapi-validator handlers to @PublicApiController classes while preserving the public contract including path, method, scopes, status codes, and response shape. Remove legacy wiring only after the new controller is registered and tests pass.

Why does the OpenAPI spec drift test fail after adding a controller?

The generated-spec-drift test fails when committed OpenAPI fragments are stale. Run the full pnpm build to regenerate handlers/<feature>/spec/paths/*.generated.yml and openapi.decorator-routes.generated.yml, then commit the updated files.

How should write-only secrets be handled in PUT requests?

GET returns a sentinel placeholder instead of the real secret. PUT with the exact sentinel means keep the stored secret; any other value replaces it. Never persist the sentinel as a real secret or echo real secrets in responses.