Building a custom n8n node: declarative or programmatic

A custom n8n node connects a workflow canvas to your internal API. Choosing declarative or programmatic style early determines build effort, testing and who maintains the node after release.

On this page

When a custom n8n node is the right way to connect an internal API

A custom node is the right choice when several workflows need the same internal system and each one would otherwise repeat the same HTTP Request setup: the base URL, authentication, pagination, error handling and field mapping. In n8n, a custom node is a TypeScript package with three core parts: a description that defines the operations and parameters shown on the canvas, a credentials definition that tells n8n what secrets to collect and how to store them, and execution logic that calls the API and returns items. Teams that build the same logic into a Code node in every workflow end up with copies that drift apart, and the credentials sit inside workflow code where reviewers rarely look. A single node with a reviewed credential type keeps that logic in one place that the whole team can test and change.

A custom node is not the answer for every integration. For a one-off call to an endpoint that only one workflow uses, an HTTP Request node or a short Code node is usually easier to read and maintain, and it adds no package to version or ship. The trade-off turns on reuse, the number of operations, and whether non-developers will build workflows against the system. Before committing, confirm which of your internal APIs have stable documented endpoints, who owns each one, and whether they require authentication flows that n8n's built-in credential types do not already cover.

Licensing shapes where the node can live. n8n is source-available under the Sustainable Use License, not OSI open source, and the license permits use or modification only for your own internal business purposes or for non-commercial or personal use. An internal connector used inside your organization fits that purpose, but distributing the node outside your organization, or embedding it in a product you sell, falls outside it. Confirm with your legal team how the node will be used before you plan distribution, and review the n8n LICENSE.md text against your intended use.

Declarative or programmatic: how the two styles differ

In the declarative style, you describe the node in configuration: its operations, the fields a user fills in and the routing rules that map those fields to HTTP requests. n8n builds and sends the calls from that description, so the node file is mostly configuration with little control flow.

  • Build effort: Usually small for a REST API with consistent resources, paths and parameter patterns. Each new operation is typically a new block of properties and routing, not new logic.
  • Testing surface: Mostly the mapping from fields to requests. Check the generated URL, query parameters, headers and body for each operation against the API documentation, and test several error responses.
  • Limits: Chained calls, custom pagination or binary handling beyond the built-in options may not fit. Confirm each case against the node documentation for your target n8n version.
  • When the API changes: A renamed path or parameter breaks the routing for every operation that uses it, and the failure often surfaces only when a user runs a workflow.

Check whether the internal API follows one naming and pagination pattern across endpoints, because irregular conventions multiply the routing rules your team must maintain.

Which node options fit which internal API

This table compares the four ways to reach an internal API from n8n across reuse, authentication, pagination, binary data, versioning and ownership. Read each row against your API's shape, and use the takeaway to decide whether a simple HTTP Request node is enough or a packaged custom node is worth its maintenance cost.

ConcernDeclarative nodeProgrammatic nodeCode node or HTTP Request node
Reuse across teamsGood fit: a shared package that teams install once and configure through credentials and parametersGood fit: full control of shared logic, but every team depends on the package's code and release cyclePoor fit: each workflow carries its own copy of the request logic, so changes spread by hand
Custom authenticationCovers common schemes through the credentials file; unusual signing flows may need a different styleHandles any scheme in code, including token exchange and request signing, at the cost of more code to testHandles any scheme inline, but secrets sit in workflow logic unless they come from credentials
Pagination logicSupported for common cursor and offset patterns; confirm the pagination options your n8n version offersFull control over loops, rate limits and partial-failure handling inside the nodeManual loops in the workflow or Code node; workable for a few endpoints, hard to keep consistent
Binary file handlingConfirm current support for binary input and output in the declarative property types before committingFull access to binary data for upload and download, including streaming and transformationsPossible through the HTTP Request node or Code node, but large files need careful memory handling
Versioning and releasesNode version changes are declared in the description, so existing workflows keep working when parameters changeVersioned in code with explicit migration paths for workflows built on earlier versionsChanges apply the moment a workflow is edited; there is no version contract for other users
Maintenance ownershipSmaller surface to maintain, which suits a team that owns one API and few custom behaviorsLarger surface and more tests; needs a named owner who rebuilds and retests after each n8n upgradeNo package to maintain, but every workflow owner becomes an accidental maintainer of the API calls
Best whenThe API is REST-like, the auth scheme is standard and several teams need the same operationsThe API needs custom logic, unusual auth or binary handling and the team can maintain TypeScript codeOne or two workflows call the API, the logic is short and nobody else needs it
Does not fit whenThe API needs custom signing, complex pagination or logic that the declarative format cannot expressOnly one workflow needs the call, or no engineer will own releases after the first versionMany teams depend on the calls, or the API needs auditable, versioned behavior

