On this page
Sommatic Docs
Open portal

Decrypt Data

Decrypts a value produced by crypto.encrypt or $encrypt.

View as Markdown
Open in
Identity Available crypto.decrypt Version 2.0.0 Execution: sync

Decrypts a v1.<iv>.<tag>.<ciphertext> token produced by crypto.encrypt and returns the original JSON value under data.

How it works

  1. Resolves the config; encrypted is usually {{ $json.encrypted }}.
  2. Leaves through error with encrypted data is required when encrypted is empty.
  3. Picks the key: connection_id first, otherwise the literal key.
  4. Checks the format: four dot-separated parts, the first one v1.
  5. Decrypts with AES-256-GCM and verifies the authentication tag: a wrong key or an altered token fails.
  6. Returns { data: <original value> } on out, with the audit record in meta.crypto.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-decrypt-payment",
  "label": "Decrypt payment details",
  "operator_slug": "crypto.decrypt",
  "operator_version": "2.0.0",
  "config": {
    "connection_id": "pi-credential-xxxx",
    "encrypted": "{{ $json.encrypted }}"
  }
}

Configuration

connection_id string Optional

Sommatic AI credential resolved server-side (recommended). Accepts credentials of type `encryption-key`.

key string Optional

Encryption key as a literal. Allowed, but it is stored in the flow, its version history and Git: prefer connection_id.

encrypted string Required

v1.<iv>.<tag>.<ciphertext>

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

connection_id
Takes precedence over the literal key. The credential is resolved on the server when the node runs, so the secret never appears in the flow. A string secret is used as the key; an object secret must carry key or secret. It must hold the same key used by crypto.encrypt.
key
A literal key works, but it is stored in the flow, its version history and Git, and meta.warnings reports it on every run. Prefer connection_id.

Output ports

out default

The token was decrypted and authenticated.

Data
{
  "data": {
    "card_last4": "4242",
    "amount": 129.9,
    "currency": "USD"
  }
}
error

The token is missing or malformed, the key is wrong, or the credential cannot be resolved.

Data
{
  "error": "Decryption failed: wrong key or tampered value"
}

In expressions

What a later node can read from this node's output with $("Decrypt Data").item.json.<path> (write your node's label instead of Decrypt Data). 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.

ExpressionEditorWorker
$("Decrypt Data").item.json.dataany= {…}Decrypted value
$("Decrypt Data").item.json.data.card_last4stringNot suggested by the editor= "4242"—
$("Decrypt Data").item.json.data.amountnumberNot suggested by the editor= 129.9—
$("Decrypt Data").item.json.data.currencystringNot suggested by the editor= "USD"—

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Errors

Message Port Cause and fix
encrypted data is required error encrypted is empty.
Invalid encrypted value: expected v1.<iv>.<tag>.<ciphertext> error The value is not a token from crypto.encrypt (for example the whole { encrypted, algorithm } object was passed instead of encrypted).
Decryption failed: wrong key or tampered value error The key differs from the one used to encrypt, or the token was altered or truncated.
A key is required: pass { credential: "<alias>" } (recommended) or { key } error Neither connection_id nor the literal key field is set. Select a credential in connection_id.
credential binding 'connection' has no key usable for symmetric error The credential resolved, but its secret is empty or is an object without a usable field. Store the key as a string, or as an object with the field this operation reads (see connection_id).
Failed to resolve connection <connection_id>: <detail> error The credential id does not exist or is not available to this workflow. Check the id and the credential type.

Input contract

connection_id string Optional
key string Optional
encrypted string Required

Output contract

data any Optional

Decrypted value

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "crypto.decrypt",
  "name": "Decrypt Data",
  "category": "identity",
  "version": "2.0.0",
  "description": "Decrypts a value produced by crypto.encrypt or $encrypt. Fails if the key is wrong or the value was altered.",
  "capabilities": [
    "crypto",
    "decryption"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string",
        "title": "Encryption key credential",
        "description": "Sommatic AI credential resolved server-side (recommended). Accepts credentials of type `encryption-key`.",
        "ui_widget": "connection_picker",
        "ui_options": {
          "credential_types": [
            "encryption-key"
          ]
        }
      },
      "key": {
        "type": "string",
        "ui_widget": "password",
        "x-literal-secret": true,
        "description": "Encryption key as a literal. Allowed, but it is stored in the flow, its version history and Git: prefer connection_id."
      },
      "encrypted": {
        "type": "string",
        "description": "v1.<iv>.<tag>.<ciphertext>"
      }
    },
    "required": [
      "encrypted"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string"
      },
      "key": {
        "type": "string"
      },
      "encrypted": {
        "type": "string"
      }
    },
    "required": [
      "encrypted"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "data": {
        "description": "Decrypted value"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Decrypted",
      "description": "Decrypted string",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Decryption failed",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "sync",
  "required_resources": [],
  "compatible_worker_pools": [
    "standard"
  ],
  "tags": [
    "crypto",
    "security"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_veripass",
    "profile": {
      "name": "Veripass",
      "verified": true,
      "url": "https://me.veripass.com/veripass",
      "logo_url": null
    }
  }
}

Execution

Execution
sync
Stateful
No
Capabilities
cryptodecryption
Tags
cryptosecurity

Notes and limits

  • The value comes back under data.data: read it downstream as {{ $json.data.amount }}.
  • The decrypted value is plain data in the run from this point on: avoid sending it to logs or external systems you do not need.
  • Leaving through error does not fail the run: the engine follows the edges wired to error, and if there are none the branch simply ends.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs