# GoTrueApi | @supabase/supabase-js
Documentation for @supabase/supabase-js

### Hierarchy

- GoTrueApi

## Index

### Constructors

- constructor

### Properties

- _createRequestHeaders
- cookieName
- cookieOptions
- fetch
- headers
- url

### Methods

- createUser
- deleteAuthCookie
- deleteUser
- generateLink
- getAuthCookieString
- getUrlForProvider
- getUser
- getUserByCookie
- getUserById
- inviteUserByEmail
- listUsers
- refreshAccessToken
- resetPasswordForEmail
- sendMagicLinkEmail
- sendMobileOTP
- setAuthCookie
- signInWithEmail
- signInWithOpenIDConnect
- signInWithPhone
- signOut
- signUpWithEmail
- signUpWithPhone
- updateUser
- updateUserById
- verifyMobileOTP
- verifyOTP

## Constructors

### constructor

- new GoTrueApi(__namedParameters: { cookieOptions?: CookieOptions ; fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>); headers?: {}; url: string }): GoTrueApi

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:11

  #### Parameters

  - ##### __namedParameters: { cookieOptions?: CookieOptions ; fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>); headers?: {}; url: string }

    - ##### Optional cookieOptions?: CookieOptions

    - ##### Optional fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)

      - - (input: RequestInfo | URL, init?: RequestInit): Promise<Response>

        - #### Parameters

          - ##### input: RequestInfo | URL

          - ##### Optional init: RequestInit

          #### Returns Promise<Response>

    - ##### Optional headers?: {}

      - ##### [key: string]: string

    - ##### url: string

  #### Returns GoTrueApi

## Properties

### Private _createRequestHeaders

_createRequestHeaders: any

- Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:24

Create a temporary object with all configured headers and adds the Authorization token to be used on request methods

param jwt

  A valid, logged-in JWT.

### Private cookieName

cookieName: any

- Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:25

### Protected cookieOptions

cookieOptions: CookieOptions

- Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:9

### Protected fetch

fetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)

- Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:10

#### Type declaration

- - (input: RequestInfo | URL, init?: RequestInit): Promise<Response>

  - #### Parameters

    - ##### input: RequestInfo | URL

    - ##### Optional init: RequestInit

    #### Returns Promise<Response>

### Protected headers

headers: {}

- Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:6

#### Type declaration

- ##### [key: string]: string

### Protected url

url: string

- Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:5

## Methods

### createUser

- createUser(attributes: AdminUserAttributes ): Promise<{ data: null; error: ApiError ; user: null } | { data: AuthUser ; error: null; user: AuthUser }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:251

  Creates a new user.

  This function should only be called on a server. Never expose your `service_role` key in the browser.

  #### Parameters

  - ##### attributes: AdminUserAttributes

    The data you want to create the user with.

  #### Returns Promise<{ data: null; error: ApiError ; user: null } | { data: AuthUser ; error: null; user: AuthUser }>

### deleteAuthCookie

- deleteAuthCookie(req: any, res: any, options: { redirectTo?: string }): any

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:218

  Deletes the Auth Cookies and redirects to the

  #### Parameters

  - ##### req: any

    The request object.

  - ##### res: any

    The response object.

  - ##### options: { redirectTo?: string }

    Optionally specify a `redirectTo` URL in the options.

    - ##### Optional redirectTo?: string

  #### Returns any

### deleteUser

- deleteUser(uid: string): Promise<{ data: null | AuthUser ; error: null | ApiError ; user: null | AuthUser }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:315

  Delete a user. Requires a `service_role` key.

  This function should only be called on a server. Never expose your `service_role` key in the browser.

  #### Parameters

  - ##### uid: string

    The user uid you want to remove.

  #### Returns Promise<{ data: null | AuthUser ; error: null | ApiError ; user: null | AuthUser }>

### generateLink

