# Migration

From [Descope Operations](https://learn.descope.io/c/operations): Move users in, go live, and find out what broke when something does.

Take this course interactively at https://learn.descope.io/c/operations/migration

---

![Migration Strategy.](video:migration-migration-strategy)

A migration to Descope is more than copying a user table. Before choosing a strategy, inventory every identity asset the customer depends on today, because each one has its own path across, and the strategy that suits the users may not suit the rest.

## What moves in a migration

- Users and login IDs: the identifier a user signs in with, usually an email, phone number or username. Every imported user needs one, unique within the project
- Credentials: password hashes, and sometimes TOTP seeds. Passkeys generally cannot be exported, so users re-enroll them afterwards
- Authorization data: roles and permissions, which map to Descope RBAC
- Organizations: customer accounts or workspaces in the legacy system, which become Descope tenants
- Custom profile data: metadata and profile fields, which become custom attributes, created in the Console before any import
- Enterprise SSO and SCIM connections that your customers' own IT teams configured
- Social logins, which keep working once login IDs are migrated, linking the next time the user signs in through that provider
- OAuth clients that call with a client ID and secret, recreated as Inbound Apps with their existing credentials

Descope also models multi-tenancy differently from many legacy providers. A user is global to the project and can belong to several tenants, with different roles in each. Where a customer has duplicate records for the same person across organizations, the migration is the moment to consolidate them into one Descope user with several tenant memberships.

## The strategies

- Full migration: export users and related data, import them with the Batch Create Users API, then switch traffic so Descope is the single source of truth. The most common path, and the only one that retires the old provider on a fixed date
- Just-in-time (JIT) migration: no bulk export. Each user is created in Descope at first sign-in, after a Flow verifies their credentials against the legacy provider. The go-to option when hashes cannot be exported
- Session migration: a valid session token from the legacy provider is exchanged for a Descope session, so active users are not signed out by the switch. In beta, it needs the user to exist in Descope already and works only with token-based sessions
- Hybrid migration: Descope is configured as an external identity provider inside the legacy system, which stays in the request path. A stepping stone, rarely the end state

Enterprise customers usually combine them. A common pattern is a full migration of existing users, session migration so active users keep their sessions, and a sync that catches anybody who signs up between the export and the cutover.

## What each provider will and will not hand you

- Auth0 exports password hashes, but only through a support ticket, and large tenants need a JSON export rather than paged API calls
- Okta CIS does not export password hashes through its Users API, which pushes most plans toward JIT, session migration, a reset or passwordless
- AWS Cognito does not export password hashes at all, so a full migration from it is always one without passwords
- A home-grown system owns its data, so the export is usually easy and the discovery is the hard part

> [!WARNING]
> Establish the password hashing situation first, whatever the provider. It is the single fact that decides whether passwords import directly or whether users need another route, and finding out late reshapes the whole plan.

## Key terms

- Full migration: exporting users and related data, importing them with Batch Create Users, then cutting over so Descope is the source of truth.
- JIT migration: provisioning each user at first sign-in, after verifying their credentials against the legacy provider.
- Session migration: exchanging a valid legacy session token for a Descope session; in beta, and only for users already in Descope.
- Hybrid migration: Descope as an external identity provider inside a legacy system that stays in place.

## Summary

- What has to be inventoried before a strategy can be chosen
- The four strategies, and why most migrations combine them
- Which providers export password hashes, and which do not
- Why the hashing question is the first one to answer

---

![Password Migration.](video:migration-password-migration)

Password handling is usually the deciding factor in a migration plan. If the customer can export password hashes in a supported format, Descope imports them, and users keep signing in with the password they already have without ever seeing a reset prompt. Users never notice the migration, which is the outcome worth working for.

## Hash formats Descope imports

- bcrypt
- Argon2
- Django
- Firebase
- PBKDF2
- PHPass
- MD5, unsalted only, for legacy compatibility
- The SHA family: SHA-1, SHA2-256, SHA2-512, SHA3-256 and SHA3-512
- Buddy-Auth, which is bcrypt combined with SHA-512

Each format has its own object inside a user's `hashedPassword` field, and the customer's algorithm has to be matched to it. Where the hashes cannot be exported, or use a scheme Descope does not support, there are three ways forward.

## When hashes cannot come across

- JIT with password verification: check the password against the legacy system at first sign-in, then store it in Descope
- A forced password reset: route migrated users through a reset path in a Flow on their first login
- Passwordless: if every user has a verified email address, skip passwords and move to magic links, OTP or passkeys

Two rules apply either way. Passwords captured during JIT must satisfy the project's password policy, so align the policies for the migration window or send failures to a reset. And a cleartext password on any user caps a Batch Create Users request at 100 users, while batches carrying only `hashedPassword` have no such cap.

## Where hash imports go wrong

- Argon2 variant: set the type to argon2i if the hashes are not Argon2id. Omit it and Descope verifies as Argon2id, and sign-ins fail with a generic E062903 that looks exactly like a wrong password
- PHC strings: an Argon2 hash stored as `$argon2i$v=19$m=...,t=...,p=...$salt$hash` has to be split into type, memory, iterations, threads, salt and hash, with salt and hash re-padded to standard base64
- SHA salt position: Descope assumes the salt is appended. Set saltPosition to prefix if the legacy system prepended it
- MD5: only unsalted MD5 is supported, so salted MD5 needs JIT or a reset
- Django: pass the whole stored hash string as it is, since Django embeds the algorithm, iterations and salt
- Mixed formats: group users by algorithm and import each group with its matching object

The pattern behind all of these is the same. A wrongly described hash does not fail at import. It imports cleanly and then fails at every sign-in, in the same way a mistyped password would, so the mistake surfaces as a support queue rather than an error. Older systems that changed algorithm over the years often hold several formats at once, which is why discovery asks about it before anything is imported.

## Key terms

- hashedPassword: the user field carrying an existing password hash, in an algorithm-specific object.
- PHC string: a self-describing hash format, common for Argon2, that has to be split into its parts before import.
- saltPosition: the SHA parameter saying whether the salt was prepended (prefix) or appended (suffix).
- E062903: the error an unverifiable imported hash produces, indistinguishable from a wrong password.

## Summary

- Which hash formats import directly, so users never reset
- The three routes when hashes cannot come across, and the two rules that apply to all of them
- The import mistakes that only show up as failed sign-ins
- Why a mix of hash formats has to be found before importing

---

![Migrating from Auth0 and Okta.](video:migration-migrating-from-auth0-and-okta)

Auth0 and Okta are the most common starting points for a Descope migration. Both products belong to Okta, but they expose identity data very differently, and that difference changes the plan. Descope also publishes Auth0 and Okta CIS migration skills in the descope/skills repository on GitHub, which walk a developer through the migration with an AI agent.

Every engagement starts by translating the customer's vocabulary into Descope's, because the same idea goes by different names on each side.

## How Auth0 and Okta map to Descope

- Auth0 Organizations become Descope tenants. In Okta, groups representing customer accounts usually become tenants, while groups representing access levels become roles
- Roles and permissions map directly to Descope roles and permissions
- Auth0 connections, whether database, social or enterprise, are recorded by the migration tool in a `connection` custom attribute on each user
- Okta profile fields: `profile.login` or `profile.email` become login IDs, `firstName` and `lastName` become given and family name, and custom fields become custom attributes
- Auth0 Actions and Okta hooks are rebuilt in Descope Flows, with conditions, connectors and scriptlets
- Enterprise connections become tenant SSO configurations, SAML or OIDC

Descope maintains an open-source migration tool that moves Auth0 users, roles, permissions and organizations across, and maps each user to their roles and tenants. Full migration with it is the most common Auth0 path.

## What the Auth0 migration needs first

- The Auth0 tenant ID, from the dashboard URL, such as `dev-xyz` in `manage.auth0.com/dashboard/us/dev-xyz/`
- An Auth0 Management API token from the API Explorer, valid for 24 hours
- The Descope Project ID and a Management Key
- Optionally, a password hash export, which Auth0 provides only through a support ticket, so raise it early
- Optionally, a JSON export of users from Auth0's User Import / Export extension, which customers with more than 1,000 users need because of API paging limits

With those in hand, clone the repository, install its requirements in a Python virtual environment, set `AUTH0_TOKEN`, `AUTH0_TENANT_ID`, `DESCOPE_PROJECT_ID` and `DESCOPE_MANAGEMENT_KEY` in its `.env`, and run a dry run before anything else. Compare the dry run's counts of users, roles, permissions and organizations with the Auth0 dashboard, then run it for real and read the log it writes.

```bash
# Dry run, API-based export
python3 src/main.py auth0 --dry-run

# Live run from a JSON export, including password hashes
python3 src/main.py auth0 --from-json ./users.json --with-passwords ./password_hashes.json
```

Three things in the output are worth knowing about. The tool creates the `connection` and `freshlyMigrated` custom attributes itself. It merges duplicate Auth0 identities belonging to one person, and if any of the merged accounts was disabled, the merged Descope user is disabled too. And users with neither an email nor a phone number, which some social identities lack, fail with E011002 and need handling by hand.

If the customer cannot remove Auth0 yet, the import can be followed by a hybrid setup, with Descope configured as an external identity provider in Auth0. Position it as a step on the way to a full migration rather than as where things end.

## Okta CIS: no hashes, so other routes

- Full migration through the Users API: create an API token, page through `GET /api/v1/users` with `limit=200` and the `after` cursor, back off when rate-limited, and import with Batch Create Users, without passwords
- A customer-owned data store: if Okta sits in front of the customer's own database, connect that store to Descope with a Generic HTTP Connector and take Okta out of the path, with no export at all
- JIT with password verification: the backend sends credentials to Okta's `/api/v1/authn`, and on success the user is created or linked in Descope with the same password
- Session migration: ship an app version that passes the existing Okta token to Descope through the SDK, so active users never re-enter anything
- Passkeys and TOTP seeds cannot be migrated from Okta CIS, so plan for re-enrollment in the first sign-in after migration

The Okta Users API does not export password hashes, which is the whole reason the list looks like this. For session migration, the SDK's `AuthProvider` takes the legacy token through `getExternalToken`:

```tsx
<AuthProvider
  projectId="<ProjectID>"
  getExternalToken={async () => getCurrentOktaAccessToken()}
>
  <App />
</AuthProvider>
```

## Key terms

- descope-migration: Descope's open-source tool that migrates Auth0 users, roles, permissions and organizations, with dry run and live modes.
- Password hash export: the file of Auth0 hashes Auth0 provides only through a support ticket, passed to the tool with `--with-passwords`.
- Okta CIS: Okta Customer Identity Solution, whose Users API does not export password hashes.
- getExternalToken: the `AuthProvider` prop that hands the SDK a legacy token for session migration.

## Summary

- How Auth0 and Okta concepts translate into tenants, roles, attributes and Flows
- What the Auth0 migration tool needs, and why the dry run always comes first
- What to expect in its output, including the users it cannot migrate
- Why Okta CIS plans lean on JIT, session migration, a reset or passwordless

---

![Migrating Enterprise SSO and SCIM.](video:migration-migrating-enterprise-sso-and-scim)

Auth0 and Okta customers that sell to enterprises usually have many tenant SSO connections, each one configured by their own customers' IT admins. Asking every one of those admins to reconfigure an identity provider is the largest source of friction in these migrations, and it is the step most likely to stall a cutover for months. Descope's seamless SSO and SCIM migration exists to remove it, and is available on the Growth and Enterprise plans.

## How a seamless SSO migration runs

- Implement SSO with Descope Flows or the SDK, gated so that only selected tenants use Descope. Rollback then becomes a configuration change
- Create a Descope tenant for each customer and copy the IdP settings exactly. For SAML, use the Management API to set `spACSUrl` and `spEntityId` to the values the customer's IdP already trusts
- Deploy Descope's Cloudflare Worker template, `cf-sso-redirect-worker`, on the legacy authentication hostname, so IdP responses still sent to the old ACS URL are forwarded to Descope. This needs a custom domain and a DNS provider
- Optionally proxy SCIM through the same worker, mapping each legacy connection ID in the SCIM path to a Descope tenant and SCIM token
- Test with internal tenants, then move customer tenants in waves

The pattern underneath is that nothing the customer's IdP knows has to change. The IdP keeps sending responses to the address it was given, and the worker and the overridden service provider values make that address land in Descope. That is what lets a migration move a tenant without a message to its IT team.

> [!NOTE]
> When proxying SCIM, set `logOnly` to true first. The worker then logs how it would have mapped each request without forwarding anything, which validates the mapping before real provisioning traffic depends on it.

OIDC connections are simpler, because there is no ACS URL to preserve. Reuse the existing client ID and secret where possible, and add Descope's redirect URI to the IdP's list of allowed callback URLs.

## Key terms

- spACSUrl and spEntityId: the tenant SAML settings overridden so Descope accepts IdP responses addressed to the legacy service provider.
- SSO redirect worker: the Cloudflare Worker that forwards IdP responses, and optionally SCIM traffic, from the legacy hostname to Descope.
- Seamless SSO migration: moving tenant SSO and SCIM connections without the customer's IT admins changing their IdP configuration.

## Summary

- Why reconfiguring every customer IdP is the friction to avoid
- The steps of a seamless SSO migration, and what each preserves
- How the redirect worker and the overridden SAML values keep the IdP unchanged
- Why OIDC connections need less, and how to validate a SCIM proxy before trusting it

---

![User Import and Batch Operations.](video:migration-user-import-and-batch-operations)

Customers replacing an in-house authentication system own their data, which usually makes the export easy and the discovery hard. Descope publishes a migration tool for custom data stores, which imports plain-text or hashed passwords, but no tool can know an in-house schema: the work is mapping it to the Descope user model and importing through the Management API, and the quality of the discovery decides the quality of the import.

## Discovery questions

- Where are users stored, in SQL, NoSQL or LDAP, and how many are there?
- What uniquely identifies a user: an email, a phone number, a username or an internal ID? Are there duplicate accounts for one person?
- Which hashing algorithm, salt handling and iteration count are used, and has the algorithm changed over time?
- Does the system model organizations or workspaces that should become tenants, and where do roles and permissions live?
- Which social or enterprise SSO connections exist, and who configured them?
- Are sessions signed JWTs or opaque server-side cookies? That decides whether session migration is possible
- Can sign-ups pause during the cutover, or must new accounts keep syncing until the switch?

Export users to JSON or CSV and transform each record into the Descope user format. A login ID is required; email, phone, names, tenants, roles and custom attributes are optional but worth carrying. Import with the Batch Create Users API, or Create User for small volumes; the Console's Import Users option accepts a JSON file for small one-off loads.

## Practices for every import

- Set `verifiedEmail` and `verifiedPhone` to true only where the legacy system actually verified them, since those flags decide whether the user can sign in through that channel
- Use `userTenants` to assign tenant membership and per-tenant roles in the same request
- Keep the legacy user ID in a custom attribute or in `externalIds`, for traceability and safe re-runs
- Set `createdTime`, in Unix seconds, to keep each user's original sign-up date; only Batch Create Users accepts it
- Create every custom attribute in the Console before importing
- Read `failedUsers` in every batch response, because a batch can partially succeed

A single record in the format the API expects looks like this:

```json
{
  "users": [{
    "loginId": "ada@acme.com",
    "email": "ada@acme.com",
    "verifiedEmail": true,
    "givenName": "Ada",
    "familyName": "Lovelace",
    "hashedPassword": { "bcrypt": { "hash": "$2a$10$..." } },
    "userTenants": [{ "tenantId": "acme-corp", "roleNames": ["admin"] }],
    "customAttributes": { "legacyUserId": "10482", "freshlyMigrated": true },
    "createdTime": 1609459200
  }]
}
```

> [!NOTE]
> Login IDs must be unique within the project. A duplicate, or a collision with somebody already in Descope, fails that row rather than the batch, and the response reports it in `failedUsers`.

Plan the rollback before the import, not after it. Keep the original export untouched, record which users each batch created, and decide upfront whether failures are fixed by deleting and re-running or by correcting individual records. Run a small batch end to end first, including the rollback, so the first time the plan is tested is not on the real user base.

## Key terms

- Batch Create Users: the Management API for bulk imports, which can partially succeed and reports failures in `failedUsers`.
- userTenants: the user field assigning tenant membership and per-tenant roles in the same request.
- createdTime: the Batch Create Users field preserving a user's original sign-up timestamp.
- Rollback planning: deciding before the import how a partial failure will be undone or corrected.

## Summary

- What discovery has to establish about a home-grown system before importing
- How a legacy record maps to the Descope user format
- The practices that make an import traceable and safe to re-run
- That a batch can partially succeed, and what a tested rollback looks like

---

![JIT Migration Against a Legacy Backend.](video:migration-jit-migration)

When a legacy system's hashes use a scheme Descope does not support, such as salted MD5 or a custom pepper, or cannot be exported at all, JIT migration lets the legacy system keep verifying passwords until each user has moved. Nobody is asked to reset anything, and nothing is imported in bulk: each user moves at the moment they next sign in.

## How a JIT sign-in moves a user

- The user enters their login ID and password in a Descope Flow, on the Login Password screen component, since they are typing a password they already have
- The Flow calls the legacy system's credential check through a Generic HTTP Connector
- On success, the Sign Up / Password action creates the user in Descope with that same password, and the Update User / Attributes action sets attributes such as `freshlyMigrated`
- Every later sign-in goes straight to Descope, and the connector is never invoked for that user again

Okta CIS works the same way against Okta itself. The backend sends the credentials to Okta's `/api/v1/authn`, and on success the user is created in Descope with Sign Up / Password, or, for a user who has already signed in some other way such as a magic link, has the password stored with Update Password.

## Rules for the migration window

- Passwords captured through Sign Up / Password or Update Password must satisfy the project's password policy, so align the policies or send failures to a reset
- Protect the legacy verification endpoint with authentication and rate limiting, since it now answers whether a password is right
- Remove the endpoint once the migration is complete, rather than leaving a password oracle running behind a system nobody uses

JIT has a cost worth naming: it never finishes on its own. Users who do not sign in during the migration window are never moved, so a JIT migration ends with a decision about the stragglers: a bulk import of the remainder without passwords, or a reset path for them. That is also why most enterprise plans combine JIT with a full migration rather than relying on it alone.

## Key terms

- JIT migration: creating each user in Descope at first sign-in, after the legacy system confirms their password.
- Generic HTTP Connector: the Flow connector used to call the legacy system's credential check.
- Login Password: the screen component for a user typing a password they already have, rather than choosing a new one.

## Summary

- When JIT is the route: unsupported hash schemes, or hashes that cannot be exported
- The steps of a JIT sign-in, and why each user moves only once
- The password policy rule, and how to protect the legacy endpoint while it runs
- Why JIT leaves stragglers, and why plans usually pair it with a full migration

---

![Cutover and Coexistence.](video:migration-cutover-and-coexistence)

Very few customers can move every user at the same instant. Plan for a transition window in which some users hold Descope sessions and others still hold legacy ones, and design that window deliberately, because it is where a migration that looked finished on paper meets the people using it.

## Running both systems at once

- Dual token validation: the backend reads each token's issuer or `kid`, validates Descope tokens with the Descope SDK, and validates legacy tokens against the old provider's keys
- Phased rollout: route selected tenants or user cohorts to Descope first, so behavior can be compared and rolled back
- The `freshlyMigrated` attribute: set to true on import, so a condition in the sign-in Flow can send migrated users through onboarding before setting it back to false
- Tracking progress: Search Users accepts a `password` filter, and comparing the totals for true and false shows how many password users have moved

That last measure only counts password-based paths. Users moved through session migration or a passwordless method never have a password set, so a customer whose users sign in with magic links will see the `password: false` total stay high whatever progress has been made.

Sessions are the part of a cutover users actually notice. With session migration, a valid session token from the legacy provider, whether Auth0, Okta or a custom issuer, is exchanged for a Descope session, so an active user is not signed out by the switch. It is in beta, and it has firm limits.

## What session migration needs, and what it does not do

- The user must already exist in Descope. Session migration does not create users, so it follows an import rather than replacing one
- Sessions must be token-based, JWTs or access tokens. Opaque server-side cookies cannot be exchanged
- Claims do not carry over. Roles, groups and custom claims from the legacy token have to be recreated with a Descope JWT Template
- Failures are audited as `ExternalSessionMigrationFailure`, most often because the user was never imported

Without session migration, the choice is the older one: let legacy sessions drain naturally, which is invisible but keeps the old system alive longer, or invalidate them and accept that everybody signs in once on cutover day. Neither happens by itself.

> [!WARNING]
> Redirect handling is where a phased rollout usually breaks first. During the window two systems are both sending users back to your application, so both sets of callback URLs and domain allowlists have to be correct at once, and the Approved Domains list covered in Going to Production has to reflect the new world before any traffic reaches it.

## Cutting over and decommissioning

- Schedule the bulk import for a quiet period, and either pause sign-ups or sync new and changed users from the legacy system until cutover
- Move traffic in cohorts: internal users first, then selected tenants, then everyone else
- Watch sign-in success rates, audit events and support tickets after each wave
- Once every user receives Descope tokens, remove legacy token validation and enforce Descope sessions on every endpoint
- Disable JIT connectors, revoke legacy credentials such as Okta API tokens, and retire the old provider

## Key terms

- Dual token validation: backend logic that validates both Descope and legacy tokens during the window, routing by issuer or `kid`.
- Session migration: exchanging a valid legacy session token for a Descope session; in beta, for users already imported.
- ExternalSessionMigrationFailure: the audit event logged when a legacy token cannot be exchanged.
- Cohort rollout: moving users to Descope in planned waves, so problems stay contained and reversible.

## Summary

- How both systems run side by side, and how to measure progress honestly
- What session migration does for active users, and the limits it comes with
- What happens to legacy sessions when session migration is not used
- The order of a cutover, and what decommissioning has to include

---

![Validation and Post-Migration.](video:migration-validation-and-post-migration)

The import is only half the work. A migration script that finished without errors proves the script ran, not that the users can sign in with what they had before, so validation has to exercise the outcome rather than the process. Most post-launch escalations trace back to something a deliberate validation pass would have caught.

## Proving the migration worked

- Compare user, role, permission and tenant counts in the Console with the source system and with the migration tool's output
- Run an unfiltered Search Users call, or one scoped with `fromCreatedTime`, and compare its total with the number of users expected
- Sign in as sample users from every cohort: password, social, enterprise SSO, and users who had MFA enabled
- Read the audit trail: session migration logs `ExternalSessionMigrationSuccess` and `ExternalSessionMigrationFailure`, and proxied SCIM traffic appears as `SCIMEvent` entries for the tenant

The failure that validation is looking for is rarely a crashed sign-in. It is a subset of users whose roles, tenants or attributes did not come across, which looks like a working migration until one of them hits an authorization check.

Some things do not migrate at all: passkeys, which legacy providers generally cannot export, MFA factors a provider will not hand over, and passwords that could not be imported. Use `freshlyMigrated` in a Flow condition to give migrated users a tailored first sign-in: verify an email or phone, enroll a passkey or MFA factor, reset a password that did not come across, and show a short message explaining the change. When onboarding finishes, the Update User / Attributes action sets `freshlyMigrated` to false, so nobody sees those prompts twice.

## Pitfalls behind most escalations

- Missing custom attributes: values for attributes not created before import are silently dropped
- Unicode email domains: import an address such as `user@café.be` in its Unicode form, because the Punycode form is a different login ID and will not match Flow sign-ins
- Password policy mismatch: JIT-captured passwords that fail the Descope policy fail the sign-in, so align policies or provide a reset path
- SCIM assignment confusion: SCIM provisions only users the IdP admin assigned to the application, and group mapping provisions nobody by itself
- Gap users: accounts created between the export and the cutover are missed unless a sync is in place
- Assuming claims carry over: roles and custom claims from legacy tokens have to be rebuilt in Descope

When a customer hits behavior that does not match the documentation, especially around a beta feature such as session migration, capture the audit events and escalate to Descope support rather than guessing at platform internals. A ticket with the events attached gets answered; a theory about how the platform works does not.

## Key terms

- freshlyMigrated: the Boolean custom attribute that routes migrated users through onboarding, cleared once it completes.
- Update User / Attributes: the Flow action that sets `freshlyMigrated` back to false after onboarding.
- Gap users: accounts created in the legacy system between the export and the cutover.

## Summary

- Why a clean script run is not evidence, and what validation should exercise instead
- How to design the first sign-in around what could not be migrated
- The pitfalls behind most post-launch escalations, and how each is avoided
- When to stop investigating and escalate, and what to send

---