Design decisions to settle before writing any code

Six decisions shape the node's surface, its security posture and its life after release. Settle them in a short design review with the API owner, the security team and the people who will use the node, because each one is expensive to change once workflows depend on the node.

Resources and operations to expose

List the API resources and operations your teams need, then cut the list to what a workflow actually calls. Every operation you expose becomes a field users configure and a surface you must test on each n8n upgrade. Ask the API owner which endpoints are stable and which are internal, and ask the security lead whether any write or delete operation needs an approval step before it ships.

Credential type

Decide whether the API uses an API key, OAuth2 or a custom header scheme, because n8n builds the credential form and the authentication logic from this choice. Confirm the auth flow with the API owner before writing the credentials file, including token lifetime, refresh behavior and whether a service account can be used. The security team should approve where secrets are stored and who can read them.

Version naming

Decide how node versions will be named and when a new version is introduced, since existing workflows keep the version they were saved with. A breaking change to a parameter should create a new node version rather than alter an existing one. The node owner should write the rule down and agree it with the team that maintains the workflows that depend on it.

Whether trigger nodes are needed

Decide whether the connector only acts on demand or must also start workflows when something happens in the internal system. Polling and webhook triggers carry different load, authentication and failure behavior, and a trigger that needs a public endpoint needs network review. Ask the integration owner which events matter and whether the source system can push them at all.

Error mapping to error output

Decide which API failures should stop a workflow and which should route to an error output that a workflow can handle. Map authentication failures, rate limits, validation errors and server errors separately, and never place secret values or full response bodies in error messages. The engineering lead and the workflow owners should agree the mapping, because it defines what alerting and retries will see.

Naming conventions for internal use

Decide the display name, internal package name and node names that teams will see in the editor and in exported workflows. Clear names prevent a private node from being confused with a public community package, and they keep credential types easy to find when several connectors share a prefix. Assign one owner to approve names before the first release, since renaming later breaks saved workflows.

How the build sequence runs from credentials file to release

