# n8n

The Wire node for [n8n](https://n8n.io) lets any workflow write entries into a Wire container. Use it as an action at the end of a pipeline, or as a tool that an n8n AI Agent can call on its own.

The node is open source and published as an npm package: [`n8n-nodes-wire`](https://www.npmjs.com/package/n8n-nodes-wire) · [source on GitHub](https://github.com/usewire/n8n-nodes-wire).

## Install

In n8n Cloud or any self-hosted n8n (v1.17 or later):

1. Open **Settings → Community Nodes**
2. Click **Install**
3. Enter the package name: `n8n-nodes-wire`
4. Accept the risk notice and install

On self-hosted, you can also install from the command line:

```bash
npm install n8n-nodes-wire
```

Then restart n8n.

## Setup

Each Wire credential in n8n points at one container. You can create as many as you want (one per container, or one per environment).

1. In [Wire](https://app.usewire.io), open the container you want to write to and go to the **Sources** tab.
2. Click **Setup** on the **n8n** card.
3. Copy the **Wire Address**. It looks like:

   ```
   wire://your-org/your-container
   ```

4. Click **Create container API key**, give it a name (e.g. `n8n`), and copy the revealed key.
5. In n8n, open **Credentials → New → search "Wire"**, pick **Wire Container**.
6. Paste the **Wire Address** and **API Key**.
7. Click **Test**. A successful test means n8n reached your container.

You can rename the credential to anything you want (e.g. `Prod Container`, `Q2 Planning`) so it's obvious which one you're picking later in a workflow.

## Write an entry

Add a **Wire** node to your workflow. Pick your credential and map the **Content** field.

### What the fields do

| Field | Purpose |
|-------|---------|
| **Content** (required) | The data you want to store. A string, markdown, or an expression resolving to an object. |
| **Tags** | Comma-separated labels for later filtering. |
| **Source Override** | Custom label for where the entry came from. By default, Wire stamps it with `n8n:{workflowId}:{nodeName}`. |
| **Metadata** | JSON blob for audit info (run IDs, upstream record IDs, etc.). |

### Examples

**Store the whole input item as structured data**

Set **Content** to the expression `{{ $json }}`. Wire recognizes the object and stores it as structured JSON.

**Store a specific field as text**

Set **Content** to `{{ $json.summary }}` or any other property. Strings are stored as text.

**Store a fixed string**

Set **Content** to a literal like `Daily sync completed`. Useful for heartbeat or event-style writes.

## Use it as an AI Agent tool

The Wire node is `usableAsTool`, which means an n8n **AI Agent** node can call it directly. Build an AI agent that reads a prompt and decides when to save a note, log a decision, or capture a finding into Wire.

1. Add an **AI Agent** node (under AI / LangChain in the node palette).
2. Give it a chat model and a system prompt.
3. Under **Tools**, add the **Wire** node and pick your credential.
4. Run the agent. When its reasoning produces something worth storing, it calls Wire with a content string and the write lands in your container, tagged with the agent's source.

This works without any special glue code. The same node you use for deterministic writes is also available to agents as a tool.

## What gets written

Every successful call makes one entry in the container, equivalent to a `POST /container/:id/tools/write` REST call. Wire auto-classifies the content (text, markdown, or structured) and tags the entry with the workflow and node name so you can trace where each entry came from in `wire_explore` or `wire_search` later.

See [REST API → Write](/mcp/rest-api/#write) for the underlying endpoint contract.

## Errors

The node surfaces Wire's error codes as plain messages:

- **Insufficient credits** — writes themselves are free, but a container is locked when the organization's credit balance is below its floor. Top up at [usewire.io](https://usewire.io).
- **API key was rejected** — the key is invalid, revoked, expired, or doesn't belong to the container in the Wire Address.
- **Not found** — the Wire Address in the credential is wrong.

## Links

- [npm: `n8n-nodes-wire`](https://www.npmjs.com/package/n8n-nodes-wire)
- [GitHub: `usewire/n8n-nodes-wire`](https://github.com/usewire/n8n-nodes-wire)
- [Report an issue](https://github.com/usewire/n8n-nodes-wire/issues)