- generateLink(type: "signup" | "invite" | "magiclink" | "recovery" | "email_change_current" | "email_change_new", email: string, options?: { data?: object; password?: string; redirectTo?: string }): Promise<{ data: null | AuthSession | AuthUser ; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:236

  Generates links to be sent via email or other.

  #### Parameters

  - ##### type: "signup" | "invite" | "magiclink" | "recovery" | "email_change_current" | "email_change_new"

    The link type ("signup" or "magiclink" or "recovery" or "invite").

  - ##### email: string

    The user's email.

  - ##### Optional options: { data?: object; password?: string; redirectTo?: string }

    - ##### Optional data?: object

    - ##### Optional password?: string

    - ##### Optional redirectTo?: string

  #### Returns Promise<{ data: null | AuthSession | AuthUser ; error: null | ApiError }>

### getAuthCookieString

- getAuthCookieString(req: any, res: any): string[]

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:227

  Helper method to generate the Auth Cookie string for you in case you can't use `setAuthCookie`.

  #### Parameters

  - ##### req: any

    The request object.

  - ##### res: any

    The response object.

  #### Returns string[]

  The Cookie string that needs to be set as the value for the `Set-Cookie` header.

### getUrlForProvider

- getUrlForProvider(provider: Provider, options: { queryParams?: {}; redirectTo?: string; scopes?: string }): string

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:32

  Generates the relevant login URL for a third-party provider.

  #### Parameters

  - ##### provider: Provider

    One of the providers supported by GoTrue.

  - ##### options: { queryParams?: {}; redirectTo?: string; scopes?: string }

    - ##### Optional queryParams?: {}

      - ##### [key: string]: string

    - ##### Optional redirectTo?: string

    - ##### Optional scopes?: string

  #### Returns string

### getUser

- getUser(jwt: string): Promise<{ data: null | AuthUser ; error: null | ApiError ; user: null | AuthUser }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:329

  Gets the current user details.

  This method is called by the GoTrueClient `update` where the jwt is set to this.currentSession.access_token and therefore, acts like getting the currently authenticated user

  #### Parameters

  - ##### jwt: string

    A valid, logged-in JWT. Typically, the access_token for the currentSession

  #### Returns Promise<{ data: null | AuthUser ; error: null | ApiError ; user: null | AuthUser }>

### getUserByCookie

- getUserByCookie(req: any, res?: any): Promise<{ data: null | AuthUser ; error: null | ApiError ; token: null | string; user: null | AuthUser }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:290

  Get user by reading the cookie from the request. Works for Next.js & Express (requires cookie-parser middleware).

  #### Parameters

  - ##### req: any

  - ##### Optional res: any

  #### Returns Promise<{ data: null | AuthUser ; error: null | ApiError ; token: null | string; user: null | AuthUser }>

### getUserById

- getUserById(uid: string): Promise<{ data: null; error: ApiError } | { data: AuthUser ; error: null }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:279

  Get user by id.

  #### Parameters

  - ##### uid: string

    The user's unique identifier

    This function should only be called on a server. Never expose your `service_role` key in the browser.

  #### Returns Promise<{ data: null; error: ApiError } | { data: AuthUser ; error: null }>

### inviteUserByEmail

- inviteUserByEmail(email: string, options?: { data?: object; redirectTo?: string }): Promise<{ data: null | AuthUser ; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:177

  Sends an invite link to an email address.

  #### Parameters

  - ##### email: string

    The email address of the user.

  - ##### Optional options: { data?: object; redirectTo?: string }

    - ##### Optional data?: object

    - ##### Optional redirectTo?: string

  #### Returns Promise<{ data: null | AuthUser ; error: null | ApiError }>

### listUsers

- listUsers(): Promise<{ data: null; error: ApiError } | { data: AuthUser []; error: null }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:265

  Get a list of users.

  This function should only be called on a server. Never expose your `service_role` key in the browser.

  #### Returns Promise<{ data: null; error: ApiError } | { data: AuthUser []; error: null }>

### refreshAccessToken

- refreshAccessToken(refreshToken: string): Promise<{ data: null | AuthSession ; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:201

  Generates a new JWT.

  #### Parameters

  - ##### refreshToken: string

    A valid refresh token that was returned on login.

  #### Returns Promise<{ data: null | AuthSession ; error: null | ApiError }>

### resetPasswordForEmail

- resetPasswordForEmail(email: string, options?: { captchaToken?: string; redirectTo?: string }): Promise<{ data: null | {}; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:190

  Sends a reset request to an email address.

  #### Parameters

  - ##### email: string

    The email address of the user.

  - ##### Optional options: { captchaToken?: string; redirectTo?: string }

    - ##### Optional captchaToken?: string

    - ##### Optional redirectTo?: string

  #### Returns Promise<{ data: null | {}; error: null | ApiError }>

### sendMagicLinkEmail

- sendMagicLinkEmail(email: string, options?: { captchaToken?: string; redirectTo?: string; shouldCreateUser?: boolean }): Promise<{ data: null | {}; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:117

  Sends a magic login link to an email address.

  #### Parameters

  - ##### email: string

    The email address of the user.

  - ##### Optional options: { captchaToken?: string; redirectTo?: string; shouldCreateUser?: boolean }

    - ##### Optional captchaToken?: string

    - ##### Optional redirectTo?: string

    - ##### Optional shouldCreateUser?: boolean

  #### Returns Promise<{ data: null | {}; error: null | ApiError }>

### sendMobileOTP

- sendMobileOTP(phone: string, options?: { captchaToken?: string; shouldCreateUser?: boolean }): Promise<{ data: null | {}; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:131

  Sends a mobile OTP via SMS. Will register the account if it doesn't already exist

  #### Parameters

  - ##### phone: string

    The user's phone number WITH international prefix

  - ##### Optional options: { captchaToken?: string; shouldCreateUser?: boolean }

    - ##### Optional captchaToken?: string

    - ##### Optional shouldCreateUser?: boolean

  #### Returns Promise<{ data: null | {}; error: null | ApiError }>

### setAuthCookie

- setAuthCookie(req: any, res: any): void

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:211

  Set/delete the auth cookie based on the AuthChangeEvent. Works for Next.js & Express (requires cookie-parser middleware).

  #### Parameters

  - ##### req: any

    The request object.

  - ##### res: any

    The response object.

  #### Returns void

### signInWithEmail

- signInWithEmail(email: string, password: string, options?: { captchaToken?: string; redirectTo?: string }): Promise<{ data: null | AuthSession ; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:65

  Logs in an existing user using their email address.

  #### Parameters

  - ##### email: string

    The email address of the user.

  - ##### password: string

    The password of the user.

  - ##### Optional options: { captchaToken?: string; redirectTo?: string }

    - ##### Optional captchaToken?: string

    - ##### Optional redirectTo?: string

  #### Returns Promise<{ data: null | AuthSession ; error: null | ApiError }>

### signInWithOpenIDConnect

- signInWithOpenIDConnect(__namedParameters: OpenIDConnectCredentials ): Promise<{ data: null | AuthSession ; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:106

  Logs in an OpenID Connect user using their id_token.

  #### Parameters

  - ##### __namedParameters: OpenIDConnectCredentials

  #### Returns Promise<{ data: null | AuthSession ; error: null | ApiError }>

### signInWithPhone

- signInWithPhone(phone: string, password: string, options?: { captchaToken?: string }): Promise<{ data: null | AuthSession ; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:92

  Logs in an existing user using their phone number and password.

  #### Parameters

  - ##### phone: string

    The phone number of the user.

  - ##### password: string

    The password of the user.

  - ##### Optional options: { captchaToken?: string }

    - ##### Optional captchaToken?: string

  #### Returns Promise<{ data: null | AuthSession ; error: null | ApiError }>

### signOut

- signOut(jwt: string): Promise<{ error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:142

  Removes a logged-in session.

  #### Parameters

  - ##### jwt: string

    A valid, logged-in JWT.

  #### Returns Promise<{ error: null | ApiError }>

### signUpWithEmail

- signUpWithEmail(email: string, password: string, options?: { captchaToken?: string; data?: object; redirectTo?: string }): Promise<{ data: null | AuthSession | AuthUser ; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:50

  Creates a new user using their email address.

  #### Parameters

  - ##### email: string

    The email address of the user.

  - ##### password: string

    The password of the user.

  - ##### Optional options: { captchaToken?: string; data?: object; redirectTo?: string }

    - ##### Optional captchaToken?: string

    - ##### Optional data?: object

    - ##### Optional redirectTo?: string

  #### Returns Promise<{ data: null | AuthSession | AuthUser ; error: null | ApiError }>

  A logged-in session if the server has "autoconfirm" ON

### signUpWithPhone

- signUpWithPhone(phone: string, password: string, options?: { captchaToken?: string; data?: object }): Promise<{ data: null | AuthSession | AuthUser ; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:79

  Signs up a new user using their phone number and a password.

  #### Parameters

  - ##### phone: string

    The phone number of the user.

  - ##### password: string

    The password of the user.

  - ##### Optional options: { captchaToken?: string; data?: object }

    - ##### Optional captchaToken?: string

    - ##### Optional data?: object

  #### Returns Promise<{ data: null | AuthSession | AuthUser ; error: null | ApiError }>

### updateUser

- updateUser(jwt: string, attributes: UserAttributes ): Promise<{ data: null | AuthUser ; error: null | ApiError ; user: null | AuthUser }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:339

  Updates the user data.

  #### Parameters

  - ##### jwt: string

    A valid, logged-in JWT.

  - ##### attributes: UserAttributes

    The data you want to update.

  #### Returns Promise<{ data: null | AuthUser ; error: null | ApiError ; user: null | AuthUser }>

### updateUserById

- updateUserById(uid: string, attributes: AdminUserAttributes ): Promise<{ data: null | AuthUser ; error: null | ApiError ; user: null | AuthUser }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:303

  Updates the user data.

  #### Parameters

  - ##### uid: string

  - ##### attributes: AdminUserAttributes

    The data you want to update.

    This function should only be called on a server. Never expose your `service_role` key in the browser.

  #### Returns Promise<{ data: null | AuthUser ; error: null | ApiError ; user: null | AuthUser }>

### verifyMobileOTP

- verifyMobileOTP(phone: string, token: string, options?: { redirectTo?: string }): Promise<{ data: null | AuthSession | AuthUser ; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:151
  deprecated

    Use `verifyOTP` instead!

  #### Parameters

  - ##### phone: string

    The user's phone number WITH international prefix

  - ##### token: string

    token that user was sent to their mobile phone

  - ##### Optional options: { redirectTo?: string }

    - ##### Optional redirectTo?: string

  #### Returns Promise<{ data: null | AuthSession | AuthUser ; error: null | ApiError }>

### verifyOTP

- verifyOTP(__namedParameters: VerifyOTPParams, options?: { redirectTo?: string }): Promise<{ data: null | AuthSession | AuthUser ; error: null | ApiError }>

- - Defined in node_modules/@supabase/gotrue-js/dist/module/GoTrueApi.d.ts:165

  Send User supplied Email / Mobile OTP to be verified

  #### Parameters

  - ##### __namedParameters: VerifyOTPParams

  - ##### Optional options: { redirectTo?: string }

    - ##### Optional redirectTo?: string

  #### Returns Promise<{ data: null | AuthSession | AuthUser ; error: null | ApiError }>

Generated using TypeDoc