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.
To create a valid, API key stamped request follow these steps:
Sign the JSON-encoded POST body with your API key to produce a signature
(DER-encoded)
Hex encode the signature
Create a JSON-encoded stamp:
publicKey
: the public key of API key, note that only P-256 keys (API_KEY_CURVE_P256) are currenlty supportedsignature
: the signature produced by the API keyscheme
: SIGNATURE_SCHEME_TK_API_P256
Base64URL encode the stamp
Attach the encoded string to your request as a X-Stamp
header
Submit the stamped request to Turnkey’s API
To create a valid, Webauthn authenticator stamped request follow these steps:
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
Include the challenge amongst WebAuthn signing options. Refer to the existing stamper implementations in the following section) for examples
TextEncoder().encode("7e8b4653fc7e51dc119cea031942f4693b4742ceca4dda269b925802b38b2147")
)Create a JSON-encoded stamp:
credentialId
: the id of the webauthn authenticatorauthenticatorData
: the authenticator data produced by Webauthn assertionclientDataJson
: the client data produced by the Webauthn assertionsignature
: the signature produced by the Webauthn assertionAttach 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..."}
Our JS SDK and CLI 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:
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:
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.
To create a valid, API key stamped request follow these steps:
Sign the JSON-encoded POST body with your API key to produce a signature
(DER-encoded)
Hex encode the signature
Create a JSON-encoded stamp:
publicKey
: the public key of API key, note that only P-256 keys (API_KEY_CURVE_P256) are currenlty supportedsignature
: the signature produced by the API keyscheme
: SIGNATURE_SCHEME_TK_API_P256
Base64URL encode the stamp
Attach the encoded string to your request as a X-Stamp
header
Submit the stamped request to Turnkey’s API
To create a valid, Webauthn authenticator stamped request follow these steps:
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
Include the challenge amongst WebAuthn signing options. Refer to the existing stamper implementations in the following section) for examples
TextEncoder().encode("7e8b4653fc7e51dc119cea031942f4693b4742ceca4dda269b925802b38b2147")
)Create a JSON-encoded stamp:
credentialId
: the id of the webauthn authenticatorauthenticatorData
: the authenticator data produced by Webauthn assertionclientDataJson
: the client data produced by the Webauthn assertionsignature
: the signature produced by the Webauthn assertionAttach 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..."}
Our JS SDK and CLI 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:
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: