Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tkhq/sdk/llms.txt

Use this file to discover all available pages before exploring further.

The Turnkey SDK distributes types across several packages. Most types you need are re-exported by the higher-level packages, but you can always import directly from the source package for precision.
@turnkey/sdk-server and @turnkey/react-wallet-kit both re-export the types they depend on, so in most cases you will not need to install @turnkey/sdk-types or @turnkey/http separately just to access types.

Type sources

PackageWhat it provides
@turnkey/sdk-typesShared session, auth, and error types; generated protobuf types
@turnkey/httpActivity types, signed request types, and the full TurnkeyApiTypes namespace
@turnkey/sdk-serverServer-side config and proxy handler types

Core types

Session

import type { Session, SessionResponse, SessionType } from "@turnkey/sdk-types";

enum SessionType {
  READ_ONLY  = "SESSION_TYPE_READ_ONLY",
  READ_WRITE = "SESSION_TYPE_READ_WRITE",
}

type Session = {
  sessionType: SessionType;
  userId: string;
  organizationId: string;
  expiry: number;
  expirationSeconds?: string;
  token: string;
  publicKey?: string;
};

type SessionResponse = {
  session: Session;
  user: {
    id: string;
    name: string;
    email: string;
    organizationId: string;
    organizationName: string;
  };
};

Auth results

import type {
  BaseAuthResult,
  PasskeyAuthResult,
  WalletAuthResult,
} from "@turnkey/sdk-types";

interface BaseAuthResult {
  sessionToken: string;
  appProofs?: v1AppProof[];
}

interface PasskeyAuthResult extends BaseAuthResult {
  credentialId: string;
}

interface WalletAuthResult extends BaseAuthResult {
  address: string;
}

TActivity

Represents a Turnkey activity object. Sourced from the generated API types.
import type { TActivity, TActivityId, TActivityStatus, TActivityType } from "@turnkey/http";

// TActivity is an alias for definitions["v1Activity"]
// TActivityId    = TActivity["id"]
// TActivityStatus = TActivity["status"]
// TActivityType   = TActivity["type"]
id
string
Unique identifier for the activity.
status
TActivityStatus
Current status: ACTIVITY_STATUS_CREATED, ACTIVITY_STATUS_PENDING, ACTIVITY_STATUS_CONSENSUS_NEEDED, ACTIVITY_STATUS_COMPLETED, ACTIVITY_STATUS_FAILED, or ACTIVITY_STATUS_REJECTED.
type
TActivityType
The kind of mutation — for example, ACTIVITY_TYPE_CREATE_PRIVATE_KEYS or ACTIVITY_TYPE_SIGN_RAW_PAYLOAD.
organizationId
string
The organization that owns this activity.
result
object
Present only when status is ACTIVITY_STATUS_COMPLETED. Contains the operation-specific result (e.g. signRawPayloadResult, createPrivateKeysResultV2).

TSignedRequest

A fully signed request ready to be forwarded to Turnkey. Returned by all stamp* methods on TurnkeyClient.
import type { TSignedRequest, TSignature } from "@turnkey/http";

type TSignedRequest = {
  body: string;   // JSON-stringified request body
  stamp: TStamp;  // stampHeaderName + stampHeaderValue
  url: string;    // full request URL
};

type TStamp = {
  stampHeaderName: string;
  stampHeaderValue: string;
};

// TSignature — result of a sign_raw_payload activity
type TSignature = definitions["v1SignRawPayloadResult"];
// Contains: r, s, v

TurnkeyApiTypes namespace

TurnkeyApiTypes exposes every definition from the Turnkey OpenAPI spec as a TypeScript type. Use it to reference request/response shapes without importing individual named types.
import type { TurnkeyApiTypes } from "@turnkey/http";

// Access any schema definition:
type Wallet        = TurnkeyApiTypes["v1Wallet"];
type WalletAccount = TurnkeyApiTypes["v1WalletAccount"];
type PrivateKey    = TurnkeyApiTypes["v1PrivateKey"];
type Policy        = TurnkeyApiTypes["v1Policy"];
type User          = TurnkeyApiTypes["v1User"];

Error types

import {
  TurnkeyError,
  TurnkeyNetworkError,
  TurnkeyErrorCodes,
} from "@turnkey/sdk-types";

import {
  TurnkeyRequestError,
  TurnkeyActivityError,
  TurnkeyActivityConsensusNeededError,
  InvalidArgumentError,
} from "@turnkey/http";
ClassPackageWhen thrown
TurnkeyRequestError@turnkey/httpNon-2xx HTTP response from the API
TurnkeyActivityError@turnkey/httpActivity reaches FAILED or REJECTED
TurnkeyActivityConsensusNeededError@turnkey/httpActivity requires consensus approvals
TurnkeyError@turnkey/sdk-typesGeneral SDK errors (higher-level packages)
TurnkeyNetworkError@turnkey/sdk-typesNetwork-level errors in higher-level packages
TurnkeyErrorCodes is a large enum covering all error conditions surfaced by the SDK. Import it from @turnkey/sdk-types when you need to branch on a specific error code:
import { TurnkeyError, TurnkeyErrorCodes } from "@turnkey/sdk-types";

try {
  await sdk.createWallet(...);
} catch (error) {
  if (
    error instanceof TurnkeyError &&
    error.code === TurnkeyErrorCodes.CREATE_WALLET_ERROR
  ) {
    // handle wallet creation failure
  }
}

Build docs developers (and LLMs) love