> ## Documentation Index
> Fetch the complete documentation index at: https://docs.turnkey.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Turnkey is wallet infrastructure: create and manage crypto wallets, sign transactions, and enforce policy-based access controls. Best-fit uses: embedded consumer wallets (email/passkey/social auth, no seed phrases), automated onchain operations with server-side wallets, AI agent wallets with policy-scoped signing, enterprise key management, and verifiable off-chain workloads on Turnkey Verifiable Cloud (TVC).
> Every API call is a JSON POST to https://api.turnkey.com signed with a P-256 API key; create an organization and key self-serve at https://app.turnkey.com.
> Key Turnkey developer resources: API reference (https://docs.turnkey.com/api-reference/overview/intro.md), OpenAPI spec (https://docs.turnkey.com/public_api.swagger.json), authentication (https://docs.turnkey.com/features/authentication/overview.md), webhooks (https://docs.turnkey.com/features/webhooks/overview.md), MCP server for docs search (https://docs.turnkey.com/mcp), skill for building with Turnkey (https://docs.turnkey.com/skill.md), agent skills for operating an organization (https://docs.turnkey.com/get-started/ai-skills.md), CLI (https://docs.turnkey.com/sdks/cli.md), SDK reference (https://docs.turnkey.com/sdks/introduction.md), full docs content (https://docs.turnkey.com/llms-full.txt).

# Stamps

> Every request made to Turnkey must include a signature over the POST body attached as a HTTP header. Our secure enclave applications use this signature to verify the integrity and authenticity of the request.

## Why sign the entire request

A signature over the complete POST body proves both possession of a registered
credential and approval of that specific request. Turnkey verifies the stamp
against the exact serialized body it receives; modifying the body after stamping
invalidates the stamp.

The request body is sent separately as the HTTP POST body, not inside the
header. Turnkey's [secure enclaves](https://docs.turnkey.com/security/secure-enclaves.md) verify the stamp
and evaluate the request's intent against your organization's policies,
preventing an intermediary from changing an authorized action.

Activity submissions must also satisfy the [signed-request validity window](https://docs.turnkey.com/api-reference/activities/overview.md#signed-request-validity).

## API keys

For API-key stamps, the `X-Stamp` header contains the public key, signature, and
signature scheme. To create a valid, API key stamped request follow these steps:

**Step 1**

Sign the JSON-encoded POST body with your API key to produce a `signature` (DER-encoded)

**Step 2**

Hex encode the `signature`

**Step 3**

Create a JSON-encoded stamp:

* `publicKey`: the public key of the API key. Turnkey supports multiple API key curves: `API_KEY_CURVE_P256, API_KEY_CURVE_SECP256K1, API_KEY_CURVE_ED25519`
* `signature`: the signature produced by the API key
* `scheme`: the signature scheme used to sign the request, matching the curve of the `publicKey`. The supported schemes are: `SIGNATURE_SCHEME_TK_API_P256, SIGNATURE_SCHEME_TK_API_SECP256K1, SIGNATURE_SCHEME_TK_API_ED25519, SIGNATURE_SCHEME_TK_API_SECP256K1_EIP191`

**Step 4**

Base64URL encode the stamp

**Step 5**

Attach the encoded string to your request as a `X-Stamp` header

**Step 6**

Submit the stamped request to Turnkey's API

## WebAuthn

To create a valid, WebAuthn authenticator stamped request follow these steps:

**Step 1**

Compute the WebAuthn challenge by hashing the POST body bytes (JSON encoded) with SHA256. For example, if the POST body is `{"organization_id": "1234", "type": "ACTIVITY_TYPE_CREATE_API_KEYS", "params": {"for": "example"}}`, the WebAuthn challenge is the string `7e8b4653fc7e51dc119cea031942f4693b4742ceca4dda269b925802b38b2147`

**Step 2**

Include the challenge amongst WebAuthn signing options. Refer to the existing stamper implementations in the [following section](#stampers) for examples

* Note that if you need to pass the challenge as bytes, you'll need to utf8-encode the challenge string (in JS, the challenge bytes will be `TextEncoder().encode("7e8b4653fc7e51dc119cea031942f4693b4742ceca4dda269b925802b38b2147")`)
* Additional note for React Native contexts: the resulting string should then additionally be base64-encoded. See [implementation](https://github.com/tkhq/sdk/blob/b52db566e79a65eec8d8e7066053d6a3ac5f3943/packages/react-native-passkey-stamper/src/util.ts#L5-L10)

**Step 3**

Create a JSON-encoded stamp:

* `credentialId`: the id of the WebAuthn authenticator
* `authenticatorData`: the authenticator data produced by the WebAuthn assertion
* `clientDataJson`: the client data produced by the WebAuthn assertion
* `signature`: the signature produced by the WebAuthn assertion

**Step 4**

Attach the JSON-encoded stamp to your request as a `X-Stamp-Webauthn` header

* Header names are case-insensitive (so `X-Stamp-Webauthn` and `X-Stamp-WebAuthn` are considered equivalent)

* Unlike API key stamps, the format is just JSON; no base64URL encoding necessary! For example: `X-Stamp-Webauthn: {"authenticatorData":"UaQZ...","clientDataJson":"eyJ0...","credentialId":"Grf...","signature":"MEQ..."}`

**Step 5**

Submit the stamped request to Turnkey's API. If you would like your client request to be proxied through a backend, refer to the patterns mentioned [here](https://docs.turnkey.com/features/authentication/passkeys/integration.md#proxying-signed-requests). An example application that uses this pattern can be found at wallet.tx.xyz (code [here](https://github.com/tkhq/demo-embedded-wallet/))

## Attested

Attested stamps allow authenticators that cannot directly sign requests (Email OTP, SMS OTP, and OAuth) to prove identity. Instead of the public key itself being a stored credential, the public key is *attested* by a token that proves ownership of an identity (an email address, phone number, or OAuth provider).

To create a valid attested stamp:

**Step 1**

Generate a P256 key pair on the client

**Step 2**

Obtain a token that attests this key pair belongs to the identity. The token must contain the client public key, cryptographically binding the key to the identity:

* For **Email OTP / SMS OTP**: a `verificationToken` issued by Turnkey after a successful OTP verification. The token embeds the client `public_key` alongside the contact (email or phone).
* For **OAuth**: an `oidcToken` from the OAuth provider (e.g., Google). The token's `nonce` must be set to the hash of the client public key.

**Step 3**

Sign the JSON-encoded POST body with the client private key to produce a `signature`

**Step 4**

Create a JSON-encoded stamp:

* `publicKey`: the public key of the client key pair generated above, hex-encoded in compressed form (33 bytes, `02` or `03` prefix)
* `signature`: the signature over the request body (hex-encoded)
* `publicKeyAttestation`: the token (verification token or OIDC token) that ties the public key to the identity
* `scheme`: the attestation scheme. `STAMP_ATTESTED_SCHEME_P256_VERIFICATION_TOKEN` for Email/SMS OTP, or `STAMP_ATTESTED_SCHEME_P256_OIDC` for OAuth

**Step 5**

Attach the JSON-encoded stamp to your request as a `X-Stamp-Attested` header

**Step 6**

Submit the stamped request to Turnkey's API

## Stampers

Our [JS SDK](https://github.com/tkhq/sdk) and [CLI](https://github.com/tkhq/tkcli) abstract request stamping for you. If you choose to use an independent client, you will need to implement this yourself. For reference, check out our implementations:

> [card] [API Key Stamper](https://github.com/tkhq/sdk/blob/main/packages/api-key-stamper)

> [card] [WebAuthn Stamper](https://github.com/tkhq/sdk/blob/main/packages/webauthn-stamper)

> [card] [React Native Stamper](https://github.com/tkhq/sdk/tree/main/packages/react-native-passkey-stamper)

> [card] [iFrame Stamper](https://github.com/tkhq/sdk/tree/main/packages/iframe-stamper)

> [card] [Telegram Cloud Storage Stamper](https://github.com/tkhq/sdk/tree/main/packages/telegram-cloud-storage-stamper)

> [card] [IndexedDb Stamper](https://github.com/tkhq/sdk/tree/main/packages/indexed-db-stamper)

> [card] [CLI](https://github.com/tkhq/tkcli/blob/main/src/cmd/turnkey/pkg/request.go)

> [card] [Wallet Stamper](https://github.com/tkhq/sdk/tree/main/packages/wallet-stamper)

Our CLI has a `--no-post` option to generate stamps without sending anything over the network. This is a useful tool should you have trouble with debugging stamping-related logic. A sample command might look something like:

```json theme={"system"}
turnkey request --no-post --host api.turnkey.com --path /api/v1/sign --body '{"payload": "hello from TKHQ"}'
{
   "curlCommand": "curl -X POST -d'{\"payload\": \"hello from TKHQ\"}' -H'X-Stamp: eyJwdWJsaWNLZXkiOiIwMzI3YTUwMDMyZTZmMDYzMWQ1NjA1YjZhZGEzMmI3NzkwNzRmMzQ2ZTgxYjY4ZTEyODAxNjQwZjFjOWVlMDNkYWUiLCJzaWduYXR1cmUiOiIzMDQ0MDIyMDM2MjNkZWZkNjE4ZWIzZTIxOTk3MDQ5NjQwN2ViZTkyNDQ3MzE3ZGFkNzVlNDEyYmQ0YTYyNjdjM2I1ZTIyMjMwMjIwMjQ1Yjc0MDg0OGE3MmQwOGI2MGQ2Yzg0ZjMzOTczN2I2M2RiM2JjYmFkYjNiZDBkY2IxYmZiODY1NzE1ZDhiNSIsInNjaGVtZSI6IlNJR05BVFVSRV9TQ0hFTUVfVEtfQVBJX1AyNTYifQ' -v 'https://api.turnkey.com/api/v1/sign'",
   "message": "{\"payload\": \"hello from TKHQ\"}",
   "stamp": "eyJwdWJsaWNLZXkiOiIwMzI3YTUwMDMyZTZmMDYzMWQ1NjA1YjZhZGEzMmI3NzkwNzRmMzQ2ZTgxYjY4ZTEyODAxNjQwZjFjOWVlMDNkYWUiLCJzaWduYXR1cmUiOiIzMDQ0MDIyMDM2MjNkZWZkNjE4ZWIzZTIxOTk3MDQ5NjQwN2ViZTkyNDQ3MzE3ZGFkNzVlNDEyYmQ0YTYyNjdjM2I1ZTIyMjMwMjIwMjQ1Yjc0MDg0OGE3MmQwOGI2MGQ2Yzg0ZjMzOTczN2I2M2RiM2JjYmFkYjNiZDBkY2IxYmZiODY1NzE1ZDhiNSIsInNjaGVtZSI6IlNJR05BVFVSRV9TQ0hFTUVfVEtfQVBJX1AyNTYifQ"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.