Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

enhance(refs): add params and return examples for database and auth (#26676)

Charis3c196e3bf5c7
diff --git a/apps/docs/components/reference/RefFunctionSection.tsx b/apps/docs/components/reference/RefFunctionSection.tsx
index 597cf1ac7b2..8c9d9fecd8a 100644
--- a/apps/docs/components/reference/RefFunctionSection.tsx
+++ b/apps/docs/components/reference/RefFunctionSection.tsx
@@ -17,7 +17,9 @@ const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
const tsDefinition =
hasTsRef && props.typeSpec ? extractTsDocNode(hasTsRef, props.typeSpec) : null
- const parameters = hasTsRef && tsDefinition ? generateParameters(tsDefinition) : item.params
+ const parameters =
+ item.overwriteParams ??
+ (hasTsRef && tsDefinition ? generateParameters(tsDefinition) : item.params)
const shortText = hasTsRef && tsDefinition ? tsDefinition.signatures[0].comment?.shortText : ''
return (
diff --git a/apps/docs/spec/supabase_js_v2.yml b/apps/docs/spec/supabase_js_v2.yml
index ec47cb68c69..96f9fa8a3f9 100644
--- a/apps/docs/spec/supabase_js_v2.yml
+++ b/apps/docs/spec/supabase_js_v2.yml
@@ -237,6 +237,45 @@ functions:
- When both **Confirm email** and **Confirm phone** (even when phone provider is disabled) are enabled in [your project](/dashboard/project/_/auth/providers), an obfuscated/fake user object is returned.
- When either **Confirm email** or **Confirm phone** (even when phone provider is disabled) is disabled, the error message, `User already registered` is returned.
- To fetch the currently logged-in user, refer to [`getUser()`](/docs/reference/javascript/auth-getuser).
+ overwriteParams:
+ - name: credentials
+ type: SignUpWithPasswordCredentials
+ subContent:
+ - name: email
+ isOptional: true
+ type: string
+ description: One of `email` or `phone` must be provided.
+ - name: phone
+ isOptional: true
+ type: string
+ description: One of `email` or `phone` must be provided.
+ - name: password
+ type: string
+ - name: options
+ isOptional: true
+ type: object
+ subContent:
+ - name: emailRedirectTo
+ isOptional: true
+ type: string
+ description: >
+ Only for email signups.
+ The redirect URL embedded in the email link.
+ Must be a configured redirect URL for your Supabase instance.
+ - name: data
+ isOptional: true
+ type: object
+ description: >
+ A custom data object to store additional user metadata.
+ - name: captchaToken
+ isOptional: true
+ type: string
+ - name: channel
+ isOptional: true
+ type: sms | whatsapp
+ description: >
+ The channel to use for sending messages.
+ Only for phone signups.
examples:
- id: sign-up
name: Sign up with an email and password
@@ -248,6 +287,94 @@ functions:
password: 'example-password',
})
```
+ response: |
+ ```json
+ // Some fields may be null if "confirm email" is enabled.
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {},
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z"
+ },
+ "session": {
+ "access_token": "<ACCESS_TOKEN>",
+ "token_type": "bearer",
+ "expires_in": 3600,
+ "expires_at": 1700000000,
+ "refresh_token": "<REFRESH_TOKEN>",
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {},
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z"
+ }
+ }
+ },
+ "error": null
+ }
+ ```
- id: sign-up-phone
name: Sign up with a phone number and password (SMS)
isSpotlight: true
@@ -524,6 +651,49 @@ functions:
}
});
```
+ response: |
+ ```json
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "",
+ "phone": "",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {},
+ "user_metadata": {},
+ "identities": [],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": true
+ },
+ "session": {
+ "access_token": "<ACCESS_TOKEN>",
+ "token_type": "bearer",
+ "expires_in": 3600,
+ "expires_at": 1700000000,
+ "refresh_token": "<REFRESH_TOKEN>",
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "",
+ "phone": "",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {},
+ "user_metadata": {},
+ "identities": [],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": true
+ }
+ }
+ },
+ "error": null
+ }
+ ```
- id: sign-in-anonymously-with-user-metadata
name: Create an anonymous user with custom user metadata
isSpotlight: false
@@ -539,6 +709,27 @@ functions:
- id: sign-in-with-password
title: 'signInWithPassword()'
$ref: '@supabase/auth-js.GoTrueClient.signInWithPassword'
+ overwriteParams:
+ - name: credentials
+ type: SignInWithPasswordCredentials
+ subContent:
+ - name: email
+ isOptional: true
+ type: string
+ description: One of `email` or `phone` must be provided.
+ - name: phone
+ isOptional: true
+ type: string
+ description: One of `email` or `phone` must be provided.
+ - name: password
+ type: string
+ - name: options
+ isOptional: true
+ type: object
+ subContent:
+ - name: captchaToken
+ isOptional: true
+ type: string
notes: |
- Requires either an email and password or a phone number and password.
examples:
@@ -552,6 +743,93 @@ functions:
password: 'example-password',
})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {},
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z"
+ },
+ "session": {
+ "access_token": "<ACCESS_TOKEN>",
+ "token_type": "bearer",
+ "expires_in": 3600,
+ "expires_at": 1700000000,
+ "refresh_token": "<REFRESH_TOKEN>",
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {},
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z"
+ }
+ }
+ },
+ "error": null
+ }
+ ```
- id: sign-in-with-phone-and-password
name: Sign in with phone and password
isSpotlight: false
@@ -565,6 +843,49 @@ functions:
- id: sign-in-with-otp
title: 'signInWithOtp()'
$ref: '@supabase/auth-js.GoTrueClient.signInWithOtp'
+ overwriteParams:
+ - name: credentials
+ type: SignInWithPasswordlessCredentials
+ subContent:
+ - name: email
+ isOptional: true
+ type: string
+ description: One of `email` or `phone` must be provided.
+ - name: phone
+ isOptional: true
+ type: string
+ description: One of `email` or `phone` must be provided.
+ - name: options
+ isOptional: true
+ type: object
+ subContent:
+ - name: emailRedirectTo
+ isOptional: true
+ type: string
+ description: >
+ Only for email signups.
+ The redirect URL embedded in the email link.
+ Must be a configured redirect URL for your Supabase instance.
+ - name: shouldCreateUser
+ isOptional: true
+ type: boolean
+ description: >
+ Whether to create the user if they don't already exist.
+ Defaults to true.
+ - name: data
+ isOptional: true
+ type: object
+ description: >
+ A custom data object to store additional user metadata.
+ - name: captchaToken
+ isOptional: true
+ type: string
+ - name: channel
+ isOptional: true
+ type: sms | whatsapp
+ description: >
+ The channel to use for sending messages.
+ Only for phone signups.
notes: |
- Requires either an email or phone number.
- This method is used for passwordless sign-ins where a OTP is sent to the user's email or phone number.
@@ -589,6 +910,16 @@ functions:
}
})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "user": null,
+ "session": null
+ },
+ "error": null
+ }
+ ```
- id: sign-in-with-sms-otp
name: Sign in with SMS OTP
isSpotlight: false
@@ -628,6 +959,16 @@ functions:
provider: 'github'
})
```
+ response: |
+ ```json
+ {
+ data: {
+ provider: 'github',
+ url: <PROVIDER_URL_TO_REDIRECT_TO>
+ },
+ error: null
+ }
+ ```
- id: sign-in-using-a-third-party-provider-with-redirect
name: Sign in using a third-party provider with redirect
isSpotlight: false
@@ -695,9 +1036,91 @@ functions:
token: 'your-id-token'
})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ ...
+ },
+ "user_metadata": {
+ ...
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "provider": "google",
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ },
+ "session": {
+ "access_token": "<ACCESS_TOKEN>",
+ "token_type": "bearer",
+ "expires_in": 3600,
+ "expires_at": 1700000000,
+ "refresh_token": "<REFRESH_TOKEN>",
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ ...
+ },
+ "user_metadata": {
+ ...
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "provider": "google",
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ }
+ }
+ },
+ "error": null
+ }
+ ```
- id: sign-in-with-sso
title: 'signInWithSSO()'
$ref: '@supabase/auth-js.GoTrueClient.signInWithSSO'
+ overwriteParams:
+ - name: params
+ type: SignInWithSSO
+ subContent:
+ - name: providerId
+ isOptional: true
+ type: string
+ description: >
+ UUID of the SSO provider.
+ One of `providerId` or `domain` is required.
+ - name: domain
+ isOptional: true
+ type: string
+ description: >
+ Domain name of the organization to use SSO with.
+ One of `providerId` or `domain` is required.
+ - name: options
+ isOptional: true
+ type: object
+ subContent:
+ - name: redirectTo
+ type: string
+ description: >
+ The URL to redirect the user to after they have signed in.
+ Must be a configured redirect URL for your Supabase instance.
+ - name: captchaToken
+ type: string
notes: |
- Before you can call this method you need to [establish a connection](/docs/guides/auth/sso/auth-sso-saml#managing-saml-20-connections) to an identity provider. Use the [CLI commands](/docs/reference/cli/supabase-sso) to do this.
- If you've associated an email domain to the identity provider, you can use the `domain` property to start a sign-in flow.
@@ -757,18 +1180,49 @@ functions:
- id: verify-otp
title: 'verifyOtp()'
$ref: '@supabase/auth-js.GoTrueClient.verifyOtp'
+ overwriteParams:
+ - name: params
+ type: VerifyOtpParams
+ subContent:
+ - name: phone
+ isOptional: true
+ type: string
+ description: One of `phone`, `email`, or `token_hash` must be provided.
+ - name: email
+ isOptional: true
+ type: string
+ description: One of `phone`, `email`, or `token_hash` must be provided.
+ - name: token_hash
+ isOptional: true
+ type: string
+ description: >
+ The token hash from the user's email link.
+ One of `phone`, `email`, or `token_hash` must be provided.
+ - name: type
+ type: sms | phone_change | signup | invite | magiclink | recovery | email_change | email
+ - name: token
+ isOptional: true
+ type: string
+ description: The OTP sent to the user. Required if using `phone` or `email`.
+ - name: options
+ isOptional: true
+ type: object
+ subContent:
+ - name: redirectTo
+ isOptional: true
+ type: string
+ description: >
+ A URL to redirect the user to after they are confirmed.
+ Must be in your configured redirect URLs.
+ - name: captchaToken
+ isOptional: true
+ type: string
+ description: Deprecated.
notes: |
- The `verifyOtp` method takes in different verification types. If a phone number is used, the type can either be `sms` or `phone_change`. If an email address is used, the type can be one of the following: `email`, `recovery`, `invite` or `email_change` (`signup` and `magiclink` types are deprecated).
- The verification type used should be determined based on the corresponding auth method called before `verifyOtp` to sign up / sign-in a user.
- The `TokenHash` is contained in the [email templates](/docs/guides/auth/auth-email-templates) and can be used to sign in. You may wish to use the hash with Magic Links for the PKCE flow for Server Side Auth. See [this guide](/docs/guides/auth/server-side/email-based-auth-with-pkce-flow-for-ssr) for more details.
examples:
- - id: verify-sms-one-time-password(otp)
- name: Verify Sms One-Time Password (OTP)
- isSpotlight: true
- code: |
- ```js
- const { data, error } = await supabase.auth.verifyOtp({ phone, token, type: 'sms'})
- ```
- id: verify-signup-one-time-password(otp)
name: Verify Signup One-Time Password (OTP)
isSpotlight: false
@@ -776,6 +1230,116 @@ functions:
```js
const { data, error } = await supabase.auth.verifyOtp({ email, token, type: 'email'})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "confirmed_at": "2024-01-01T00:00:00Z",
+ "recovery_sent_at": "2024-01-01T00:00:00Z",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ },
+ "session": {
+ "access_token": "<ACCESS_TOKEN>",
+ "token_type": "bearer",
+ "expires_in": 3600,
+ "expires_at": 1700000000,
+ "refresh_token": "<REFRESH_TOKEN>",
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "confirmed_at": "2024-01-01T00:00:00Z",
+ "recovery_sent_at": "2024-01-01T00:00:00Z",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ }
+ }
+ },
+ "error": null
+ }
+ ```
+ - id: verify-sms-one-time-password(otp)
+ name: Verify Sms One-Time Password (OTP)
+ isSpotlight: true
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.verifyOtp({ phone, token, type: 'sms'})
+ ```
- id: verify-email-auth(tokenhash)
name: Verify Email Auth (Token Hash)
isSpotlight: false
@@ -799,6 +1363,63 @@ functions:
```js
const { data, error } = await supabase.auth.getSession()
```
+ response: |
+ ```json
+ {
+ "data": {
+ "session": {
+ "access_token": "<ACCESS_TOKEN>",
+ "token_type": "bearer",
+ "expires_in": 3600,
+ "expires_at": 1700000000,
+ "refresh_token": "<REFRESH_TOKEN>",
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ }
+ }
+ },
+ "error": null
+ }
+ ```
- id: start-auto-refresh
title: 'startAutoRefresh()'
$ref: '@supabase/auth-js.GoTrueClient.startAutoRefresh'
@@ -864,6 +1485,57 @@ functions:
```js
const { data: { user } } = await supabase.auth.getUser()
```
+ response: |
+ ```json
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "confirmed_at": "2024-01-01T00:00:00Z",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ }
+ },
+ "error": null
+ }
+ ```
- id: get-the-logged-in-user-with-a-custom-access-token-jwt
name: Get the logged in user with a custom access token jwt
isSpotlight: false
@@ -890,6 +1562,59 @@ functions:
})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "confirmed_at": "2024-01-01T00:00:00Z",
+ "new_email": "[email protected]",
+ "email_change_sent_at": "2024-01-01T00:00:00Z",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ }
+ },
+ "error": null
+ }
+ ```
- id: update-the-phone-for-an-authenticated-user
name: Update the phone number for an authenticated user
description: Sends a one-time password (OTP) to the new phone number.
@@ -943,6 +1668,32 @@ functions:
```js
const { data, error } = await supabase.auth.getUserIdentities()
```
+ response: |
+ ```json
+ {
+ "data": {
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "2024-01-01T00:00:00Z",
+ "user_id": "2024-01-01T00:00:00Z",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ]
+ },
+ "error": null
+ }
+ ```
- id: link-identity
title: 'linkIdentity()'
$ref: '@supabase/auth-js.GoTrueClient.linkIdentity'
@@ -950,13 +1701,26 @@ functions:
- The **Enable Manual Linking** option must be enabled from your [project's authentication settings](/dashboard/project/_/settings/auth).
- The user needs to be signed in to call `linkIdentity()`.
- If the candidate identity is already linked to the existing user or another user, `linkIdentity()` will fail.
+ - If `linkIdentity` is run in the browser, the user is automatically redirected to the returned URL. On the server, you should handle the redirect.
examples:
- id: link-identity
name: Link an identity to a user
isSpotlight: true
code: |
```js
- const { data, error } = await supabase.auth.linkIdentity()
+ const { data, error } = await supabase.auth.linkIdentity({
+ provider: 'github'
+ })
+ ```
+ response: |
+ ```json
+ {
+ data: {
+ provider: 'github',
+ url: <PROVIDER_URL_TO_REDIRECT_TO>
+ },
+ error: null
+ }
```
- id: unlink-identity
title: 'unlinkIdentity()'
@@ -981,7 +1745,7 @@ functions:
)
// unlink the google identity
- const { data, error } = await supabase.auth.unlinkIdentity(googleIdentity)
+ const { error } = await supabase.auth.unlinkIdentity(googleIdentity)
```
- id: send-password-reauthentication
title: 'reauthenticate()'
@@ -998,7 +1762,7 @@ functions:
isSpotlight: true
code: |
```js
- const { data, error } = await supabase.auth.reauthenticate()
+ const { error } = await supabase.auth.reauthenticate()
```
- id: resend-email-or-phone-otps
title: 'resend()'
@@ -1016,7 +1780,7 @@ functions:
isSpotlight: true
code: |
```js
- const { data, error } = await supabase.auth.resend({
+ const { error } = await supabase.auth.resend({
type: 'signup',
options: {
@@ -1029,7 +1793,7 @@ functions:
description: Resends the phone signup confirmation email to the user
code: |
```js
- const { data, error } = await supabase.auth.resend({
+ const { error } = await supabase.auth.resend({
type: 'sms',
phone: '1234567890'
})
@@ -1039,7 +1803,7 @@ functions:
description: Resends the email change email to the user
code: |
```js
- const { data, error } = await supabase.auth.resend({
+ const { error } = await supabase.auth.resend({
type: 'email_change',
})
@@ -1049,7 +1813,7 @@ functions:
description: Resends the phone change OTP to the user
code: |
```js
- const { data, error } = await supabase.auth.resend({
+ const { error } = await supabase.auth.resend({
type: 'phone_change',
phone: '1234567890'
})
@@ -1074,6 +1838,107 @@ functions:
refresh_token
})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "confirmed_at": "2024-01-01T00:00:00Z",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ },
+ "session": {
+ "access_token": "<ACCESS_TOKEN>",
+ "refresh_token": "<REFRESH_TOKEN>",
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "confirmed_at": "2024-01-01T00:00:00Z",
+ "last_sign_in_at": "11111111-1111-1111-1111-111111111111",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "identities": [
+ {
+ "identity_id": "2024-01-01T00:00:00Z",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ },
+ "token_type": "bearer",
+ "expires_in": 3500,
+ "expires_at": 1700000000
+ }
+ },
+ "error": null
+ }
+ ```
- id: refresh-session
title: 'refreshSession()'
$ref: '@supabase/auth-js.GoTrueClient.refreshSession'
@@ -1088,6 +1953,105 @@ functions:
const { data, error } = await supabase.auth.refreshSession()
const { session, user } = data
```
+ response: |
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "confirmed_at": "2024-01-01T00:00:00Z",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ },
+ "session": {
+ "access_token": "<ACCESS_TOKEN>",
+ "token_type": "bearer",
+ "expires_in": 3600,
+ "expires_at": 1700000000,
+ "refresh_token": "<REFRESH_TOKEN>",
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "confirmed_at": "2024-01-01T00:00:00Z",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ }
+ }
+ },
+ "error": null
+ }
- id: refresh-session-using-a-passed-in-session
name: Refresh session using a refresh token
isSpotlight: false
@@ -1110,6 +2074,162 @@ functions:
```js
supabase.auth.exchangeCodeForSession('34e770dd-9ff9-416c-87fa-43b31d7ef225')
```
+ response: |
+ ```json
+ {
+ "data": {
+ session: {
+ access_token: '<ACCESS_TOKEN>',
+ token_type: 'bearer',
+ expires_in: 3600,
+ expires_at: 1700000000,
+ refresh_token: '<REFRESH_TOKEN>',
+ user: {
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email_confirmed_at: '2024-01-01T00:00:00Z',
+ phone: '',
+ confirmation_sent_at: '2024-01-01T00:00:00Z',
+ confirmed_at: '2024-01-01T00:00:00Z',
+ last_sign_in_at: '2024-01-01T00:00:00Z',
+ app_metadata: {
+ "provider": "email",
+ "providers": [
+ "email",
+ "<OTHER_PROVIDER>"
+ ]
+ },
+ user_metadata: {
+ email: '[email protected]',
+ email_verified: true,
+ full_name: 'User Name',
+ iss: '<ISS>',
+ name: 'User Name',
+ phone_verified: false,
+ provider_id: '<PROVIDER_ID>',
+ sub: '<SUB>'
+ },
+ identities: [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ },
+ {
+ "identity_id": "33333333-3333-3333-3333-333333333333",
+ "id": "<ID>",
+ "user_id": "<USER_ID>",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": true,
+ "full_name": "User Name",
+ "iss": "<ISS>",
+ "name": "User Name",
+ "phone_verified": false,
+ "provider_id": "<PROVIDER_ID>",
+ "sub": "<SUB>"
+ },
+ "provider": "<PROVIDER>",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ is_anonymous: false
+ },
+ provider_token: '<PROVIDER_TOKEN>',
+ provider_refresh_token: '<PROVIDER_REFRESH_TOKEN>'
+ },
+ user: {
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ email_confirmed_at: '2024-01-01T00:00:00Z',
+ phone: '',
+ confirmation_sent_at: '2024-01-01T00:00:00Z',
+ confirmed_at: '2024-01-01T00:00:00Z',
+ last_sign_in_at: '2024-01-01T00:00:00Z',
+ app_metadata: {
+ provider: 'email',
+ providers: [
+ "email",
+ "<OTHER_PROVIDER>"
+ ]
+ },
+ user_metadata: {
+ email: '[email protected]',
+ email_verified: true,
+ full_name: 'User Name',
+ iss: '<ISS>',
+ name: 'User Name',
+ phone_verified: false,
+ provider_id: '<PROVIDER_ID>',
+ sub: '<SUB>'
+ },
+ identities: [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ },
+ {
+ "identity_id": "33333333-3333-3333-3333-333333333333",
+ "id": "<ID>",
+ "user_id": "<USER_ID>",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": true,
+ "full_name": "User Name",
+ "iss": "<ISS>",
+ "name": "User Name",
+ "phone_verified": false,
+ "provider_id": "<PROVIDER_ID>",
+ "sub": "<SUB>"
+ },
+ "provider": "<PROVIDER>",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ is_anonymous: false
+ },
+ redirectType: null
+ },
+ "error": null
+ }
+ ```
- id: auth-mfa-api
title: 'Overview'
notes: |
@@ -1146,6 +2266,22 @@ functions:
// The code will be generated upon scanning the qr_code or entering the secret into the authenticator app.
const { id, type, totp: { qr_code, secret, uri }, friendly_name } = data
```
+ response: |
+ ```json
+ {
+ data: {
+ id: '<ID>',
+ type: 'totp'
+ totp: {
+ qr_code: '<QR_CODE_AS_SVG_DATA>',
+ secret: '<SECRET>',
+ uri: '<URI>',
+ }
+ friendly_name?: 'Important app'
+ },
+ error: null
+ }
+ ```
- id: mfa-challenge
title: 'mfa.challenge()'
$ref: '@supabase/auth-js.GoTrueMFAApi.challenge'
@@ -1162,6 +2298,16 @@ functions:
factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225'
})
```
+ response: |
+ ```json
+ {
+ data: {
+ id: '<ID>',
+ expires_at: 1700000000
+ },
+ error: null
+ }
+ ```
- id: mfa-verify
title: 'mfa.verify()'
$ref: '@supabase/auth-js.GoTrueMFAApi.verify'
@@ -1179,6 +2325,65 @@ functions:
code: '123456'
})
```
+ response: |
+ ```json
+ {
+ data: {
+ access_token: '<ACCESS_TOKEN>',
+ token_type: 'Bearer',
+ expires_in: 3600,
+ refresh_token: '<REFRESH_TOKEN>',
+ user: {
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ email_confirmed_at: '2024-01-01T00:00:00Z',
+ phone: '',
+ confirmation_sent_at: '2024-01-01T00:00:00Z',
+ confirmed_at: '2024-01-01T00:00:00Z',
+ last_sign_in_at: '2024-01-01T00:00:00Z',
+ app_metadata: {
+ provider: 'email',
+ providers: [
+ "email",
+ ]
+ },
+ user_metadata: {},
+ identities: [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": true,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ },
+ ],
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ is_anonymous: false,
+ factors: [
+ "id": '<ID>',
+ "friendly_name": 'Important Auth App',
+ "factor_type": 'totp',
+ "status": 'verified',
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z"
+ ]
+ }
+ }
+ error: null
+ }
+ ```
- id: mfa-challenge-and-verify
title: 'mfa.challengeAndVerify()'
$ref: '@supabase/auth-js.GoTrueMFAApi.challengeAndVerify'
@@ -1196,6 +2401,65 @@ functions:
code: '123456'
})
```
+ response: |
+ ```json
+ {
+ data: {
+ access_token: '<ACCESS_TOKEN>',
+ token_type: 'Bearer',
+ expires_in: 3600,
+ refresh_token: '<REFRESH_TOKEN>',
+ user: {
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ email_confirmed_at: '2024-01-01T00:00:00Z',
+ phone: '',
+ confirmation_sent_at: '2024-01-01T00:00:00Z',
+ confirmed_at: '2024-01-01T00:00:00Z',
+ last_sign_in_at: '2024-01-01T00:00:00Z',
+ app_metadata: {
+ provider: 'email',
+ providers: [
+ "email",
+ ]
+ },
+ user_metadata: {},
+ identities: [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": true,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ },
+ ],
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ is_anonymous: false,
+ factors: [
+ "id": '<ID>',
+ "friendly_name": 'Important Auth App',
+ "factor_type": 'totp',
+ "status": 'verified',
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z"
+ ]
+ }
+ }
+ error: null
+ }
+ ```
- id: mfa-unenroll
title: 'mfa.unenroll()'
$ref: '@supabase/auth-js.GoTrueMFAApi.unenroll'
@@ -1209,6 +2473,15 @@ functions:
factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',
})
```
+ response: |
+ ```json
+ {
+ data: {
+ id: '<FACTOR_ID>'
+ },
+ error: null
+ }
+ ```
- id: mfa-get-authenticator-assurance-level
title: 'mfa.getAuthenticatorAssuranceLevel()'
$ref: '@supabase/auth-js.GoTrueMFAApi.getAuthenticatorAssuranceLevel'
@@ -1225,6 +2498,22 @@ functions:
const { data, error } = await supabase.auth.mfa.getAuthenticatorAssuranceLevel()
const { currentLevel, nextLevel, currentAuthenticationMethods } = data
```
+ response: |
+ ```json
+ {
+ data: {
+ currentLevel: 'aal1',
+ nextLevel: 'aal2',
+ currentAuthenticationMethods: [
+ {
+ method: 'password',
+ timestamp: 1700000000
+ }
+ ]
+ }
+ error: null
+ }
+ ```
- id: admin-api
title: 'Overview'
notes: |
@@ -1263,6 +2552,48 @@ functions:
```js
const { data, error } = await supabase.auth.admin.getUserById(1)
```
+ response: |
+ ```json
+ {
+ data: {
+ user: {
+ id: '1',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ email_confirmed_at: '2024-01-01T00:00:00Z',
+ phone: '',
+ confirmation_sent_at: '2024-01-01T00:00:00Z',
+ confirmed_at: '2024-01-01T00:00:00Z',
+ last_sign_in_at: '2024-01-01T00:00:00Z',
+ app_metadata: {},
+ user_metadata: {},
+ identities: [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "1",
+ "user_id": "1",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": true,
+ "phone_verified": false,
+ "sub": "1"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ },
+ ],
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ is_anonymous: false,
+ }
+ }
+ error: null
+ }
+ ```
- id: list-users
title: 'listUsers()'
@@ -1306,6 +2637,48 @@ functions:
user_metadata: { name: 'Yoda' }
})
```
+ response: |
+ ```json
+ {
+ data: {
+ user: {
+ id: '1',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ email_confirmed_at: '2024-01-01T00:00:00Z',
+ phone: '',
+ confirmation_sent_at: '2024-01-01T00:00:00Z',
+ confirmed_at: '2024-01-01T00:00:00Z',
+ last_sign_in_at: '2024-01-01T00:00:00Z',
+ app_metadata: {},
+ user_metadata: {},
+ identities: [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "1",
+ "user_id": "1",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": true,
+ "phone_verified": false,
+ "sub": "1"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ },
+ ],
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ is_anonymous: false,
+ }
+ }
+ error: null
+ }
+ ```
- id: auto-confirm-the-users-email
name: Auto-confirm the user's email
code: |
@@ -1339,7 +2712,15 @@ functions:
'715ed5db-f090-4b8c-a067-640ecee36aa0'
)
```
-
+ response: |
+ ```json
+ {
+ "data": {
+ "user": {}
+ },
+ "error": null
+ }
+ ```
- id: invite-user-by-email
title: 'inviteUserByEmail()'
$ref: '@supabase/auth-js.GoTrueAdminApi.inviteUserByEmail'
@@ -1355,6 +2736,51 @@ functions:
```js
const { data, error } = await supabase.auth.admin.inviteUserByEmail('[email protected]')
```
+ response: |
+ ```json
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "invited_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "confirmation_sent_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {},
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ }
+ },
+ "error": null
+ }
+ ```
- id: reset-password-for-email
title: 'resetPasswordForEmail()'
@@ -1384,6 +2810,13 @@ functions:
redirectTo: 'https://example.com/update-password',
})
```
+ response: |
+ ```json
+ {
+ data: {}
+ error: null
+ }
+ ```
- id: reset-password-react
name: Reset password (React)
isSpotlight: true
@@ -1421,6 +2854,35 @@ functions:
- The following types can be passed into `generateLink()`: `signup`, `magiclink`, `invite`, `recovery`, `email_change_current`, `email_change_new`, `phone_change`.
- `generateLink()` only generates the email link for `email_change_email` if the **Secure email change** is enabled in your project's [email auth provider settings](/dashboard/project/_/auth/providers).
- `generateLink()` handles the creation of the user for `signup`, `invite` and `magiclink`.
+ overwriteParams:
+ - name: params
+ type: GenerateLinkParams
+ subContent:
+ - name: type
+ type: 'signup | invite | magiclink | recovery | email_change_current | email_change_new'
+ - name: email
+ type: string
+ - name: password
+ type: string
+ isOptional: true
+ description: Only required if type is `signup`.
+ - name: newEmail
+ type: string
+ isOptional: true
+ description: Only required if type is `email_change_current` or `email_change_new`.
+ - name: options
+ type: object
+ isOptional: true
+ subContent:
+ - name: data
+ type: object
+ description: >
+ Custom JSON object containing user metadata, to be stored in the `raw_user_meta_data` column.
+ Only accepted if type is `signup`, `invite`, or `magiclink`.
+ - name: redirectTo
+ type: string
+ description: >
+ A redirect URL which will be appended to the generated email link.
examples:
- id: generate-a-signup-link
name: Generate a signup link
@@ -1433,6 +2895,57 @@ functions:
password: 'secret'
})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "properties": {
+ "action_link": "<LINK_TO_SEND_TO_USER>",
+ "email_otp": "999999",
+ "hashed_token": "<HASHED_TOKEN",
+ "redirect_to": "<REDIRECT_URL>",
+ "verification_type": "signup"
+ },
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "phone": "",
+ "confirmation_sent_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {},
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ }
+ },
+ "error": null
+ }
+ ```
- id: generate-an-invite-link
name: Generate an invite link
isSpotlight: false
@@ -1493,10 +3006,62 @@ functions:
code: |
```js
const { data: user, error } = await supabase.auth.admin.updateUserById(
- '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
+ '11111111-1111-1111-1111-111111111111',
{ email: '[email protected]' }
)
```
+ response: |
+ ```json
+ {
+ "data": {
+ "user": {
+ "id": "11111111-1111-1111-1111-111111111111",
+ "aud": "authenticated",
+ "role": "authenticated",
+ "email": "[email protected]",
+ "email_confirmed_at": "2024-01-01T00:00:00Z",
+ "phone": "",
+ "confirmed_at": "2024-01-01T00:00:00Z",
+ "recovery_sent_at": "2024-01-01T00:00:00Z",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "app_metadata": {
+ "provider": "email",
+ "providers": [
+ "email"
+ ]
+ },
+ "user_metadata": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "identities": [
+ {
+ "identity_id": "22222222-2222-2222-2222-222222222222",
+ "id": "11111111-1111-1111-1111-111111111111",
+ "user_id": "11111111-1111-1111-1111-111111111111",
+ "identity_data": {
+ "email": "[email protected]",
+ "email_verified": false,
+ "phone_verified": false,
+ "sub": "11111111-1111-1111-1111-111111111111"
+ },
+ "provider": "email",
+ "last_sign_in_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "email": "[email protected]"
+ }
+ ],
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "is_anonymous": false
+ }
+ },
+ "error": null
+ }
+ ```
- id: updates-a-users-password
name: Updates a user's password
isSpotlight: false
@@ -1558,6 +3123,24 @@ functions:
```js
const { data, error } = await supabase.auth.admin.mfa.listFactors()
```
+ response: |
+ ```json
+ {
+ data: {
+ factors: Factor[
+ {
+ id: '<ID>',
+ friendly_name: 'Auth App Factor',
+ factor_type: 'totp',
+ status: 'verified',
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z'
+ }
+ ]
+ },
+ error: null
+ }
+ ```
- id: mfa-delete-factor
title: 'mfa.deleteFactor()'
$ref: '@supabase/auth-js.GoTrueAdminMFAApi.deleteFactor'
@@ -1572,6 +3155,15 @@ functions:
userId: 'a89baba7-b1b7-440f-b4bb-91026967f66b',
})
```
+ response: |
+ ```json
+ {
+ data: {
+ id: '34e770dd-9ff9-416c-87fa-43b31d7ef225'
+ },
+ error: null
+ }
+ ```
- id: select
title: 'Fetch data: select()'
$ref: '@supabase/postgrest-js.PostgrestQueryBuilder.select'
@@ -3227,19 +4819,19 @@ functions:
(2, 'Albania'),
(3, 'Algeria');
```
- response: |
- ```json
- {
- "data": [
- {
- "id": 2,
- "name": "Albania"
- }
- ],
- "status": 200,
- "statusText": "OK"
- }
- ```
+ response: |
+ ```json
+ {
+ "data": [
+ {
+ "id": 2,
+ "name": "Albania"
+ }
+ ],
+ "status": 200,
+ "statusText": "OK"
+ }
+ ```
hideCodeBlock: true
isSpotlight: true
- id: is
@@ -3939,12 +5531,40 @@ functions:
name: Text search
code: |
```ts
- const { data, error } = await supabase
- .from('quotes')
- .select('catchphrase')
- .textSearch('catchphrase', `'fat' & 'cat'`, {
- config: 'english'
- })
+ const result = await supabase
+ .from("texts")
+ .select("content")
+ .textSearch("content", `'eggs' & 'ham'`, {
+ config: "english",
+ });
+ ```
+ data:
+ sql: |
+ ```sql
+ create table texts (
+ id bigint
+ primary key
+ generated always as identity,
+ content text
+ );
+
+ insert into texts (content) values
+ ('Four score and seven years ago'),
+ ('The road goes ever on and on'),
+ ('Green eggs and ham')
+ ;
+ ```
+ response: |
+ ```json
+ {
+ "data": [
+ {
+ "content": "Green eggs and ham"
+ }
+ ],
+ "status": 200,
+ "statusText": "OK"
+ }
```
- id: basic-normalization
name: Basic normalization