Overview
It exposes a ready-made API client class which manages the process of constructing requests to the Turnkey API and authenticating them with a valid API key. Use the@turnkey/sdk-server package to handle
server-side interactions for applications that interact with the Turnkey API.
Installation
Initializing
Parameters
The base URL that API requests will be sent to (use
https://api.turnkey.com when making requests to Turnkey’s API)
The API Private Key to sign requests with (this will normally be the API Private Key to your root
organization)
Creating clients
Calls to Turnkey’s API must be signed with a valid credential (often referred to in the docs as stamping) from the user initiating the API call. When using the Server SDK, the user initiating the API call is normally your root organization, and the API call is authenticated with the API keypair you create on the Turnkey dashboard.apiClient()
The apiClient method returns an instance of the TurnkeyApiClient which will sign requests with
the injected apiPrivateKey, and apiPublicKey credentials.
TurnkeyServerClient
The@turnkey/sdk-server exposes NextJS Server Actions. These server actions can be used to
facilitate implementing common authentication flows.
sendOtp()
Initiate an OTP authentication flow for either an EMAIL or SMS.
Parameters
An object containing the parameters to initiate an
EMAIL or SMS OTP authentication flow.verifyOtp()
Verify the OTP Code sent to the user via EMAIL or SMS.
Parameters
An object containing the parameters to verify an OTP authentication attempt.
createOauthSession()
Complete an OAuth authentication flow after obtaining an OIDC token from the OAuth provider. This
creates a Turnkey session bound to the provided public key.
Parameters
An object containing the parameters to create a Turnkey session via OIDC.
sendCredential()
Send a login credential to a user’s email address.
Parameters
An object containing the parameters to send a login credential via email.