authentication

Sign in anonymously

Changed on

Create an anonymous user session without providing credentials. Anonymous users can be converted to regular users later via the deanonymize endpoint. This endpoint always creates a new user and is not gated by AUTH_DISABLE_AUTO_SIGNUP; it is controlled by AUTH_DISABLE_SIGNUP and AUTH_ANONYMOUS_USERS_ENABLED.

post/signin/anonymous

Request

  • Base URL
    https://{subdomain}.auth.{region}.nhost.run/v1
  • URL
    https://{subdomain}.auth.{region}.nhost.run/v1/signin/anonymous
  • Auth
    none declared

Request body

displayNamestring
localestring

A two or three characters locale

metadataobject

Example request

{
  "displayName": "John Smith",
  "locale": "en",
  "metadata": {
    "firstName": "John",
    "lastName": "Smith"
  }
}

Response

Successfully signed in

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

    • breaking

      the response property // became nullable for the status

    • warning

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