Skip to main content
Stytch logo

Stytch

Lets an agent manage users and drive authentication flows through Stytch's Consumer (B2C) API: create and search users, send and verify magic links and one-time passcodes, manage passwords and sessions, register TOTP authenticators, and authenticate OAuth tokens.

What it can do​

MethodWhat it does
stytch_user_createCreate a user by email or phone number, with optional name, external_id, and metadata.
stytch_user_getGet a single user by user_id.
stytch_user_searchSearch users with an optional query object; supports limit and cursor pagination.
stytch_user_updateUpdate a user's name, external_id, or metadata.
stytch_user_deleteDelete a user (irreversible).
stytch_magic_link_email_sendSend an email magic link to an existing user.
stytch_magic_link_email_login_or_createSend an email magic link, creating the user if they do not exist.
stytch_magic_link_authenticateAuthenticate a magic link token and optionally mint a session.
stytch_otp_sms_sendSend a one-time passcode by SMS.
stytch_otp_whatsapp_sendSend a one-time passcode by WhatsApp.
stytch_otp_email_sendSend a one-time passcode by email.
stytch_otp_authenticateAuthenticate an OTP using the method_id and code.
stytch_password_createCreate a password-backed user (password is validated for strength).
stytch_password_authenticateAuthenticate a user with email and password.
stytch_password_reset_startStart a password reset by email.
stytch_password_strength_checkCheck password strength (and breach status if an email is supplied).
stytch_session_getList a user's active sessions.
stytch_session_authenticateValidate and optionally extend a session token or JWT.
stytch_session_revokeRevoke a session by id, token, or JWT.
stytch_totp_createRegister a TOTP authenticator for a user.
stytch_totp_authenticateAuthenticate a 6-digit TOTP code.
stytch_oauth_authenticateAuthenticate an OAuth token returned to your redirect URL.
stytch_requestGeneric passthrough to any Consumer (B2C) endpoint for full API coverage.

How to get your keys​

Stytch authenticates server-side calls with HTTP Basic auth: your Project ID as the username and your Secret as the password. Both come from the same dashboard page.

  1. Sign in at stytch.com/dashboard.
  2. Open Project Overview and find the Project ID & API keys section (key management docs).
  3. Copy the Project ID - it looks like project-test-... (Test) or project-live-... (Live).
  4. Copy the Secret - it looks like secret-test-... / secret-live-.... Keep it private; never expose it in client-side code.
  5. Note which environment the keys belong to. Test and Live are separate projects with separate keys and separate users.

Fields to fill​

FlyMyAI fieldWhere it comes from
STYTCH_PROJECT_IDStytch Dashboard -> Project Overview -> Project ID & API keys
STYTCH_SECRETSame page as the Project ID (kept private)
STYTCH_ENVOptional - test (default) or live, matching the project whose keys you pasted

Troubleshooting​

  • 401 unauthorized_credentials - the Project ID or Secret is wrong, or they are from different projects. Re-copy both from the same Project Overview page.
  • Test keys do not see your live users - Test and Live are separate environments. Set STYTCH_ENV=live and use the project-live-... / secret-live-... pair to act on live data.
  • user_not_found on magic link send - stytch_magic_link_email_send requires an existing user; use stytch_magic_link_email_login_or_create to create one on the fly.
  • unable_to_auth_otp_code / expired - OTP codes are short-lived (a few minutes). Re-send and authenticate promptly with the method_id from the send response.
We love our partners - FlyMy.AI builds with the best. Thanks, Stytch!