Adds an existing password to a User's email that doesn't have a password yet. We support migrating users from passwords stored with bcrypt, scrypt, argon2, MD-5, SHA-1, or PBKDF2. This endpoint has a rate limit of 100 requests per second.
Migrate Password
POST
https://test.stytch.com/v1/passwords/migrateBody parameters
email* string
name object
phone_number string
trusted_metadata object
untrusted_metadata object
hash* string
hash_type* string
scrypt_config object
argon_2_config object
md_5_config object
sha_1_config object
pbkdf_2_config object
set_email_verified boolean
set_phone_number_verified boolean
external_id string
Response fields
status_code int
request_id string
user_id string
user object
email_id string
user_created boolean
const stytch = require('stytch');
const client = new stytch.Client({
project_id: 'PROJECT_ID',
secret: 'SECRET',
});
const params = {
email: "sandbox@stytch.com",
hash: "$2a$12$vefoDBbzuMb/NczV/fc9QemTizkNAZr9EO02pIUHPAAJibcYp0.ne",
hash_type: "bcrypt",
phone_number: "+12025550162",
external_id: "my-new-external-id",
};
client.passwords.migrate(params)
.then(resp => { console.log(resp) })
.catch(err => { console.log(err) });
RESPONSE
200
{
"status_code": 200,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6",
"email_id": "email-test-81bf03a8-86e1-4d95-bd44-bb3495224953",
"user_created": true
}
Common Error Types
- duplicate_phone_number
- invalid_argon_2_salt
- invalid_base64_scrypt_hash
- invalid_bcrypt_cost
- invalid_bcrypt_hash
- invalid_email
- invalid_hash
- invalid_hash_type
- invalid_md_5_hash
- invalid_pbkdf_2_hash
- invalid_pbkdf_2_iteration_amount
- invalid_pbkdf_2_salt
- invalid_phone_number
- invalid_phpass_hash_prefix
- invalid_scrypt_salt_length
- invalid_sha_1_hash
- password_already_exists
- pbkdf_2_key_length_mismatch
- scrypt_key_length_mismatch
- too_many_unverified_factors