# Check Consent

> Checks if User has consented to activity.

Source: https://docs.sommatic.ai/en/nodes/consent.check/

- Slug: `consent.check`
- Family: Identity
- Version: 1.0.0
- Status: Experimental. Mock: always leaves through `yes`; `purpose` and the subject are not checked against any consent record.
- Execution: async

Checks if User has consented to activity.

## Configuration

- `user_id` (string, required)
- `purpose` (string, required)

## Output ports

- `yes` (default): User agreed
- `no`: User did not agree
- `error`: Check failed

## Input contract

- `user_id` (string, required)
- `purpose` (string, required)

## Output contract

- `consented` (boolean, optional)
- `timestamp` (string, optional)

## In expressions

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

- `$("Check Consent").item.json.consented` (boolean) = `true`
- `$("Check Consent").item.json.timestamp` (string) = `"2026-11-26T15:04:05.000Z"`


## How it works

Placeholder consent check: it validates that `user_id` is set and always answers `yes` with `consented: true`. No consent platform is queried and `purpose` is not evaluated.

1. Resolves the config: expressions in `user_id` and `purpose` are evaluated against the run.
2. Leaves through `error` with `user_id is required` when `user_id` is empty.
3. Does not look up any consent record: the decision is hard-coded to consented.
4. Returns `{ consented: true, timestamp }` on `yes`, where `timestamp` is the evaluation time in ISO 8601.

## In a workflow

### Node

```json
{
  "node_id": "node-check-consent",
  "label": "Check marketing consent",
  "operator_slug": "consent.check",
  "operator_version": "1.0.0",
  "config": {
    "user_id": "{{ $json.customer_id }}",
    "purpose": "marketing_email"
  }
}
```

### Envelope

```json
{
  "ok": true,
  "port": "yes",
  "data": {
    "consented": true,
    "timestamp": "2026-11-26T15:04:05.000Z"
  }
}
```

## Output ports (behaviour in the code)

### `yes`

Always, once `user_id` is set.

```json
{
  "consented": true,
  "timestamp": "2026-11-26T15:04:05.000Z"
}
```

### `no`

Never emitted: the worker has no path that denies consent.

### `error`

`user_id` is empty.

```json
{
  "error": "user_id is required"
}
```

## Behaviour in the code

- `purpose`: Required by the schema but ignored at runtime: the answer is the same for every purpose.

## Errors

| Message | Port | Cause and fix |
| --- | --- | --- |
| `user_id is required` | `error` | `user_id` is empty or its expression resolved to an empty value. Check the expression against the input item. |

## Notes and limits

- Do not rely on this node to enforce consent: it never routes to `no`. Until a real consent source is connected, check consent with an explicit call (for example `io.http`) and a `flow.if`.
- 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.


## Contracts (JSON Schema)

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

```json
{
  "slug": "consent.check",
  "name": "Check Consent",
  "category": "identity",
  "version": "1.0.0",
  "description": "Checks if User has consented to activity.",
  "capabilities": [
    "privacy",
    "consent"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "user_id": {
        "type": "string"
      },
      "purpose": {
        "type": "string"
      }
    },
    "required": [
      "user_id",
      "purpose"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "user_id": {
        "type": "string"
      },
      "purpose": {
        "type": "string"
      }
    },
    "required": [
      "user_id",
      "purpose"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "consented": {
        "type": "boolean"
      },
      "timestamp": {
        "type": "string"
      }
    }
  },
  "ports": [
    {
      "port_id": "yes",
      "label": "Consented",
      "description": "User agreed",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "no",
      "label": "Not Consented",
      "description": "User did not agree",
      "is_default": false,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Check failed",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "identity-worker"
  ],
  "tags": [
    "privacy",
    "gdpr"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_veripass",
    "profile": {
      "name": "Veripass",
      "verified": true,
      "url": "https://me.veripass.com/veripass",
      "logo_url": null
    }
  }
}
```

### config_schema

```json
{
  "type": "object",
  "properties": {
    "user_id": {
      "type": "string"
    },
    "purpose": {
      "type": "string"
    }
  },
  "required": [
    "user_id",
    "purpose"
  ]
}
```

### input_contract_schema

```json
{
  "type": "object",
  "properties": {
    "user_id": {
      "type": "string"
    },
    "purpose": {
      "type": "string"
    }
  },
  "required": [
    "user_id",
    "purpose"
  ]
}
```

### output_contract_schema

```json
{
  "type": "object",
  "properties": {
    "consented": {
      "type": "boolean"
    },
    "timestamp": {
      "type": "string"
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "yes",
    "label": "Consented",
    "description": "User agreed",
    "is_default": true,
    "supports_condition": true
  },
  {
    "port_id": "no",
    "label": "Not Consented",
    "description": "User did not agree",
    "is_default": false,
    "supports_condition": true
  },
  {
    "port_id": "error",
    "label": "Error",
    "description": "Check failed",
    "is_default": false,
    "supports_condition": false
  }
]
```