The sequence turns an internal API contract into a versioned, lint-clean n8n node package that your team can install on its own instances and hand to a named maintainer. Each step ends with a check you can repeat in your own environment before moving on.

  1. Confirm the API contract and auth flow

    Before any code, the owner of the internal API and the n8n builder agree on the endpoints, request and response shapes, error format, pagination, rate limits and the authentication method, such as an API key header, OAuth2 or a token exchange. Write these down as a short contract document that names the staging base URL and a test account. The step is done when someone outside the build team can read the document and make one successful authenticated call to staging with a tool such as curl, and the expected error responses for a bad or expired credential are recorded.

  2. Scaffold the node package from the n8n-node tool

    Run the n8n-node scaffolding tool from n8n's node development documentation to generate the package layout, TypeScript configuration and a starter node file. Confirm the tool version matches the n8n version your fleet runs, because node interfaces change between releases. Set the package name to your internal naming convention and keep it out of the public npm namespace. The step is done when the generated project installs its dependencies and builds without errors on your build machine.

  3. Define the credentials file

    Create the credentials file that describes the fields the node needs, such as base URL, API key or client ID and secret, and mark secret fields so n8n stores them encrypted. Add a credential test that makes a lightweight, read-only call to the staging API, so the credential form can report success or failure when users save it. The step is done when saving a credential against staging returns a success message, and saving a deliberately wrong key returns a clear failure message without leaking the secret into logs.

  4. Build node properties and execution logic

    Choose declarative or programmatic style for each resource based on the contract from the first step. Declarative nodes describe requests and routing in configuration, which suits plain REST resources, while programmatic nodes give full control over pagination, branching and error handling. Define resources, operations and parameters, then implement the request logic and map responses to output items. The step is done when each operation runs manually in a test workflow against staging and returns items with the field names the contract documents.

  5. Lint and test against the staging API

    Run the linter that ships with the scaffold, and fix every reported issue rather than suppressing rules without a recorded reason. Add automated tests for parameter validation, error mapping and at least one integration test that calls the staging API with a dedicated test credential stored in your CI secrets. Confirm that the CI job cannot reach production endpoints. The step is done when lint passes cleanly and the integration tests pass on a clean checkout, not only on the developer machine.

  6. Version the node and record changes

    Set the package version using semantic versioning, bump the minor version for added operations and the major version for breaking changes to parameters or output shape, and write a changelog entry for each release. Tag the commit in your source control system so every installed build can be traced to source. The step is done when a reviewer can read the changelog and identify which version a given workflow depends on.

  7. Package the node for internal installation

    Build the production package and publish it to your private package registry or deliver it as a tarball, then install it on a non-production n8n instance using the method your deployment supports. Confirm the node appears in the editor, that its credential type loads, and that a sample workflow runs end to end. Check your n8n version against the node's declared compatibility before rolling it out to other environments. The step is done when a fresh instance installs the package and the sample workflow completes without manual file edits.

  8. Hand over and assign ownership

    Transfer the node to a named maintainer team with the contract document, test suite, changelog, runbook for rotating the test credential and a list of the internal API owners to contact on breaking changes. Agree who reviews n8n upgrade impacts, because each upgrade may require a rebuild and retest of the node. Confirm the owner, the escalation path and the upgrade review cadence in writing. The step is done when the maintainers have built, tested and installed a minor change themselves without help from the original builders.

How the node moves from the internal API into a workflow

The node starts as a package in your repository, with a description file that defines its operations and a credentials file that defines how it authenticates. When n8n loads the package, the node's parameters become fields on the canvas. At run time, the n8n runtime reads the saved credentials from its database, decrypts them with the encryption key, and sends the request from inside your network to the internal API. Check where the encryption key lives and which hosts the runtime can reach before you approve the design.

Custom node flow from package to internal API, with the credential store inside the boundary.

How versioning and linting keep a private node stable

A private node has two version lines that must be managed separately: the version of your node package and the version of the n8n release it runs on. The package follows semantic versioning, so a change that breaks existing workflows should move the major version, while additions and fixes move the minor or patch version. The n8n release is a different clock. n8n uses semantic versioning and ships minor releases roughly weekly, with n8n 2.43 released on 6 October 2026 as the most recent dated example in the supplied release history. Your team should decide in advance which n8n versions the node is tested against and who signs off when a new one appears.

Inside the node itself, version properties let a workflow saved against an older definition keep running after you change the node. A common pattern is to give the node a version list and branch the description and execute logic by version, so a parameter renamed in version 2 still resolves for workflows built on version 1. Confirm the exact property names and branching approach against the node development documentation for your n8n release before you rely on them. Linting and tests should catch the changes that break saved workflows: removed or renamed parameters, changed default values, altered credential field names and altered output shapes. Run the linter that ships with the n8n node tooling on every commit, and keep a small set of fixture workflows that load each supported version and assert the output fields downstream nodes depend on.

Plan the retest as a recurring cost, not a one-time task. Every n8n upgrade needs a run of the fixture workflows against the new release, and a failure means either a fix in the node or a pinned n8n version until the fix ships. If the node is shipped inside a custom Docker image, as described in the sibling topic on installing private custom nodes, the image must be rebuilt for each n8n upgrade you adopt, so the node and the host release move together. Ask the team that will own the node how long they expect each rebuild and retest cycle to take, who approves an upgrade, and whether a pinned n8n version is an acceptable fallback for your change process.

Security risks in custom node credentials and API access

A custom node handles the credentials and API calls that connect n8n to your internal systems, so its security depends on how those secrets are stored, scoped, logged and reviewed. The cards below cover the controls to decide and confirm before the node reaches production workflows.

Encryption key shared across processors

n8n stores credentials encrypted in the database, and in queue mode every worker and webhook processor must hold the main instance's encryption key to read them. Treat that key as a high-value secret: restrict who can read the environment where it lives, rotate it only with a planned credential migration, and confirm that every worker and webhook processor receives the same value. A mismatched key fails at runtime, so test a credential-backed node on each process type.

Queue mode docs

Least-privilege API tokens

Create a dedicated service account and token for the node, limited to the endpoints and operations its workflows actually use. Ask the owner of the internal API which scopes exist, whether tokens can be time-limited, and how revocation works. Avoid administrator tokens in the node's credential type, and separate read-only and write operations so a workflow that only reads data cannot change records.

Logging that never prints secrets

Node code often logs request details while debugging, and those logs can capture bearer tokens, passwords or full response bodies with personal data. Review every log statement and error message in the node, mask credential fields, and avoid echoing the full request configuration. Confirm that n8n execution data retention and any log forwarding do not store values your policy forbids.

Outbound calls limited to approved hosts

A declarative or programmatic node can send requests to any URL a workflow supplies, which can expose credentials to a host you did not intend. Restrict the base URL to the internal API hostname in the credential definition, reject redirects to other hosts, and confirm that network egress rules block the node's runtime from reaching unapproved destinations. Test this with a deliberately misconfigured URL.

Code review before internal publishing

Review the node package before it is installed in any environment, including dependency versions and install scripts, not only the node's own logic. Require a second reviewer, record the approved commit, and build the package from that commit. Ask who owns approvals after release, because a change to a shared node affects every workflow that uses it.

Questions teams ask before building a custom n8n node

What drives the cost of building a custom n8n node?

The main driver is how much of the internal API the node must cover and how hard its authentication is. A node that wraps a few read endpoints with a simple API key costs far less to build than one that covers write operations, paging, file transfers, webhooks and OAuth2 flows. Other drivers include the number of operations, how much the API documentation is complete, how many environments need testing, and whether the node must follow your internal naming and security standards. Ask any partner for a quote that lists each operation, each credential type and each test environment separately, and states what is one-time work (the build and first release) and what recurs (upgrades, fixes and API changes). Costs for keeping the node current are often underestimated, so ask for them in writing.

Can our internal team build a custom node without outside help?

Yes, if the team has working knowledge of TypeScript and Node.js, because n8n itself is built with those technologies and custom nodes are written in them. The team also needs someone who understands the internal API well enough to model its resources, authentication and error responses. The first build is usually where skills gaps appear: credential handling, the declarative versus programmatic choice, linting and packaging, and running the node inside a real n8n instance. A common approach is for the internal team to build the first node with a short review from an experienced n8n developer, then keep ownership in-house. DeployOpen can take the build end to end under a fixed-scope agreement, or review and harden work your team has already started.

How long does a typical custom node build take?

