arazzo: 1.0.1 info: title: Stytch Create User and Send Email Magic Link summary: Create a Stytch user, send them an email magic link, and authenticate the resulting token. description: >- A foundational consumer onboarding flow. The workflow first creates a User record from an email address, then sends a login/signup email magic link to that same address, and finally authenticates the magic link token the user clicks to mint a session. Every step spells out its request inline so the flow can be read and executed without opening the underlying OpenAPI description. All calls authenticate with HTTP Basic auth using your Stytch project_id as the username and secret as the password. version: 1.0.0 sourceDescriptions: - name: stytchConsumerApi url: ../openapi/stytch-consumer-openapi.yml type: openapi workflows: - workflowId: create-user-magic-link summary: Create a user, email a magic link, and authenticate the clicked token. description: >- Provisions a new consumer user, dispatches an email magic link to their inbox, and exchanges the token captured from the clicked link for an authenticated Stytch session. inputs: type: object required: - email - login_magic_link_url - signup_magic_link_url - token properties: email: type: string description: The email address to create the user under and send the magic link to. login_magic_link_url: type: string description: The URL the user is redirected to after clicking a login magic link. signup_magic_link_url: type: string description: The URL the user is redirected to after clicking a signup magic link. session_duration_minutes: type: integer description: Optional session lifetime in minutes for the authenticated session. token: type: string description: The magic link token extracted from the URL the user clicked. steps: - stepId: createUser description: >- Add a new consumer user to Stytch using the supplied email address, returning the user_id used by later steps. operationId: api_user_v1_Create requestBody: contentType: application/json payload: email: $inputs.email successCriteria: - condition: $statusCode == 200 outputs: userId: $response.body#/user_id emailId: $response.body#/email_id - stepId: sendMagicLink description: >- Send a login or signup email magic link to the user's email address so they can authenticate by clicking through. operationId: api_magic_v1_magic_links_email_Send requestBody: contentType: application/json payload: email: $inputs.email user_id: $steps.createUser.outputs.userId login_magic_link_url: $inputs.login_magic_link_url signup_magic_link_url: $inputs.signup_magic_link_url successCriteria: - condition: $statusCode == 200 outputs: methodEmailId: $response.body#/email_id - stepId: authenticateMagicLink description: >- Authenticate the magic link token captured from the clicked link to mint an authenticated session for the user. operationId: api_magic_v1_Authenticate requestBody: contentType: application/json payload: token: $inputs.token session_duration_minutes: $inputs.session_duration_minutes successCriteria: - condition: $statusCode == 200 outputs: userId: $response.body#/user_id sessionToken: $response.body#/session_token sessionJwt: $response.body#/session_jwt outputs: userId: $steps.authenticateMagicLink.outputs.userId sessionToken: $steps.authenticateMagicLink.outputs.sessionToken sessionJwt: $steps.authenticateMagicLink.outputs.sessionJwt