# Desktop Clipboard

> Read/Write to System Clipboard.

Source: https://docs.sommatic.ai/en/nodes/io.desktop.clipboard/

- Slug: `io.desktop.clipboard`
- Family: Input and output
- Version: 1.0.0
- Status: Available
- Execution: async

Read/Write to System Clipboard.

## Configuration

- `operation` (string, required): Default: `read`. Allowed values: `read`, `write`.
- `content` (string, optional): Content to write

## Output ports

- `out` (default): Operation successful
- `error`: Clipboard access failure

## Input contract

- `operation` (string, required)
- `content` (string, optional)

## Output contract

- `result` (string, optional): Clipboard content (read) or success status (write)

## In expressions

What a later node can read from this node's output with `$("Desktop Clipboard").item.json.<path>` (write your node's label instead of `Desktop Clipboard`). **Editor** marks the paths the workflow editor suggests under Previous Nodes (the output contract); **Worker** marks the paths the worker really returns through `out`, from the output shown in Ports.

- `$("Desktop Clipboard").item.json.result` (string) = `"INV-2026-0042"`: Clipboard content (read) or success status (write)


## How it works

Reads the text in the system clipboard, or writes text to it, on the machine that runs the worker.

1. Resolves the node config. `operation` and `content` fall back to the same keys of the incoming payload when they are empty in the config; `operation` defaults to `read`.
2. With `write`, writes `content` (an empty string when missing) to the clipboard and returns `{ result: { written: true } }`.
3. Any other value of `operation` reads the clipboard and returns its text as `result`.
4. Any failure of the clipboard access leaves through `error`.

## In a workflow

### Node

```json
{
  "node_id": "node-copy-invoice-number",
  "label": "Copy invoice number",
  "operator_slug": "io.desktop.clipboard",
  "operator_version": "1.0.0",
  "config": {
    "operation": "write",
    "content": "{{ $json.invoice_number }}"
  }
}
```

### Envelope

```json
{
  "ok": true,
  "data": {
    "result": {
      "written": true
    }
  },
  "port": "out"
}
```

## Output ports (behaviour in the code)

### `out`

The clipboard was read (`result` is its text) or written (`result` is `{ written: true }`).

```json
{
  "result": "INV-2026-0042"
}
```

### `error`

The clipboard could not be accessed.

```json
{
  "error": "<clipboard error message>"
}
```

## Behaviour in the code

- `operation`: Only `write` writes; every other value, including an unknown one, reads the clipboard.

## Errors

| Message | Port | Cause and fix |
| --- | --- | --- |
| `<clipboard error message>` | `error` | The machine that runs the worker has no desktop session or clipboard utility available (for example, a headless server). Run this node only where a desktop session exists. |

## Notes and limits

- The node acts on the clipboard of the host where the orchestrator worker runs, not on the user's browser.
- Only text is supported. A write replaces the whole clipboard content.


## Contracts (JSON Schema)

### All (`*.definition.js`)

```json
{
  "slug": "io.desktop.clipboard",
  "name": "Desktop Clipboard",
  "category": "io",
  "version": "1.0.0",
  "description": "Read/Write to System Clipboard.",
  "capabilities": [
    "clipboard",
    "desktop"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "operation": {
        "type": "string",
        "enum": [
          "read",
          "write"
        ],
        "default": "read"
      },
      "content": {
        "type": "string",
        "description": "Content to write"
      }
    },
    "required": [
      "operation"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "operation": {
        "type": "string"
      },
      "content": {
        "type": "string"
      }
    },
    "required": [
      "operation"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "result": {
        "type": "string",
        "description": "Clipboard content (read) or success status (write)"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Result",
      "description": "Operation successful",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Clipboard access failure",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "desktop-agent"
  ],
  "tags": [
    "desktop",
    "clipboard"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_link_loom",
    "profile": {
      "name": "Link Loom",
      "verified": true,
      "url": "https://me.veripass.com/link-loom",
      "logo_url": null
    }
  }
}
```

### config_schema

```json
{
  "type": "object",
  "properties": {
    "operation": {
      "type": "string",
      "enum": [
        "read",
        "write"
      ],
      "default": "read"
    },
    "content": {
      "type": "string",
      "description": "Content to write"
    }
  },
  "required": [
    "operation"
  ]
}
```

### input_contract_schema

```json
{
  "type": "object",
  "properties": {
    "operation": {
      "type": "string"
    },
    "content": {
      "type": "string"
    }
  },
  "required": [
    "operation"
  ]
}
```

### output_contract_schema

```json
{
  "type": "object",
  "properties": {
    "result": {
      "type": "string",
      "description": "Clipboard content (read) or success status (write)"
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "out",
    "label": "Result",
    "description": "Operation successful",
    "is_default": true,
    "supports_condition": true
  },
  {
    "port_id": "error",
    "label": "Error",
    "description": "Clipboard access failure",
    "is_default": false,
    "supports_condition": false
  }
]
```
