Turnkey home page
Search...
⌘K
Ask AI
Demo
Login
Get started
Get started
Search...
Navigation
SDK reference
importPrivateKey()
Documentation
SDK reference
API reference
Security
Changelogs
Support
Blog
Contact us
SDK reference
Introduction
React
React Native
Flutter
Swift
TypeScript | Frontend
Overview
Getting Started
Authentication
Advanced backend authentication
Advanced API requests
Legacy (@turnkey/sdk-browser)
SDK reference
addOauthProvider()
addPasskey()
clearAllSessions()
clearSession()
clearUnusedKeyPairs()
completeOauth()
completeOtp()
connectWalletAccount()
constructor()
createApiKeyPair()
createPasskey()
createWallet()
createWalletAccounts()
deleteSubOrganization()
disconnectWalletAccount()
exportPrivateKey()
exportWallet()
exportWalletAccount()
fetchUser()
fetchWalletAccounts()
fetchWallets()
getActiveSessionKey()
getAllSessions()
getProxyAuthConfig()
getSession()
getWalletProviders()
importPrivateKey()
importWallet()
init()
initOtp()
loginOrSignupWithWallet()
loginWithOauth()
loginWithOtp()
loginWithPasskey()
loginWithWallet()
logout()
refreshSession()
removeOauthProviders()
removePasskeys()
removeUserEmail()
removeUserPhoneNumber()
setActiveSession()
signAndSendTransaction()
signMessage()
signTransaction()
signUpWithOauth()
signUpWithOtp()
signUpWithPasskey()
signUpWithWallet()
storeSession()
switchWalletProviderChain()
updateUserEmail()
updateUserName()
updateUserPhoneNumber()
verifyOtp()
switchWalletAccountChain()
fetchPrivateKeys()
TypeScript | Server
Golang
Rust
Ruby
CLI
Python
Web3 libraries
Advanced
Migration Path
SDK reference
importPrivateKey()
Copy page
Copy page
Overview
Imports a private key from an encrypted bundle.
This function imports a private key using the provided encrypted bundle.
If a userId is provided, the private key will be imported for that specific user; otherwise, it uses the current session’s userId.
Requires address formats to
Automatically infers the cryptographic curve used to generate the private key based on the address format (can be optionally overriden if needed).
The encrypted bundle MUST be encrypted to ensure security.
Automatically ensures an active session exists before making the request.
Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
Package:
core
Defined in:
core.ts:3427
Parameters
params
object
required
Show params details
params.
addressFormats
v1AddressFormat[]
required
params.
curve
v1Curve
required
the cryptographic curve used to generate a given private key
params.
encryptedBundle
string
required
encrypted bundle containing the private key key material and metadata.
params.
privateKeyName
string
required
name of the private key to create upon import.
params.
stampWith
StamperType
parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
params.
userId
string
user ID to import the wallet for a specific user (defaults to the current session’s userId).
Response
A successful response returns the following fields:
returns
string
required
A promise that resolves to the ID of the imported wallet.
Was this page helpful?
Yes
No
getWalletProviders()
importWallet()
Assistant
Responses are generated using AI and may contain mistakes.