mapping.yaml
mapping.yaml describes how fields move between a source, CMF and a target, and which strategies apply. export scaffolds one and map sets its target; the other commands read it with --mapping. Every section is optional except target where noted.
target: auth0connection_id: con_1a2b3c
# Source side: flat-file columns -> CMF (export --source flatfile)records_path: data.usersfields: - {source: id, cmf: source_id} - {source: mail, cmf: email, transform: "trim|lowercase"} - {source: active, cmf: blocked, transform: not}
# Custom transforms, usable in any transform pipelinetransforms: normalize_phone: {handler: audit}
# IDs the target is to give the usersids: target: {strategy: uuidv5, namespace: 6ba7b811-9dad-11d1-80b4-00c04fd430c8}
# Target side: CMF -> target fields, on importtarget_fields: - {cmf: profile.locale, target: user_metadata.locale, transform: lowercase}metadata: - {key: internal_notes, from: user_metadata, destination: app_metadata.notes}conflict: {on_duplicate: skip}
# Decisions handed to handlersstrategies: import.payload: {handler: audit} verify.lookup: {strategy: target_id}Handlers are declared in hooks.yaml and selected here by name; a mapping can’t hold a URL or a secret. See Hooks.
target, connection_id
Section titled “target, connection_id”The target connector the mapping is for (auth0, kratos, keycloak, firebase, cognito), required by validate --mapping and by ids.target, and the Auth0 database connection to import into (--connection-id wins over it).
fields, records_path
Section titled “fields, records_path”How a flat file’s own columns become CMF fields, on export --source flatfile (and prepare). See export for the column convention and prepare for the full options of a field: source, cmf, pattern, values, transform and default. records_path is the dotted path to the array of users in a JSON file whose root is an object.
A transform is a pipeline of transforms joined with |, run left to right: the built-ins trim, lowercase, uppercase, bool (true/false, yes/no, 1/0, on/off… into true or false) and not (bool, inverted), and the custom ones under transforms. An empty value stays empty.
transforms
Section titled “transforms”Custom transforms, each handed to a handler: on export as the map.field strategy, on import as map.target_field. A name can’t be a built-in’s.
transforms: normalize_phone: {handler: audit, on_failure: fail}ids.target decides the user ID each user gets in the target: preserve (the source ID, the default), prefix, template, uuidv5, or a handler. It is assigned once into the users file’s target_ids, by a job’s export or ids assign, and only Auth0 and Firebase accept it. See id.target.
target_fields
Section titled “target_fields”Fields of the target’s user set from CMF fields, on import, after the connector’s own mapping (so they win over it).
target_fields: - {cmf: profile.locale, target: traits.locale, transform: lowercase} - {cmf: emails.0.value, target: metadata_admin.contact} - {cmf: app_metadata.tier, target: metadata_public.tier, default: free}cmf is a dotted path into the CMF user, array indexes included. An empty result leaves the target field unset. Without a transform the value keeps its type (a number, a boolean, an object); a transform needs a string, number or boolean.
target is a path the target accepts:
| Target | Paths |
|---|---|
auth0 | given_name, family_name, name, nickname, picture, user_metadata.<key>, app_metadata.<key> |
kratos | traits.<key> (not email, username or phone, which iamigrate sets from the user’s identifiers), metadata_public.<key>, metadata_admin.<key> |
keycloak | firstName, lastName, attributes.<key> (a one-element list; a non-string value in JSON) |
cognito | Standard attributes (name, given_name, family_name, birthdate, locale, …) by name, and custom:<name> (the attribute has to be in the pool’s schema) |
firebase | displayName, photoUrl, custom_claims.<key> (not a reserved claim name; merged with the claims from app_metadata, within Firebase’s 1000 bytes) |
validate --mapping rejects a path the target doesn’t accept.
metadata
Section titled “metadata”Moves a metadata key away from where the target connector puts it by default, to a target field path (as above), or drop to leave it out:
metadata: - {key: email, from: user_metadata, destination: metadata_admin.legacy_email} - {key: internal_notes, from: app_metadata, destination: drop}Use it for a key that would collide with something the connector sets: the Kratos connector copies user_metadata into the identity’s traits, so a user_metadata.email collides with the user’s email trait. The user’s own identifier wins and the key stays in metadata_public only, and validate reports the collision.
The routes are the same for every user. To place keys differently per user, delegate to a handler with metadata.place: the keys it places are taken before the routes, which then apply to the rest.
conflict
Section titled “conflict”What an import does with a user the target already has:
on_duplicate | Effect |
|---|---|
fail (the default) | The user is reported as failed, as without the section |
skip | The user is reported under the report’s skipped instead of failed, and still verified |
upsert | The user is updated, as with --upsert. Only Auth0, Firebase and Cognito can; validate rejects it for Kratos and Keycloak |
strategies
Section titled “strategies”The strategies handed to handlers, by name, and the built-in alternatives of verify.lookup and identity.primary (email_first, username_first, phone_first). See Strategies for each: export.record, id.source, hash.detect, export.user, validate.user, validate.dedup_key, import.user, identity.primary, hash.translate, mfa.translate, metadata.place, import.payload, org.resolve, role.resolve, verify.lookup, verify.compare.
strategies: export.user: {handler: audit} verify.lookup: {strategy: target_id}A step only needs the handlers of the strategies it runs: validate doesn’t need --hooks for a mapping whose only handler is an import.payload’s.
app_metadata, user_metadata, manual_steps
Section titled “app_metadata, user_metadata, manual_steps”Written by export and map for review: the metadata keys found in the export, and the decisions left to a human. They don’t change what is imported; use metadata and target_fields for that.