---
name: turnkey
description: Use when building wallet infrastructure, managing cryptographic
  keys, signing transactions, implementing authentication flows, or provisioning
  wallets for users or agents. Reach for Turnkey when you need non-custodial
  wallet management, policy-based access controls, transaction broadcasting, or
  secure key storage in hardware-backed enclaves.
metadata:
  mintlify-proj: turnkey
  version: "1.0"
---

# Turnkey Skill

## Product summary

Turnkey is wallet infrastructure for developers: secure key management, transaction signing, and programmable access controls built on hardware-backed secure enclaves. Keys never leave the enclave—Turnkey returns signed payloads and handles transaction broadcasting. The platform is API-first (all operations are JSON POST requests to `https://api.turnkey.com`), with SDKs for TypeScript, React, React Native, Swift, Kotlin, and Flutter. Core concepts: organizations (top-level entity), sub-organizations (isolated per end-user), users (with credentials like API keys or passkeys), wallets (HD wallets generating accounts across chains), policies (rules evaluated in the enclave before signing), and activities (any action submitted to Turnkey). Start at [docs.turnkey.com](https://docs.turnkey.com).

## When to use

Reach for Turnkey when you need to:

- **Embed wallets in consumer apps** — Non-custodial wallets users access with email, passkeys, phone, or social login. No seed phrases or browser extensions.
- **Automate onchain operations** — Server-side wallets for payouts, treasury operations, payment orchestration, or smart contract management at scale.
- **Provision agent wallets** — Give AI agents signing authority constrained by policies: spending caps, destination allowlists, approval flows.
- **Secure high-value keys** — Hardware-backed storage and programmable access controls for signing keys, encryption keys, and secrets.
- **Sign across chains** — Millions of isolated sub-organizations and low-latency signing for EVM, Solana, Bitcoin, and 20+ other chains.
- **Implement authentication flows** — Passkeys, email OTP, SMS, OAuth, or external wallet login with session management and MFA.

## Quick reference

### Core API endpoints

All requests are POST to `https://api.turnkey.com` with a digital signature ("stamp") in the header.

| Task | Endpoint pattern | Notes |
|------|------------------|-------|
| Create wallet | `POST /v1/submit` with `create_wallet` activity | Returns `walletId` |
| Sign transaction | `POST /v1/submit` with `sign_transaction` activity | Supports EVM, Solana, Bitcoin, etc. |
| Broadcast transaction | `POST /v1/submit` with `broadcast_evm_transaction` or `broadcast_svm_transaction` | Can sponsor gas |
| Create user | `POST /v1/submit` with `create_users` activity | Add authenticators (API key, passkey, email) |
| Create policy | `POST /v1/submit` with `create_policy` activity | Evaluated in enclave before signing |
| Query wallets | `POST /v1/query` with `list_wallets` | Read-only, no signature required |
| Get user | `POST /v1/query` with `get_user` | Returns user details and credentials |

### Authentication methods

| Method | Use case | Client-side | Server-side |
|--------|----------|-------------|------------|
| API key | Backend requests, automation | ✗ | ✓ |
| Passkey | User login, transaction approval | ✓ | ✗ |
| Email OTP | Passwordless signup/login | ✓ | ✗ |
| SMS | Phone-based verification | ✓ | ✗ |
| OAuth | Social login (Google, Apple, Discord, etc.) | ✓ | ✗ |
| External wallet | Sign-In With Ethereum/Solana | ✓ | ✗ |

### Wallet and account structure

```
Organization
├── User (with API key or passkey)
├── Sub-organization (isolated per end-user)
│   ├── User (end-user with passkey)
│   ├── Wallet (HD wallet with seed)
│   │   ├── Account (Ethereum: m/44'/60'/0'/0/0)
│   │   ├── Account (Solana: m/44'/501'/0'/0')
│   │   └── Account (Bitcoin: m/84'/0'/0'/0/0)
│   └── Policies (control who signs what)
```

### Stampers (request signers)

| Stamper | When to use | Notes |
|---------|------------|-------|
| API key stamper | Backend requests | Securely stores private key on device |
| Passkey stamper | User-initiated actions | Prompts user to sign with biometric/hardware key |
| Wallet stamper | External wallet signing | Uses MetaMask, Phantom, etc. |
| Session stamper | Authenticated frontend | Uses session JWT from login |

### Supported chains (transaction broadcasting)

**EVM:** Base, Polygon, Ethereum, Arbitrum, BNB Chain, Optimism, Monad, Arc, Robinhood Chain (+ testnets)  
**Solana:** Mainnet, devnet  
**Other:** Bitcoin, Spark, Cosmos, Tron, Sui, Aptos, Stacks, Cardano, and 10+ more (signing only)

## Decision guidance

### When to use sub-organizations vs. users

| Scenario | Use sub-organizations | Use users |
|----------|----------------------|-----------|
| Each end-user gets their own wallet | ✓ | ✗ |
| Multiple team members in one org | ✗ | ✓ |
| Isolation required (multi-tenant) | ✓ | ✗ |
| Shared policies and wallets | ✗ | ✓ |
| Scaling to millions of wallets | ✓ | ✗ |

### When to use policies vs. root quorum

| Control | Root quorum | Policies |
|---------|------------|----------|
| Bind root users | ✓ | ✗ |
| Bind non-root users | ✗ | ✓ |
| Require approval threshold | ✓ | ✓ |
| Enforce spending caps | ✗ | ✓ |
| Allowlist destinations | ✗ | ✓ |
| Require MFA | ✓ | ✓ |
| Bypass on recovery | ✗ | ✓ |

### When to use sign transaction vs. sign raw payload

| Method | Use case | Parsing | Policy support |
|--------|----------|---------|-----------------|
| `sign_transaction` | EVM/Solana transactions | ✓ (network-specific) | ✓ (full) |
| `sign_raw_payload` | Any message/payload | ✗ (curve-based) | ✗ (limited) |

## Workflow

### 1. Set up organization and API key

1. Navigate to [app.turnkey.com/dashboard](https://app.turnkey.com/dashboard/auth/initial) and create an account.
2. Copy your Organization ID from the user dropdown.
3. Go to My Profile → Create an API key → Name it → Approve with your authenticator.
4. Save the private key immediately (not visible after this step).
5. Store both public and private keys securely; never expose to end-users.

### 2. Create a sub-organization for an end-user

1. Call `create_sub_organization` activity with:
   - Organization name
   - Root users (e.g., end-user passkey + your backend API key)
   - Root quorum threshold (e.g., 2 for multi-sig)
2. Receive `subOrganizationId` and store it mapped to your user.
3. All future API calls for that user reference this `subOrganizationId`.

### 3. Create a wallet and accounts

1. Call `create_wallet` activity with:
   - Wallet name
   - List of accounts (e.g., Ethereum, Solana)
   - Mnemonic length (default 12 words, up to 24)
2. Receive `walletId` and account addresses.
3. Store wallet ID; addresses are public and can be shared.

### 4. Implement authentication

1. Choose auth method(s): passkey, email OTP, OAuth, or external wallet.
2. For embedded wallets: use `@turnkey/react-wallet-kit` (React) or `@turnkey/core` (TypeScript).
3. Call login/signup function (e.g., `loginWithPasskey`, `signUpWithOTP`).
4. Receive session JWT; store in browser local storage or mobile async storage.
5. Use session to make authenticated requests without re-stamping.

### 5. Sign and broadcast a transaction

1. Prepare unsigned transaction (e.g., EVM: `to`, `value`, `data`, `chainId`).
2. Call `sign_transaction` with wallet account address and transaction.
3. Receive signed transaction.
4. Call `broadcast_evm_transaction` or `broadcast_svm_transaction` to submit onchain.
5. Poll `get_send_transaction_status` to track confirmation.

### 6. Create and enforce policies

1. Write policy in Turnkey's policy language (JSON-like syntax).
2. Call `create_policy` activity with policy definition.
3. Policies are evaluated in the enclave before any signing.
4. Use `get_policy_evaluations` to debug policy decisions.

## Common gotchas

- **API keys are not wallet keys.** API keys authenticate requests to Turnkey; wallet keys are generated inside the enclave and never exposed. Keep API keys secure; never share with end-users.
- **Stamping is required for all requests.** Every POST to Turnkey must include a digital signature in the `X-Stamp` header. Use a stamper (API key, passkey, or session) to sign automatically.
- **Activities can be asynchronous.** If your organization has high activity volume, submissions may return `ACTIVITY_STATUS_PENDING`. Poll with `get_activity` until terminal state (COMPLETED, FAILED, REJECTED). TypeScript SDKs do this automatically with configurable `activityPoller`.
- **Root quorum does not bind policies.** Root users bypass policies. Use root quorum only for critical operations (e.g., policy changes). Non-root users are always bound by policies.
- **Policies do not bind root users.** If you need to control root users, use root quorum or MFA policies instead.
- **Session scope is checked before policies.** If a session has a restricted scope (e.g., recovery-only), it cannot perform actions outside that scope, even if policies allow it.
- **Wallets must be exported before deletion.** Deleting a wallet requires prior export to prevent accidental loss of funds, unless you pass `deleteWithoutExport: true`.
- **Mnemonic length is permanent.** Once a wallet is created with a 12-word mnemonic, you cannot change it to 24 words. Choose upfront.
- **Sub-org parent has read-only access.** Parent organizations cannot modify sub-org wallets or policies. This isolation is intentional.
- **Email recovery is low-confidence.** Always pair email recovery with a second factor (passkey, MFA) that does not depend on the same inbox.
- **Consensus activities require approval.** If a policy requires consensus (e.g., 2-of-2 multi-sig), the activity returns `ACTIVITY_STATUS_CONSENSUS_NEEDED`. Route to your approval flow; do not poll.

## Verification checklist

Before deploying to production:

- [ ] API keys are stored securely (environment variables, secrets manager, not in code).
- [ ] Root quorum is configured with at least 2 users and threshold ≥ 2 (unless single-user is intentional).
- [ ] Policies are written and tested; use `get_policy_evaluations` to verify logic.
- [ ] Sub-organizations are created for each end-user with appropriate root users.
- [ ] Wallets are created with accounts for all supported chains.
- [ ] Authentication flow is tested end-to-end (signup, login, session creation).
- [ ] Transaction signing and broadcasting work on testnet.
- [ ] Gas sponsorship is enabled in the dashboard if you plan to sponsor gas.
- [ ] Webhooks are configured to track activity status changes.
- [ ] Error handling covers `ACTIVITY_STATUS_PENDING`, `CONSENSUS_NEEDED`, and `AUTHENTICATORS_NEEDED`.
- [ ] Rate limits are understood; implement exponential backoff for retries.
- [ ] Backup and recovery flows are tested (export wallet, recover with passkey).
- [ ] Security checklist items are complete: least privilege policies, user tags for role-based access, MFA enforcement, IP allowlisting if needed.

## Resources

- **Comprehensive navigation:** [docs.turnkey.com/llms.txt](https://docs.turnkey.com/llms.txt) — page-by-page listing for agent navigation.
- **Core documentation:**
  - [About Turnkey](https://docs.turnkey.com/get-started/about-turnkey) — core concepts, architecture, use cases.
  - [API Reference](https://docs.turnkey.com/api-reference/overview/intro) — all endpoints, activities, queries, and error codes.
  - [Securing Your Integration](https://docs.turnkey.com/security/securing-your-integration) — security best practices, threat model, controls.

---

> For additional documentation and navigation, see: https://docs.turnkey.com/llms.txt