---
title: Link identities with sameAs
description: Review the evidence for two distinct recording atoms and prepare a sameAs claim while preserving both original payloads and IDs.
url: https://docs.intuition.systems/docs/build/link-identities
markdown_url: https://docs.intuition.systems/docs/build/link-identities.md
version: V2
llms_index: https://docs.intuition.systems/llms.txt
kind: how-to
reader:
  - app
packages:
  - '@0xintuition/primitives@0.1.1'
  - '@0xintuition/predicates@0.1.1'
  - '@0xintuition/iid@0.1.1'
---

Prepare a `sameAs` triple when two existing atoms refer to the same recording and a reviewer has checked the evidence.

**Prompt for your agent:** Review the evidence and plan a sameAs claim

```text
Goal: decide whether two atoms describe the same recording and, if they do, plan a sameAs claim.
Read https://docs.intuition.systems/docs/build/link-identities.md, https://docs.intuition.systems/docs/concepts/same-as.md and https://docs.intuition.systems/docs/identifier/entity-types.md.
Use exact package versions from https://docs.intuition.systems/intuition-release.json and public entry points only.
Input: the exact original bytes of both atoms and the source records behind them.
Compare entity level and identifiers, not titles alone. Record each piece of evidence and the decision.
If the evidence supports a link, output the planned sameAs triple with its IDs. Otherwise output the reason for not linking.
Preserve both original payloads and IDs. Never rebuild either atom under a new profile.
Do not create the triple or send transactions.
Report the checks you actually ran and anything you could not verify.
```

## Before you start

Retain the exact original bytes for both atoms, their entity levels, and the source records used to identify them. Read [sameAs](https://docs.intuition.systems/docs/concepts/same-as) and [triples](https://docs.intuition.systems/docs/concepts/triples).

For your own project, follow [Install the packages](https://docs.intuition.systems/docs/build/install). To run the [offline example](https://github.com/0xIntuition/intuition-docs/blob/84242e8f4399ac758c942e85b343e0512245a6cf/examples/v2/identity-linking/src/link-identities.ts), install its locked dependencies from the documentation repository root with Node.js 22.21.0.

```sh
npm ci --prefix examples/v2 --ignore-scripts
```

## Steps

### 1. Compare the two source records

In the synthetic catalog, the older atom stores a JSON payload with a title and a catalog URL in its `sameAs` field. The newer atom stores the bare IID `int:isrc:USRC17607839`. The catalog editor has verified that both source entries describe the recording with that ISRC. The URL in the older payload is a reference the editor can inspect. Adding another URL would change those serialized bytes and produce a different atom ID.

### 2. Screen the candidates and record the review

Check what each candidate identifies before comparing its identifiers. A review article can quote the exact ISRC while identifying a different entity. A second recording can share a title while carrying a different ISRC. Leave candidates with missing evidence for later review. This catalog requires a matching canonical ISRC and explicit approval for this particular workflow. Other domains need evidence appropriate to their entity level.

```ts
import type { Hex } from 'viem';
import { inspectIntuitionId } from '@0xintuition/iid';
import { calculateAtomId } from '@0xintuition/ids';
import { sameAsId } from '@0xintuition/predicates/sameAs';
import { buildTriple } from '@0xintuition/primitives/triple';

type CatalogRecord = {
  atomData: Hex;
  level: 'recording' | 'article';
  recordingIid?: string;
};

export function planLink(
  left: CatalogRecord,
  right: CatalogRecord,
  reviewerApproved: boolean,
) {
  if (left.level !== 'recording' || right.level !== 'recording')
    return { reason: 'Different entity level' };
  if (!left.recordingIid || !right.recordingIid)
    return { reason: 'Missing recording identifier' };
  const a = inspectIntuitionId(left.recordingIid);
  const b = inspectIntuitionId(right.recordingIid);
  if (
    !a.valid ||
    !b.valid ||
    a.scheme !== 'isrc' ||
    b.scheme !== 'isrc' ||
    a.iid !== b.iid
  ) {
    return { reason: 'Recording identifiers do not match' };
  }
  if (!reviewerApproved) return { reason: 'Awaiting review' };
  const subjectId = calculateAtomId(left.atomData);
  const objectId = calculateAtomId(right.atomData);
  if (subjectId === objectId) return { reason: 'Already the same atom' };
  const claim = buildTriple(subjectId, 'sameAs', objectId);
  if (!claim.success) throw new Error(claim.errors.join(', '));
  return { claim: claim.value };
}
```

### 3. Review the edge before creating it

Supply each original payload as hex-encoded bytes in `atomData`. For UTF-8 text, call `stringToHex` on the exact stored string, including any spaces. For example, the six literal characters `0x6162` encode as `0x307836313632`. If the archive already gives the two binary bytes as `0x6162`, pass that hex value directly. Compare the printed subject, predicate, and object IDs with the intended terms. The locally built triple is a proposal. To publish the reviewed edge, follow [Create triples](https://docs.intuition.systems/docs/build/create-triples). Both original atom IDs continue to identify their respective payloads.

## Check the result

```sh
node examples/v2/identity-linking/src/link-identities.ts
```

The accepted fixture prints two distinct atom IDs and the claim ID `0x84c9260e71757e9c7d5e33fa8bd370a7794160910b8e59ced21cb4e27911402f`. The article produces “Different entity level,” the title alone produces “Missing recording identifier,” and the second recording produces “Recording identifiers do not match.” A matching pair without approval remains “Awaiting review.”

## Related

[Identity ladders](https://docs.intuition.systems/docs/concepts/identity-ladder), [equivalence and candidate review](https://github.com/0xIntuition/intuition-identifier/blob/3e593247c0e7cb168b37368937167ed146d3868a/spec/08-equivalence.md), [IID inspection](https://github.com/0xIntuition/packages/blob/ccae0f0d0277cddd8490b72c49d3771866e7ffea/packages/iid/src/parse.ts), and [triple blueprints](https://github.com/0xIntuition/packages/blob/ccae0f0d0277cddd8490b72c49d3771866e7ffea/packages/primitives/src/triple.ts).

Applies to V2 · `@0xintuition/primitives` 0.1.1 · `@0xintuition/predicates` 0.1.1 · `@0xintuition/iid` 0.1.1