The duration depends mainly on the size and quality of the API the node will wrap. Duration grows with the number of resources and operations, the complexity of authentication, the amount of pagination and error handling, and how many test cases your team requires before release. Delays often come from waiting on access to a test account, unclear API behavior, or review cycles with security and platform teams, not from the coding itself. Ask for a timeline that is tied to a written list of operations and acceptance tests. Because no reliable figure applies across all internal APIs, treat any single duration you are given as a claim to verify against that scope.

What does the build need from our team before it starts?

The build needs five inputs. First, API documentation or an OpenAPI description that covers endpoints, parameters, response shapes, pagination and error codes. Second, a test account with the permissions the node will use, plus clear rules on which operations are allowed against production data. Third, a staging environment where the node can be installed and tested without touching live systems. Fourth, a named owner on your side who can answer questions about business rules and approve design decisions. Fifth, the security requirements for credentials, such as how API keys or tokens are issued, rotated and stored. Agree these inputs in the written scope, because a missing test account or staging instance is one of the most common causes of schedule slippage.

Who maintains the custom node after release?

The owner of the node must be named in writing before release, and that owner is responsible for keeping it working. n8n uses semantic versioning and ships minor releases roughly weekly, so a node that depends on n8n internals or on an outdated node API can break after an upgrade and needs regression testing. The owner also handles changes to the internal API, dependency updates, security patches and the request queue from users. Options include an internal team, a DeployOpen retainer for upgrades, fixes and continuous testing, or a mix of both. Confirm who receives alerts when a workflow using the node fails, and who approves a new release of the package.

Should we use a Code node or HTTP Request node instead?

Use the HTTP Request node for a handful of simple calls that a few workflows need, because it requires no packaging and is quick to change. Use the Code node for logic that is specific to one workflow and is easy to keep beside it. Build a custom node when the same internal API is called from many workflows, when users need a guided credential form and resource picker, or when the calls need consistent error handling and versioning across teams. Custom nodes also make access to the API easier to review because the authentication and operations sit in one package. Code node module access is a separate decision with its own security cost, so check that policy before depending on external packages inside Code nodes.

Does an internal custom node raise licensing questions?

n8n is licensed under the Sustainable Use License, which permits use or modification for your own internal business purposes. An internal node that connects to your own systems and runs only inside your organization generally fits that purpose, but your legal team should confirm it against the license text. Files with .ee in their name or directory are covered by the n8n Enterprise License and need a valid Enterprise license, so a custom node must not copy or depend on those files. Using n8n as a backend for an external product, or distributing a node to outside parties, falls under different terms. Read the n8n LICENSE.md and document your interpretation before the node is shared.

How DeployOpen scopes and supports a custom n8n node

DeployOpen scopes a custom n8n node as a fixed-scope engagement. Before any build starts, the scope, deliverables and timeline are agreed in writing. For a connector, that written scope names the internal API operations the node will expose, the authentication method and credential fields, whether the node is declarative or programmatic, the resources and operations covered, the test cases, the packaging route into your n8n image, and who receives the source repository and documentation. A quote follows from that written scope, so the decisions that drive cost, such as the number of operations, the complexity of authentication and the amount of custom logic in the execute method, are visible to you before you commit.

DeployOpen is a Chainscore Labs company. It plans, implements, hardens, documents and supports self-hosted open-source platforms inside the client's own infrastructure, including the cloud accounts, data centers or air-gapped networks where the node will run. DeployOpen does not publish a price list. Cost depends on the written scope, and you should ask for a quote that separates design, build, testing, packaging, and handover, and states which items are one-time and which recur. Confirm with your own environment team which hosting and deployment assumptions the quote should cover before you ask for one.

Ongoing work after release is optional and can be contracted as a retainer. A retainer can cover n8n version upgrades that require rebuilding the custom node image, dependency updates, changes to the internal API, and continuous testing of the node against your current n8n release. Ask any provider to state in the quote who owns the node code after handover, who answers when the internal API changes, and how upgrades are tested before they reach production. These answers matter more than the build itself, because a custom node that no one maintains becomes a security and operations liability on the next n8n release.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.