Skip to main content

Create a User with Email Only

This example demonstrates how to create a sub organization using just an end-user's email: passkeys not required! Note that this flow does not require emails to be verified.

1. Initialize Turnkey

import { Turnkey } from "@turnkey/sdk-browser";

const turnkey = new Turnkey({
apiBaseUrl: "https://api.turnkey.com",
defaultOrganizationId: process.env.TURNKEY_ORGANIZATION_ID,
});

2. Configure the Sub Organization for the User

import { DEFAULT_ETHEREUM_ACCOUNTS } from "@turnkey/sdk-browser;"

const subOrganizationConfig = {
subOrganizationName: <subOrganizationName>,
rootUsers: [{
userName: <userEmail>,
userEmail: <userEmail>,
apiKeys: [],
authenticators: [],
oauthProviders: []
}],
rootQuorumThreshold: 1,
wallet: {
walletName: <walletName>,
accounts: DEFAULT_ETHEREUM_ACCOUNTS
}
};

3. Call createSubOrganization from your backend

await turnkey.serverSign("createSubOrganization", [subOrganizationConfig]);

This is all that is needed to create a user without any authentication credential other than their email address, in the login flow you can see how to then authenticate the user after their subOrganization is created.

Ask AI