# compute_hash

> Source: https://docs.clonepartner.com/reference/steps/compute-hash/

<!-- sources: src/steps/compute-hash-step.ts, src/steps/types.ts, references/envoy/step-types.md -->

# compute_hash

Computes a hash of the input record and adds it as a field, for change detection between runs.

## When to use it

Use `compute_hash` with [get_destination_id](/reference/steps/get-destination-id/) and a `skip_if` comparison to update only records whose content changed. For new tasks, prefer [sync_record](/reference/steps/sync-record/), which computes and compares the hash internally as part of one composite step.

## Configuration

| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| `fields` | string[] | No | all fields not prefixed with `_` | Field names to include in the hash. |
| `algorithm` | string | No | `sha256` | Hash algorithm: `sha256` or `md5`. |
| `field_name` | string | No | `_hash` | Name of the output field the hash is written to. |

An invalid algorithm fails validation with `Invalid hash algorithm: '<value>' (must be sha256, md5)`; a non-string-array `fields` fails with `compute_hash fields must be an array of strings`.

## Example

```yaml
name: hash-contacts
connectors:
  source:
    type: csv
steps:
  - name: read_contacts
    type: call_method
    config:
      connector: source
      method: read
      args:
        resource: contacts

  - name: hash
    type: compute_hash
    config:
      fields: ["name", "email", "updated_at"]
```

## Behavior notes

- **The output is the input record plus the hash field** — by default `_hash`, or the name set in `field_name`. No other fields change.
- **Requires an object input.** A non-object item fails the step with `Compute hash requires an object input`.
- When `fields` is omitted, every field whose name does not start with `_` participates in the hash, so previously added bookkeeping fields (like `_hash` itself) are excluded.
- Downstream steps that compare hashes must use the same `fields` list and `algorithm`, or every record looks changed.

## Related

- [sync_record](/reference/steps/sync-record/) — computes, compares, and stores the hash in one step
- [get_destination_id](/reference/steps/get-destination-id/) — returns the previously stored hash to compare against
- [Idempotent sync and the mapping DB](/building/idempotent-sync/) — the change-detection pattern end to end
