Before this: read the Agent Wallets overview and install
@dynamic-labs-wallet/node.Generate a session key pair
generateSessionKeyPair returns a P-256 key pair: publicKeyHex (33-byte compressed public key, lowercase hex) and privateKeyJwk (the private key as a JWK). The SDK stores nothing — you persist the JWK in your secrets vault.
Create the auth client
createAuthClient performs Dynamic sign-in flows headlessly — the server-side counterpart to the JS client SDK’s sign-in. It holds configuration only: no secrets, no persistence. Set appOrigin to the origin your sign-ins present as; it must be on your environment’s allowlisted CORS origins.
Sign in with wallet.signIn
wallet.signIn runs the whole flow in one call — it fetches a nonce, builds the sign-in message (deriving its domain and URI from appOrigin; pass domain and uri per call to override), collects the signature from your signMessage callback, and verifies it to mint the JWT. The callback is the only difference between the two modes: the agent signs with its own key, or a human signs in your app’s UI.
- Autonomous agent
- Human user
No human in the loop: the agent signs with its agent signing token. If the agent does not have one yet, generate it once and store it in your secrets vault or KMS:On every run, load the stored token and sign in with it:The Dynamic user is keyed to this public address, so use the same agent signing token every run to keep operating the same user’s wallets — and re-authentication at the refresh limit needs no human either. For custody requirements, see Storage & Security.
{ jwt, expiresAt, userId }. Sign-in fails with a descriptive error when address is not a 0x-prefixed 20-byte hex address, when neither appOrigin nor domain/uri is provided, when the signature or nonce is invalid or expired, when the account requires MFA (the headless client does not support MFA), or when the environment uses cookie-based auth (the response carries no JWT in the body).
For custom message construction, auth.wallet also exposes the underlying primitives — getNonce, createMessage, and verify. See the Wallet sign-in reference.