authentication

Verify email OTP

Complete email OTP authentication by verifying the one-time password. Returns a session if validation is successful.

post/signin/otp/email/verify

Request body

otpstring required

One time password

emailstring email required

A valid email

Example request

{
  "email": "john.smith@nhost.io"
}

Response

Magic link sent to user's email successfully

Example response

{
  "session": {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "accessTokenExpiresIn": 900,
    "refreshTokenId": "2c35b6f3-c4b9-48e3-978a-d4d0f1d42e24",
    "refreshToken": "2c35b6f3-c4b9-48e3-978a-d4d0f1d42e24",
    "user": {
      "avatarUrl": "https://myapp.com/avatars/user123.jpg",
      "createdAt": "2023-01-15T12:34:56Z",
      "defaultRole": "user",
      "displayName": "John Smith",
      "email": "john.smith@nhost.io",
      "emailVerified": true,
      "id": "2c35b6f3-c4b9-48e3-978a-d4d0f1d42e24",
      "locale": "en",
      "metadata": {
        "firstName": "John",
        "lastName": "Smith"
      },
      "phoneNumber": "+12025550123",
      "roles": [
        "user",
        "customer"
      ]
    }
  }
}

Changes

Changed in 5 of the 15 revisions of this API.144

    • added the new otp-too-many-attempts enum value to the error response property for the response status default

      response-property-enum-value-added

  • b39086c84b4311See the full diff
    • added the new user-already-exists enum value to the error response property for the response status default

      response-property-enum-value-added

    • removed the email-already-in-use enum value from the error response property for the response status default

      response-property-enum-value-removed

    • the session/user/locale response property's maxLength was increased from 2 to 3 for the response status 200

      response-property-max-length-increased

    • added the new provider-account-already-linked enum value to the error response property for the response status default

      response-property-enum-value-added

    • added the new email-already-in-use enum value to the error response property for the response status default

      response-property-enum-value-added

    • removed the otp-too-many-attempts enum value from the error response property for the response status default

      response-property-enum-value-removed

    • removed the provider-account-already-linked enum value from the error response property for the response status default

      response-property-enum-value-removed

    • removed the user-already-exists enum value from the error response property for the response status default

      response-property-enum-value-removed

    This revision also has 20 changes that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog