Strategies
A strategy is a decision iamigrate makes for each user (or record, role, organization) that you can hand to a handler declared in hooks.yaml (see Hooks). Strategies are configured in mapping.yaml, and each keeps today’s behavior unless configured.
Most go under strategies, by name:
strategies: export.user: {handler: audit} import.payload: {handler: audit, on_failure: fail} verify.lookup: {strategy: target_id} # a built-in alternativeid.target goes under ids, and custom transforms (map.field, map.target_field) under transforms. See mapping.yaml.
Every strategy is batched: one request carries up to the handler’s batch_size items, {"items": {"<key>": <item>}}, and the answer holds one result per key, {"results": {"<key>": <result>}}. The key is the user’s source_id unless said otherwise. A strategy’s on_failure defaults to fail; with ignore, a failed call leaves the users of that batch to the built-in behavior.
What a handler sees of a user
Section titled “What a handler sees of a user”A handler deciding about a user gets who they are, never their credentials: only hash.translate and mfa.translate, whose job they are, see passwords and MFA factors; and hash.detect, which sees the password value of a record whose hash it is asked to identify.
{ "source_id": "u1", "username": "ada", "blocked": false, "emails": [{"value": "ada@example.com", "verified": true, "primary": true}], "phones": [], "profile": {"given_name": "Ada", "family_name": "Lovelace"}, "app_metadata": {"plan": "pro"}, "user_metadata": {"theme": "dark"}, "roles": [], "global_roles": [], "memberships": [], "provenance": {"source_connector": "flatfile", "exported_at": "2026-10-17T09:12:03Z"}, "target_ids": {"auth0": "legacy-1"}}target_ids is only there once assigned. Below, this is called the user.
Export
Section titled “Export”export.record
Section titled “export.record”Each raw record a flat file holds, as read and before the mapping’s fields apply. Configured in the flat-file source’s mapping (export --mapping, job create --source-mapping). Other sources don’t have it.
- Key:
record <n>, the record’s position from 1, as it has no source ID yet. - Item:
{"record": {"<column>": "<value>", ...}}. - Result:
{"action": "keep"}(or{}),{"action": "drop", "reason": "..."}, or{"action": "replace", "record": {...}}. A dropped record is listed under the manifest’sskipped_records, asrecord <n>.
id.source
Section titled “id.source”The source_id of each raw record a flat file holds, for an ID that is a combination of columns or otherwise can’t be read from one. Asked after export.record and before the mapping’s fields, so what it answers is the source_id column the fields then see. Configured in the flat-file source’s mapping, like export.record. Without it, a fields entry mapping a column (or several, as fallbacks) to source_id does the same for most files.
- Key:
record <n>, the record’s position in the file from 1, as forexport.record(a record it dropped keeps its number). - Item:
{"record": {"<column>": "<value>", ...}}. - Result:
{"source_id": "..."}.{}or an emptysource_idkeeps the record’s own, if it has one.
An ID must give the same answer for the same record on every run, as imports, reports and verify refer to users by it.
hash.detect
Section titled “hash.detect”The password of each record whose hash iamigrate can’t read from its columns: a raw digest (md5, sha1, sha256, sha512) without a password_algorithm, an unreadable password_encoding or password_salt, and so on. Records the columns settle (a self-describing hash, or raw digests with their algorithm) aren’t sent. Asked after the mapping’s fields, so the columns are the ones the convention names. Configured in the flat-file source’s mapping.
- Key: the record’s
source_id. Records without one are skipped before this, and two sent records can’t share one. - Item:
{"source_id": "u1", "password": "5f4dcc3b...", "columns": {"password_salt": "pepper", "password_salt_encoding": "utf8"}, "reason": "..."}: the rawpasswordvalue, the other password columns the record has, and why iamigrate couldn’t read them. - Result: a CMF password, e.g.
{"algorithm": "md5", "hash": {"value": "5f4dcc3b...", "encoding": "hex"}, "salt": {"value": "pepper", "encoding": "utf8", "position": "prefix"}}(portableis true unless set);{"skip": "reason"}to leave the record out, listed with that reason under the manifest’sskipped_records; or{}to leave it to the built-in handling, which skips it with its own reason.
The password is checked before it is written: a known algorithm, a hash, salt and key that decode as their encoding, a digest of the algorithm’s size, an hmac with its key and digest. One that fails the check skips the record, with the reason, rather than writing a hash no target can use.
map.field
Section titled “map.field”A custom transform on the export side, named in a field’s transform pipeline, e.g. transform: "trim|normalize_phone|lowercase", and declared under transforms. A pipeline runs over a whole column at a time, so it’s one request per batch of values, not one per value. Empty values aren’t sent.
- Key: the record’s position.
- Item:
{"transform": "normalize_phone", "field": "phone", "value": "+1 (415) 555-0100"}. - Result:
{"value": "+14155550100"}.
export.user
Section titled “export.user”Each CMF user the export produced, whatever the source, before it is written to the users file. In a job, any source; standalone, with a flat-file export --mapping.
- Item: the user.
- Result:
{}to keep it,{"action": "drop", "reason": "..."}, or{"action": "replace", "user": {...}}. A replacement keeps the user’ssource_idand its credentials, whichexport.usernever sees. Dropped users are listed under the manifest’sskipped_records, and the manifest’s counts are those of the users written.
id.target
Section titled “id.target”The user ID each user gets in the target, assigned once into the users file’s target_ids so that every import of it, a resumed one included, sends the same. Configured under ids.target, with a built-in or a handler; a job’s export applies it, and ids assign does for a users file that didn’t come from one.
ids.target | ID |
|---|---|
{strategy: preserve} (the default) | The source ID |
{strategy: prefix, prefix: "legacy-"} | legacy- + the source ID |
{strategy: template, template: "{{.SourceID}}@acme"} | A Go template over SourceID, Email, Username and Phone |
{strategy: uuidv5, namespace: <uuid>} | The version 5 UUID of the source ID in that namespace: the same user always gets the same UUID |
{handler: <name>} | The handler’s answer |
- Item: the user, plus
"target": "<connector>". - Result:
{"id": "..."}.
Only Auth0 and Firebase accept a chosen user ID. Ory Kratos, Keycloak and Cognito generate their own, so validate rejects an ids.target for them; their import records the generated IDs instead (target_ids in the import report). An ID already assigned is kept. on_failure: ignore isn’t accepted: some users would get the handler’s ID and others their source ID, with no way to tell which.
Validate
Section titled “Validate”validate.user
Section titled “validate.user”More problems per user, on top of validate’s own.
- Item: the user.
- Result:
{"problems": [{"field": "emails", "rule": "domain is blocked", "value": "x@example.org"}]}, or{}for none.
validate.dedup_key
Section titled “validate.dedup_key”More keys two users can’t share, on top of the emails, usernames and phones validate already compares: a normalized email, say.
- Item: the user.
- Result:
{"keys": ["ada.lovelace@example.com"]}. A user with a key an earlier one had gets adedup_keyproblem.
Import
Section titled “Import”The import-side strategies run on a batch of users before the target connector builds its payloads, in this order: import.user, identity.primary, hash.translate, mfa.translate, metadata.place, then the mapping’s metadata routes and target_fields. import.payload runs last, on the payloads. They are asked again whenever the import runs again, so they must give the same answer every time (see Hooks).
import.user
Section titled “import.user”- Item: the user.
- Result:
{}to import it,{"action": "drop", "reason": "..."}to skip it, or{"action": "replace", "user": {...}}as forexport.user. Skipped users are listed under the report’sskippedwith codeSKIPPED, and verify doesn’t look for them.
identity.primary
Section titled “identity.primary”Which of a user’s identifiers is their primary one: the kind (email, username or phone), and which contact when they have several emails or phones. Every connector reads the decision the same way, but what it changes depends on the target:
| Target | What identity.primary changes | Kinds it accepts |
|---|---|---|
| Keycloak | Which value becomes the Keycloak username: the username, the email or the phone | email, username, phone |
| Kratos | Nothing about the kind: the email, username and phone traits are always all set, and the identity schema decides which one logs in. Only the contact choice below applies | email, username, phone |
| Cognito | Which identifier the user is created under (its username in the pool): email, username or phone number. The others become attributes | email, username, phone |
| Firebase | Nothing about the kind: the account takes an email and a phone number, and has no username. Only the contact choice below applies | email, phone |
| Auth0 | Nothing about the kind: the bulk import requires an email. Only the contact choice below applies | email |
The contact choice applies to every target: the contact the strategy picks (or, failing that, the one flagged primary) is the one the target takes as the user’s email or phone, instead of the first in the list.
identity.primary | Prefers, in this order |
|---|---|
| (not set) | Each connector’s own order, the first contact of each list |
{strategy: email_first} | email, username, phone |
{strategy: username_first} | username, email, phone |
{strategy: phone_first} | phone, email, username |
{handler: <name>} | As the handler answers |
A built-in falls back along its order for a user without the kind it prefers, and skips the kinds the target doesn’t accept. validate --mapping rejects a built-in that prefers a kind the target doesn’t accept (username_first for Auth0 or Firebase, phone_first for Auth0).
With identity.primary set, Keycloak takes the chosen identifier as its username, so email_first makes the email the username for a user who also has a username, where Keycloak otherwise prefers the username.
Verify looks users up as the import saw them, replaying a built-in’s choice and the contacts flagged primary. It can’t replay a handler’s own answer: if a handler picks a contact that isn’t flagged primary, set verify.lookup to look that user up by the identifier you want.
- Item: the user.
- Result:
{"identifier": "email"}(or"username","phone") to make that kind primary,{"value": "ada@example.com"}to name the identifier itself (which also picks the contact among several), or{}for no opinion: the connector picks the kind, with the contacts flaggedprimaryfirst. Naming a kind the user lacks, a value that is none of their identifiers, or a kind the target doesn’t accept fails the import, as does answering bothidentifierandvalue.
metadata.place
Section titled “metadata.place”Where each user’s metadata keys go on the target, when it isn’t the same for every user. The mapping’s metadata routes are static; this asks a handler, user by user, and the routes then apply to the keys it didn’t place. Only users with app_metadata or user_metadata are sent.
- Item: the user (their
app_metadataanduser_metadataamong the rest, never their credentials). - Result: a list of placements,
[{"key": "plan", "from": "app_metadata", "destination": "metadata_admin.plan"}].fromisapp_metadataoruser_metadata, anddestinationa target field path, ordropto leave the key out.[]places nothing.
A placed key is taken out of the user’s metadata, so the connector doesn’t also put it where it does by default. When a placed key and a route (or a target_fields entry) set the same destination, the later one wins: placements, then routes, then target_fields.
Every destination is checked as a route’s is, by the target connector (for Kratos, traits.email, traits.username and traits.phone are refused). validate can’t check a handler’s answers, which depend on the user, so a destination the target can’t set, a key the user doesn’t have, or a key placed twice fails the import step. Unlike the static routes, a bad answer is found when the user is reached, not before the import starts.
hash.translate
Section titled “hash.translate”Each user’s password, for a hash the target can’t take as it is, or to make users reset theirs.
- Item:
{"source_id": "u1", "password": {"algorithm": "md5", "hash": {"value": "...", "encoding": "hex"}, ...}}. - Result:
{"password": {...}}, a CMF password to import instead;{"reset": true}to import none and have the user reset it (reported underrequires_password_reset); or{}to keep it.
mfa.translate
Section titled “mfa.translate”Each user’s MFA factors.
- Item:
{"source_id": "u1", "mfa_factors": [{"type": "totp", "value": "...", "portable": true}]}. - Result:
{"mfa_factors": [...]}to import instead ([]for none), or{}to keep them.
map.target_field
Section titled “map.target_field”A custom transform on the import side, in a target_fields entry’s transform. As map.field, keyed by source_id, with field the target path.
import.payload
Section titled “import.payload”The payloads the target connector built for a batch of users, as they would be sent, for the final say.
- Item:
{"source_id": "u1", "payload": {...}}: an Auth0 bulk import record, a Kratos identity, a Keycloak user representation, or a Firebase account. - Result:
{"payload": {...}}to send instead, or{}to send it as is.
A replacement must keep the user’s ID. For Auth0, a chunk is re-checked against the 500 KB job limit once its records are replaced.
org.resolve, role.resolve
Section titled “org.resolve, role.resolve”Auth0 only, the one target with organizations and roles: each organization of organizations.cmf.jsonl and role of roles.cmf.jsonl, before they are matched by name or created.
- Key: the organization’s or role’s
source_id. - Item: the CMF organization (
source_id,name,display_name,metadata) or role (source_id,name,description). - Result:
{"id": "rol_..."}to use that existing Auth0 role or organization,{"name": "..."}to match or create it by that name, or{}.
Verify
Section titled “Verify”Verify is a job’s verifying step, or diff with --mapping (and --report for the import’s target IDs).
verify.lookup
Section titled “verify.lookup”How to find each user in the target.
verify.lookup | Looks a user up |
|---|---|
| (not set) | By identifier, as each connector does: email, else username or phone |
{strategy: target_id} | By the ID the import gave it, from the import report (--report for diff); by identifier when there’s none |
{handler: <name>} | As the handler answers |
- Item: the user, plus
"target_id"when the import recorded one. - Result:
{"target_id": "..."}, or{"identifier": "..."}(an email when it has an@; for Firebase, a phone number when it starts with+; else a username).
verify.compare
Section titled “verify.compare”For each user found, whether it differs from the CMF user.
- Item:
{"user": <the user>, "target": <the target's record of it>, "drift": ["blocked"]},driftbeing what iamigrate itself found. - Result:
{"drift": [...]}, the fields that differ ([]for none).