Prerequisites
Before working with Narrative IDs, ensure you have:- Access to the Narrative platform with appropriate permissions
- An encoding key ID for your organization’s encoding space
- Partner encoding key IDs if you need to translate for collaboration
Encoding identifiers
Encoding converts a clear text identifier (such as an email or hashed email) into a Narrative ID within your organization’s encoding space.When to encode
Encode identifiers when you want to:- Share data with partners without exposing raw identifiers
- Create privacy-safe join keys for cross-organization matching
- Prepare data for collaboration workflows
Using NARRATIVE_ID_ENCODE
TheNARRATIVE_ID_ENCODE function creates a Narrative ID from a clear text identifier.
Syntax:
| Parameter | Type | Description |
|---|---|---|
raw_identifier | string | The clear text identifier to encode (email, hashed email, phone, etc.) |
key_id | string | Your organization’s encoding key ID |
Creating a dataset with Narrative IDs
To prepare a dataset for sharing, encode the identifiers during a materialized view creation:Translating between partners
Translation converts a Narrative ID from one partner’s encoding space to another, enabling cross-organization matching without exposing the underlying identifiers.When to translate
Translate Narrative IDs when you need to:- Share data with a specific partner for matching
- Query across datasets from different partners
- Enable a partner to join your data with their own
Using NARRATIVE_ID_TRANSLATE
TheNARRATIVE_ID_TRANSLATE function converts a Narrative ID from its current encoding space to a target partner’s encoding space.
Syntax:
| Parameter | Type | Description |
|---|---|---|
narrative_id | string | An existing Narrative ID to translate |
target_key_id | string | The encoding key ID for the target partner’s encoding space |
Partner collaboration workflow
Here’s a typical workflow for sharing data with a partner:1
Encode your identifiers
Create Narrative IDs in your encoding space:
2
Translate for your partner
Convert your Narrative IDs to the partner’s encoding space:
3
Share the translated data
The partner receives data with Narrative IDs in their encoding space. They can now join against their own data using their Narrative IDs.
Joining across partner datasets
When querying data that spans multiple partners, use translation in the join condition:Working with match tables
Match tables are pre-generated lookup tables that pair Narrative IDs with clear text identifiers, enabling offline workflows.What match tables provide
- A static mapping between your clear text identifiers and their Narrative IDs
- The ability to work with Narrative IDs outside the Narrative platform
- Faster lookups for high-volume processing
Generating a match table
Create a match table by selecting both the raw identifier and its encoded Narrative ID:Using match tables
Once generated, you can export the match table for use in external systems:Best practices
Normalization before encoding
Always normalize identifiers before encoding to ensure consistent matching:| Identifier Type | Normalization |
|---|---|
LOWER(TRIM(email)) | |
| Phone | E.164 format or NORMALIZE_PHONE() |
| Hashed email | Already normalized (ensure consistent hashing upstream) |
Performance considerations
- Encode once, translate as needed: Encode your raw identifiers once and store the Narrative IDs. Translate only when preparing data for a specific partner
- Use materialized views: For frequently accessed data, encode identifiers in a materialized view rather than at query time
- Batch translations: When sharing with multiple partners, consider creating partner-specific views
Encoding vs. hashing
| Use Case | Approach |
|---|---|
| General pseudonymization | Use standard hashing (SHA-256) |
| Cross-partner collaboration | Use Narrative ID encoding |
| Internal data processing | Either, depending on downstream use |
| Regulatory compliance | Narrative ID provides additional isolation |
Troubleshooting
| Issue | Possible Cause | Solution |
|---|---|---|
| No matches after translation | Identifiers not normalized consistently | Ensure both partners normalize the same way before encoding |
| Invalid key_id error | Incorrect encoding key ID | Verify the key ID with your Narrative administrator |
| Translation returns NULL | Source Narrative ID is invalid | Check that the source was properly encoded |

