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

# Login or Create

> Login or create user with email magic links using the Stytch Vanilla JS SDK

The Login or create method wraps the [Login or Create](/api-reference/consumer/api/magic-links/via-email/log-in-or-create-user) Email Magic Link API endpoint.

## Parameters

<ParamField body="email" type="string" required>
  The email address of the User to send the Magic Link to.
</ParamField>

<ParamField body="Configuration" type="object">
  Additional configuration.

  <Expandable title="properties">
    <ParamField body="login_magic_link_url" type="string">
      The URL the end user clicks from the login Email Magic Link. This should be a URL that your app receives and parses and subsequently send an API request to authenticate the Magic Link and log in the User. If this value is not passed, the default login redirect URL that you set in your Dashboard is used. If you have not set a default login redirect URL, an error is returned.
    </ParamField>

    <ParamField body="signup_magic_link_url" type="string">
      The URL the end user clicks from the sign-up Email Magic Link. This should be a URL that your app receives and parses and subsequently send an API request to authenticate the Magic Link and sign-up the User. If this value is not passed, the default sign-up redirect URL that you set in your Dashboard is used. If you have not set a default sign-up redirect URL, an error is returned.
    </ParamField>

    <ParamField body="login_expiration_minutes" type="int">
      Set the expiration for the login email magic link, in minutes. By default, it expires in 1 hour. The minimum expiration is 5 minutes and the maximum is 7 days (10080 mins).
    </ParamField>

    <ParamField body="signup_expiration_minutes" type="int">
      Set the expiration for the sign-up email magic link, in minutes. By default, it expires in 1 week. The minimum expiration is 5 minutes and the maximum is 7 days (10080 mins).
    </ParamField>

    <ParamField body="login_template_id" type="string">
      Use a custom template for login emails. By default, it will use your default email template. Templates can be added in the [Stytch dashboard](https://stytch.com/dashboard/templates) using our built-in customization options or custom HTML templates with type “Magic links - Login”.
    </ParamField>

    <ParamField body="signup_template_id" type="string">
      Use a custom template for sign-up emails. By default, it will use your default email template. Templates can be added in the [Stytch dashboard](https://stytch.com/dashboard/templates) using our built-in customization options or custom HTML templates with type “Magic links - Sign-up”.
    </ParamField>

    <ParamField body="locale" type="string">
      Used to determine which language to use when sending the user this delivery method. Parameter is an [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. "en". Supported languages are English ("en"), Spanish ("es"), French ("fr") and Brazilian Portuguese ("pt-br"); if no value is provided, the copy defaults to English.
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="request_id" type="string">
  Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we
  may ask for this value to help identify a specific API call when helping you debug an issue.
</ResponseField>

<ResponseField name="status_code" type="number">
  The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values
  equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
</ResponseField>

<Panel>
  <RequestExample>
    ```js theme={null}
    import { StytchClient } from '@stytch/vanilla-js';

    const stytch = new StytchClient('${publicToken}');

    export const sendEmailMagicLink = () => {
    stytch.magicLinks.email.loginOrCreate('${email}', {
      login_magic_link_url: '${exampleURL}/authenticate',
      login_expiration_minutes: 60,
      signup_magic_link_url: '${exampleURL}/authenticate',
      signup_expiration_minutes: 60,
    });
    };
    ```
  </RequestExample>

  <ResponseExample>
    ```json 200 theme={null}
    {
        "status_code": 200,
        "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141"
    }
    ```

    ```json 400 theme={null}
    {
      "status_code": 400,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "invalid_magic_link_url",
      "error_message": "magic_link_url format is invalid. Common issues include using http instead of https, omitting https://, or having a trailing /.",
      "error_url": "https://stytch.com/docs/api/errors/400"
    }
    ```

    ```json 401 theme={null}
    {
      "status_code": 401,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "unauthorized_credentials",
      "error_message": "Unauthorized credentials.",
      "error_url": "https://stytch.com/docs/api/errors/401"
    }
    ```

    ```json 429 theme={null}
    {
      "status_code": 429,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "too_many_requests",
      "error_message": "Too many requests have been made.",
      "error_url": "https://stytch.com/docs/api/errors/429"
    }
    ```

    ```json 500 theme={null}
    {
      "status_code": 500,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "internal_server_error",
      "error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
      "error_url": "https://stytch.com/docs/api/errors/500"
    }
    ```
  </ResponseExample>
</Panel>
