From e5dc0db5e6798096b155b46347a67444e4ce677e Mon Sep 17 00:00:00 2001 From: Jeremias Menichelli Date: Fri, 24 Apr 2026 19:02:02 +0200 Subject: [PATCH] chore: Define new structure to support other definitions --- apps/docs/app/reference/javascript/page.tsx | 8 +- apps/docs/scripts/generate-tsdoc-mdx.ts | 123 +- apps/docs/scripts/process-tsdoc.ts | 65 +- .../spec/enrichments/tsdoc_v2/config.json | 16 - .../spec/enrichments/tsdoc_v2/processed.json | 68278 ---------------- 5 files changed, 135 insertions(+), 68355 deletions(-) delete mode 100644 apps/docs/spec/enrichments/tsdoc_v2/config.json delete mode 100644 apps/docs/spec/enrichments/tsdoc_v2/processed.json diff --git a/apps/docs/app/reference/javascript/page.tsx b/apps/docs/app/reference/javascript/page.tsx index aa519665bfe..46d72906458 100644 --- a/apps/docs/app/reference/javascript/page.tsx +++ b/apps/docs/app/reference/javascript/page.tsx @@ -36,7 +36,7 @@ export type LibKey = keyof typeof libs */ async function getReferenceContent(library: string, version: string | undefined) { const libKey = getLibKey(library, version) - const filePath = join(REFERENCE_DIRECTORY, `${libKey}.mdx`) + const filePath = join(REFERENCE_DIRECTORY, libKey, 'index.mdx') const fileContent = await fs.readFile(filePath, 'utf-8') const { data: meta, content } = matter(fileContent) return { meta, content } as { content: string; meta: GuideFrontmatter } @@ -44,7 +44,7 @@ async function getReferenceContent(library: string, version: string | undefined) async function getReferenceSections(library: string, version: string | undefined) { const libKey = getLibKey(library, version) - const filePath = join(REFERENCE_DIRECTORY, `${libKey}.sections.json`) + const filePath = join(REFERENCE_DIRECTORY, libKey, 'sections.json') const fileContent = await fs.readFile(filePath, 'utf-8') return JSON.parse(fileContent) as AbbrevApiReferenceSection[] } @@ -79,7 +79,7 @@ async function ReferencePage() { const { library, version } = params const libKey = `${library}${version ? `-${version}` : ''}` as LibKey const { name, icon, currentVersion, isLatestVersion } = libs[libKey] - // const sections = await getReferenceSections(library, version) + const sections = await getReferenceSections(library, version) const { meta, content } = await getReferenceContent(library, version) return ( @@ -89,7 +89,7 @@ async function ReferencePage() { library={library} version={currentVersion} isLatestVersion={isLatestVersion} - sections={[]} + sections={sections} meta={meta} content={content} /> diff --git a/apps/docs/scripts/generate-tsdoc-mdx.ts b/apps/docs/scripts/generate-tsdoc-mdx.ts index d04dd3a5760..b8feb6e8b4c 100644 --- a/apps/docs/scripts/generate-tsdoc-mdx.ts +++ b/apps/docs/scripts/generate-tsdoc-mdx.ts @@ -1,17 +1,37 @@ -import { mkdirSync, readFileSync, writeFileSync } from 'fs' -import { join, dirname, resolve } from 'path' +import { mkdirSync, readdirSync, writeFileSync } from 'fs' +import { join, dirname, relative } from 'path' import { fileURLToPath } from 'url' -import { processSpec } from './process-tsdoc.js' +import { processSpec, type SpecCategory, type SpecConfig } from './process-tsdoc.js' const __dirname = dirname(fileURLToPath(import.meta.url)) -const CONFIG_PATH = join(__dirname, '../spec/enrichments/tsdoc_v2/config.json') -const config: { - title?: string - subtitle?: string - referenceLink?: string - referenceLinkLabel?: string -} = JSON.parse(readFileSync(CONFIG_PATH, 'utf-8')) +// --------------------------------------------------------------------------- +// Folder discovery +// --------------------------------------------------------------------------- + +/** + * Recursively finds all folders under `baseDir` that directly contain at least + * one .json file other than config.json. These are treated as spec source folders. + */ +function findSpecFolders(baseDir: string): string[] { + const result: string[] = [] + function walk(dir: string) { + const entries = readdirSync(dir, { withFileTypes: true }) + const hasSource = entries.some( + (e) => e.isFile() && e.name.endsWith('.json') && e.name !== 'config.json' + ) + if (hasSource) result.push(dir) + for (const e of entries) { + if (e.isDirectory()) walk(join(dir, e.name)) + } + } + walk(baseDir) + return result +} + +// --------------------------------------------------------------------------- +// Helpers +// --------------------------------------------------------------------------- function escapeMdxProse(text: string): string { // Escape { and } outside code blocks/spans so MDX doesn't treat them as JSX. @@ -25,6 +45,35 @@ function prop(value: unknown): string { return `{${JSON.stringify(value)}}` } +function toSlug(name: string): string { + return name + .toLowerCase() + .replace(/[^a-z0-9]+/g, '-') + .replace(/^-|-$/g, '') +} + +// --------------------------------------------------------------------------- +// Sections builder +// --------------------------------------------------------------------------- + +function buildSections(categories: SpecCategory[]): object[] { + return categories.map(({ category, definitions }) => ({ + id: toSlug(category), + type: 'category', + title: category, + items: definitions.map((def) => ({ + id: def.name, + type: 'function', + title: def.name, + slug: def.name, + })), + })) +} + +// --------------------------------------------------------------------------- +// MDX builder +// --------------------------------------------------------------------------- + let exampleCounter = 0 function generateExamplesBlock(examples: any[]): string[] { @@ -86,14 +135,16 @@ function generateExamplesBlock(examples: any[]): string[] { return lines } -function generateMdx(categories: ReturnType): string { +function generateMdx(categories: SpecCategory[], config: SpecConfig): string { const fmVal = (v: string) => `"${v.replace(/"/g, '\\"')}"` const frontmatter = [ '---', `title: ${fmVal(config.title ?? 'Reference')}`, ...(config.subtitle ? [`subtitle: ${fmVal(config.subtitle)}`] : []), ...(config.referenceLink ? [`referenceLink: ${fmVal(config.referenceLink)}`] : []), - ...(config.referenceLinkLabel ? [`referenceLinkLabel: ${fmVal(config.referenceLinkLabel)}`] : []), + ...(config.referenceLinkLabel + ? [`referenceLinkLabel: ${fmVal(config.referenceLinkLabel)}`] + : []), '---', '', '', @@ -145,13 +196,43 @@ function generateMdx(categories: ReturnType): string { return lines.join('\n') } -const processed = processSpec() -const mdx = generateMdx(processed) +// --------------------------------------------------------------------------- +// Main: discover and process all spec folders +// --------------------------------------------------------------------------- -const outPath = join(__dirname, '../content/reference/javascript.mdx') -mkdirSync(dirname(outPath), { recursive: true }) -writeFileSync(outPath, mdx) -console.log(`MDX written to ${outPath}`) -console.log( - `${processed.length} categories, ${processed.flatMap((c) => c.definitions).length} definitions` -) +const specRefDir = join(__dirname, '../spec/reference') +const contentRefDir = join(__dirname, '../content/reference') + +const specFolders = findSpecFolders(specRefDir) + +if (specFolders.length === 0) { + console.warn(`No spec folders found under ${specRefDir}`) + process.exit(0) +} + +for (const specDir of specFolders) { + exampleCounter = 0 // reset per spec so IDs don't bleed across files + + const { categories, config } = processSpec(specDir) + + // Mirror the folder path: spec/reference/ → content/reference/ + const rel = relative(specRefDir, specDir) + const outDir = join(contentRefDir, rel) + mkdirSync(outDir, { recursive: true }) + + // Write MDX + const mdx = generateMdx(categories, config) + const mdxPath = join(outDir, 'index.mdx') + writeFileSync(mdxPath, mdx) + + // Write sections + const sections = buildSections(categories) + const sectionsPath = join(outDir, 'sections.json') + writeFileSync(sectionsPath, JSON.stringify(sections, null, 2)) + + console.log(`[${rel}] MDX → ${mdxPath}`) + console.log(`[${rel}] sections → ${sectionsPath}`) + console.log( + `[${rel}] ${categories.length} categories, ${categories.flatMap((c) => c.definitions).length} definitions` + ) +} diff --git a/apps/docs/scripts/process-tsdoc.ts b/apps/docs/scripts/process-tsdoc.ts index d0a99279025..d2e2bfa0337 100644 --- a/apps/docs/scripts/process-tsdoc.ts +++ b/apps/docs/scripts/process-tsdoc.ts @@ -1,8 +1,5 @@ -import { readFileSync, writeFileSync } from 'fs' -import { join, dirname, resolve } from 'path' -import { fileURLToPath } from 'url' - -const __dirname = dirname(fileURLToPath(import.meta.url)) +import { readFileSync, readdirSync } from 'fs' +import { join } from 'path' type ContentItem = { kind: string; text: string } type BlockTag = { tag: string; name?: string; content?: ContentItem[] } @@ -167,6 +164,7 @@ function parseExamples(blockTags: BlockTag[]): any[] { const responseTag = findByName(responses, title) ?? responses[i] const descTag = findByName(descs, title) ?? descs[i] + // Use findLast so inline code spans (e.g. `select()`) before the fenced block are skipped const sqlBlock = sqlTag?.content?.findLast((c) => c.kind === 'code') const responseBlock = responseTag?.content?.findLast((c) => c.kind === 'code') const notes = descTag?.content @@ -205,29 +203,39 @@ function collectDeclarations(node: any): any[] { return out } -const SOURCE_FILES = [ - 'functions.json', - 'gotrue.json', - 'postgrest.json', - 'realtime.json', - 'storage.json', - 'supabase.json', -] +export interface SpecConfig { + title?: string + subtitle?: string + referenceLink?: string + referenceLinkLabel?: string + ignoreDefinitions?: string[] + categoryOrder?: string[] +} -export function processSpec() { - const specDir = join(__dirname, '../spec/enrichments/tsdoc_v2') +export interface SpecCategory { + category: string + definitions: any[] +} - const config: { ignoreDefinitions?: string[]; categoryOrder?: string[] } = (() => { +export function processSpec(specDir: string): { categories: SpecCategory[]; config: SpecConfig } { + // Load config (optional — missing config is fine) + const config: SpecConfig = (() => { try { return JSON.parse(readFileSync(join(specDir, 'config.json'), 'utf-8')) } catch { return {} } })() + const ignoredNames = new Set(config.ignoreDefinitions ?? []) const categoryOrder = config.categoryOrder ?? [] - const roots = SOURCE_FILES.map((f) => JSON.parse(readFileSync(join(specDir, f), 'utf-8'))) + // Discover all JSON source files in the spec folder, excluding config.json + const sourceFiles = readdirSync(specDir) + .filter((f) => f.endsWith('.json') && f !== 'config.json') + .map((f) => join(specDir, f)) + + const roots = sourceFiles.map((f) => JSON.parse(readFileSync(f, 'utf-8'))) // Build a per-file targetMap so IDs from different packages don't collide const fileMaps = roots.map((root) => buildTargetMap(root)) @@ -244,14 +252,14 @@ export function processSpec() { if (!categoryTag) continue // skip internal declarations with no category const category = (categoryTag.content?.[0]?.text ?? '').split('\n')[0].trim() + if (ignoredNames.has(decl.name)) continue + if (!categoryMap.has(category)) categoryMap.set(category, []) const sig = decl.signatures[0] const remarkTags = blockTags.filter((t) => t.tag === '@remarks') const examples = parseExamples(blockTags) - if (ignoredNames.has(decl.name)) continue - const definition: any = { name: decl.name, description: contentToMd(decl.comment?.summary ?? []), @@ -266,7 +274,7 @@ export function processSpec() { categoryMap.get(category)!.push(definition) } - const result = Array.from(categoryMap.entries()) + const categories = Array.from(categoryMap.entries()) .map(([category, definitions]) => ({ category, definitions })) .sort((a, b) => { const ai = categoryOrder.indexOf(a.category) @@ -281,20 +289,5 @@ export function processSpec() { return 0 }) - console.log(result) - - return result -} - -// Only write to disk when run directly -const isMain = fileURLToPath(import.meta.url) === resolve(process.argv[1]) -if (isMain) { - const output = processSpec() - writeFileSync( - join(__dirname, '../spec/enrichments/tsdoc_v2/processed.json'), - JSON.stringify(output, null, 2) - ) - console.log( - `Done: ${output.length} categories, ${output.flatMap((c) => c.definitions).length} declarations` - ) + return { categories, config } } diff --git a/apps/docs/spec/enrichments/tsdoc_v2/config.json b/apps/docs/spec/enrichments/tsdoc_v2/config.json deleted file mode 100644 index 34432a95a5c..00000000000 --- a/apps/docs/spec/enrichments/tsdoc_v2/config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "title":"JavaScript Client library", -"subtitle": "Use the `supabase-js` package to interact with your Postgres database, listen to database changes, invoke Deno Edge Functions, build login and user management functionality, and manage large files.", -"referenceLink": "https://github.com/supabase/supabase-js", -"referenceLinkLabel": "@supabase/supabase-js", - "versions": [ - "v1", - "v2" - ], - "isLatestVersion": true, - "version": "v2", - "ignoreDefinitions": [ - "constructor" - ], - "categoryOrder": [ "Initializing", "Database", "Auth", "Functions", "Realtime", "Storage" ] -} \ No newline at end of file diff --git a/apps/docs/spec/enrichments/tsdoc_v2/processed.json b/apps/docs/spec/enrichments/tsdoc_v2/processed.json deleted file mode 100644 index af8f1b0eb53..00000000000 --- a/apps/docs/spec/enrichments/tsdoc_v2/processed.json +++ /dev/null @@ -1,68278 +0,0 @@ -[ - { - "category": "Database", - "definitions": [ - { - "name": "overrideTypes", - "description": "Override the type of the returned `data` field in the response.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Example 1", - "code": "// Merge with existing types (default behavior)\nconst query = supabase\n .from('users')\n .select()\n .overrideTypes<{ custom_field: string }>()\n\n// Replace existing types completely\nconst replaceQuery = supabase\n .from('users')\n .select()\n .overrideTypes<{ id: number; name: string }, { merge: false }>()", - "response": "let x: typeof data // MyType[]" - }, - { - "title": "Complete Override type of successful response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .overrideTypes, { merge: false }>()", - "response": "let x: typeof data // MyType[]" - }, - { - "title": "Complete Override type of object response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .maybeSingle()\n .overrideTypes()", - "response": "let x: typeof data // MyType | null" - }, - { - "title": "Partial Override type of successful response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .overrideTypes>()", - "response": "let x: typeof data // Array" - }, - { - "title": "Partial Override type of object response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .maybeSingle()\n .overrideTypes<{ status: \"A\" | \"B\" }>()", - "response": "let x: typeof data // CountryRowProperties & { status: \"A\" | \"B\" } | null" - }, - { - "title": "Example 5", - "code": "// Merge with existing types (default behavior)\nconst query = supabase\n .from('users')\n .select()\n .overrideTypes<{ custom_field: string }>()\n\n// Replace existing types completely\nconst replaceQuery = supabase\n .from('users')\n .select()\n .overrideTypes<{ id: number; name: string }, { merge: false }>()" - } - ] - }, - { - "name": "returns", - "description": "Override the type of the returned `data`.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "setHeader", - "description": "Set an HTTP header for the request.", - "parameters": [ - { - "name": "name", - "type": "string" - }, - { - "name": "value", - "type": "string" - } - ], - "returnType": "this" - }, - { - "name": "then", - "description": "", - "parameters": [ - { - "name": "onfulfilled", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "onrejected", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "PromiseLike", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "typeParam", - "name": "TResult1" - }, - { - "kind": "typeParam", - "name": "TResult2" - } - ] - } - ] - } - }, - { - "name": "throwOnError", - "description": "If there's an error with the query, throwOnError will reject the promise by throwing the error instead of returning it as part of a successful response.\nhttps://github.com/supabase/supabase-js/issues/92", - "parameters": [], - "returnType": { - "kind": "intersection", - "types": [ - { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - } - ] - } - }, - { - "name": "from", - "description": "Perform a query on a table or a view.", - "parameters": [ - { - "name": "relation", - "type": { - "kind": "typeParam", - "name": "TableName" - } - } - ], - "returnType": { - "kind": "object", - "name": "PostgrestQueryBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "fetch", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "delete", - "optional": false, - "type": null - }, - { - "name": "insert", - "optional": false, - "description": "Perform an INSERT into the table or view.\nBy default, inserted rows are not returned. To return it, chain the call with `.select()`.", - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "update", - "optional": false, - "type": null - }, - { - "name": "upsert", - "optional": false, - "description": "Perform an UPSERT on the table or view. Depending on the column(s) passed to `onConflict`, `.upsert()` allows you to perform the equivalent of `.insert()` if a row with the corresponding `onConflict` columns doesn't exist, or if it does exist, perform an alternative action depending on `ignoreDuplicates`.\nBy default, upserted rows are not returned. To return it, chain the call with `.select()`.", - "type": null - } - ] - } - }, - { - "name": "rpc", - "description": "Perform a function call.", - "parameters": [ - { - "name": "fn", - "description": "The function name to call", - "type": { - "kind": "typeParam", - "name": "FnName" - } - }, - { - "name": "args", - "description": "The arguments to pass to the function call", - "type": { - "kind": "typeParam", - "name": "Args" - } - }, - { - "name": "options", - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "count", - "optional": true, - "description": "Count algorithm to use to count rows returned by the function. Only applicable for [set-returning functions](https://www.postgresql.org/docs/current/functions-srf.html).\n`\"exact\"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the hood.\n`\"planned\"`: Approximated but fast count algorithm. Uses the Postgres statistics under the hood.\n`\"estimated\"`: Uses exact count for low numbers and planned count for high numbers.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "exact" - }, - { - "kind": "literal", - "value": "planned" - }, - { - "kind": "literal", - "value": "estimated" - } - ] - } - }, - { - "name": "get", - "optional": true, - "description": "When set to `true`, the function will be called with read-only access mode.", - "type": "boolean" - }, - { - "name": "head", - "optional": true, - "description": "When set to `true`, `data` will not be returned. Useful if you only need the count.", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "object", - "name": "PostgrestFilterBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "containedBy", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in `column` is contained by `value`.", - "type": null - }, - { - "name": "contains", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where `column` contains every element appearing in `value`.", - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "eq", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "filter", - "optional": false, - "description": "Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "gt", - "optional": false, - "description": "Match only rows where `column` is greater than `value`.", - "type": null - }, - { - "name": "gte", - "optional": false, - "description": "Match only rows where `column` is greater than or equal to `value`.", - "type": null - }, - { - "name": "ilike", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-insensitively.", - "type": null - }, - { - "name": "ilikeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-insensitively.", - "type": null - }, - { - "name": "ilikeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-insensitively.", - "type": null - }, - { - "name": "in", - "optional": false, - "type": null - }, - { - "name": "is", - "optional": false, - "description": "Match only rows where `column` IS `value`.\nFor non-boolean columns, this is only relevant for checking if the value of `column` is NULL by setting `value` to `null`.\nFor boolean columns, you can also set `value` to `true` or `false` and it will behave the same way as `.eq()`.", - "type": null - }, - { - "name": "isDistinct", - "optional": false, - "type": null - }, - { - "name": "like", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-sensitively.", - "type": null - }, - { - "name": "likeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-sensitively.", - "type": null - }, - { - "name": "likeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-sensitively.", - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "lt", - "optional": false, - "description": "Match only rows where `column` is less than `value`.", - "type": null - }, - { - "name": "lte", - "optional": false, - "description": "Match only rows where `column` is less than or equal to `value`.", - "type": null - }, - { - "name": "match", - "optional": false, - "description": "Match only rows where each column in `query` keys is equal to its associated value. Shorthand for multiple `.eq()`s.", - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "neq", - "optional": false, - "type": null - }, - { - "name": "not", - "optional": false, - "description": "Match only rows which doesn't satisfy the filter.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "notIn", - "optional": false, - "type": null - }, - { - "name": "or", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overlaps", - "optional": false, - "description": "Only relevant for array and range columns. Match only rows where `column` and `value` have an element in common.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "rangeAdjacent", - "optional": false, - "description": "Only relevant for range columns. Match only rows where `column` is mutually exclusive to `range` and there can be no element between the two ranges.", - "type": null - }, - { - "name": "rangeGt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is greater than any element in `range`.", - "type": null - }, - { - "name": "rangeGte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or greater than any element in `range`.", - "type": null - }, - { - "name": "rangeLt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is less than any element in `range`.", - "type": null - }, - { - "name": "rangeLte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or less than any element in `range`.", - "type": null - }, - { - "name": "regexIMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-insensitively (using the `~*` operator).", - "type": null - }, - { - "name": "regexMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-sensitively (using the `~` operator).", - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "textSearch", - "optional": false, - "description": "Only relevant for text and tsvector columns. Match only rows where `column` matches the query string in `query`.", - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Example 1", - "code": "// For cross-schema functions where type inference fails, use overrideTypes:\nconst { data } = await supabase\n .schema('schema_b')\n .rpc('function_a', {})\n .overrideTypes<{ id: string; user_id: string }[]>()", - "sql": "create function hello_world() returns text as $$\n select 'Hello world';\n$$ language sql;", - "response": "{\n \"data\": \"Hello world\",\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Bulk processing\nYou can process large payloads by passing in an array as an argument." - }, - { - "title": "Call a Postgres function without arguments", - "code": "const { data, error } = await supabase.rpc('hello_world')", - "sql": "create function hello_world() returns text as $$\n select 'Hello world';\n$$ language sql;", - "response": "{\n \"data\": \"Hello world\",\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Call a Postgres function with filters\nPostgres functions that return tables can also be combined with [Filters](/docs/reference/javascript/using-filters) and [Modifiers](/docs/reference/javascript/using-modifiers)." - }, - { - "title": "Call a Postgres function with arguments", - "code": "const { data, error } = await supabase.rpc('echo', { say: '👋' })", - "sql": "create function echo(say text) returns text as $$\n select say;\n$$ language sql;", - "response": "{\n \"data\": \"👋\",\n \"status\": 200,\n \"statusText\": \"OK\"\n }" - }, - { - "title": "Bulk processing", - "code": "const { data, error } = await supabase.rpc('add_one_each', { arr: [1, 2, 3] })", - "sql": "create function add_one_each(arr int[]) returns int[] as $$\n select array_agg(n + 1) from unnest(arr) as n;\n$$ language sql;", - "response": "{\n \"data\": [\n 2,\n 3,\n 4\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "You can process large payloads by passing in an array as an argument." - }, - { - "title": "Call a Postgres function with filters", - "code": "const { data, error } = await supabase\n .rpc('list_stored_countries')\n .eq('id', 1)\n .single()", - "sql": "create table\n countries (id int8 primary key, name text);\n\ninsert into\n countries (id, name)\nvalues\n (1, 'Rohan'),\n (2, 'The Shire');\n\ncreate function list_stored_countries() returns setof countries as $$\n select * from countries;\n$$ language sql;", - "response": "{\n \"data\": {\n \"id\": 1,\n \"name\": \"Rohan\"\n },\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Postgres functions that return tables can also be combined with [Filters](/docs/reference/javascript/using-filters) and [Modifiers](/docs/reference/javascript/using-modifiers)." - }, - { - "title": "Call a read-only Postgres function", - "code": "const { data, error } = await supabase.rpc('hello_world', undefined, { get: true })", - "sql": "create function hello_world() returns text as $$\n select 'Hello world';\n$$ language sql;", - "response": "{\n \"data\": \"Hello world\",\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "schema", - "description": "Select a schema to query or perform an function (rpc) call.\nThe schema needs to be on the list of exposed schemas inside Supabase.", - "parameters": [ - { - "name": "schema", - "description": "The schema to query", - "type": { - "kind": "typeParam", - "name": "DynamicSchema" - } - } - ], - "returnType": { - "kind": "object", - "name": "PostgrestClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "fetch", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "schemaName", - "optional": true, - "type": { - "kind": "typeParam", - "name": "SchemaName" - } - }, - { - "name": "url", - "optional": false, - "type": "string" - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "from", - "optional": false, - "description": "Perform a query on a table or a view.", - "type": null - }, - { - "name": "rpc", - "optional": false, - "type": null - }, - { - "name": "schema", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "abortSignal", - "description": "Set the AbortSignal for the fetch request.", - "remarks": [ - "You can use this to set a timeout for the request." - ], - "parameters": [ - { - "name": "signal", - "description": "The AbortSignal to use for the fetch request", - "type": { - "kind": "reference", - "name": "AbortSignal" - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "Aborting requests in-flight", - "code": "const ac = new AbortController()\n\nconst { data, error } = await supabase\n .from('very_big_table')\n .select()\n .abortSignal(ac.signal)\n\n// Abort the request after 100 ms\nsetTimeout(() => ac.abort(), 100)", - "response": "{\n \"error\": {\n \"message\": \"AbortError: The user aborted a request.\",\n \"details\": \"\",\n \"hint\": \"The request was aborted locally via the provided AbortSignal.\",\n \"code\": \"\"\n },\n \"status\": 0,\n \"statusText\": \"\"\n }", - "notes": "You can use an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to abort requests.\nNote that `status` and `statusText` don't mean anything for aborted requests as the request wasn't fulfilled." - }, - { - "title": "Set a timeout", - "code": "const { data, error } = await supabase\n .from('very_big_table')\n .select()\n .abortSignal(AbortSignal.timeout(1000 /* ms */))", - "response": "{\n \"error\": {\n \"message\": \"FetchError: The user aborted a request.\",\n \"details\": \"\",\n \"hint\": \"\",\n \"code\": \"\"\n },\n \"status\": 400,\n \"statusText\": \"Bad Request\"\n }" - } - ] - }, - { - "name": "containedBy", - "description": "Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in `column` is contained by `value`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "value", - "type": { - "kind": "union", - "types": [ - "string", - { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "unknown" - ] - }, - { - "kind": "typeOperator" - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "On array columns", - "code": "const { data, error } = await supabase\n .from('classes')\n .select('name')\n .containedBy('days', ['monday', 'tuesday', 'wednesday', 'friday'])", - "sql": "create table\n classes (\n id int8 primary key,\n name text,\n days text[]\n );\n\ninsert into\n classes (id, name, days)\nvalues\n (1, 'Chemistry', array['monday', 'friday']),\n (2, 'History', array['monday', 'wednesday', 'thursday']);", - "response": "{\n \"data\": [\n {\n \"name\": \"Chemistry\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "On range columns\nPostgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - }, - { - "title": "On range columns", - "code": "const { data, error } = await supabase\n .from('reservations')\n .select()\n .containedBy('during', '[2000-01-01 00:00, 2000-01-01 23:59)')", - "sql": "create table\n reservations (\n id int8 primary key,\n room_name text,\n during tsrange\n );\n\ninsert into\n reservations (id, room_name, during)\nvalues\n (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),\n (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"room_name\": \"Emerald\",\n \"during\": \"[\\\"2000-01-01 13:00:00\\\",\\\"2000-01-01 15:00:00\\\")\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Postgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - }, - { - "title": "On `jsonb` columns", - "code": "const { data, error } = await supabase\n .from('users')\n .select('name')\n .containedBy('address', {})", - "sql": "create table\n users (\n id int8 primary key,\n name text,\n address jsonb\n );\n\ninsert into\n users (id, name, address)\nvalues\n (1, 'Michael', '{ \"postcode\": 90210, \"street\": \"Melrose Place\" }'),\n (2, 'Jane', '{}');", - "response": "{\n \"data\": [\n {\n \"name\": \"Jane\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n }" - } - ] - }, - { - "name": "contains", - "description": "Only relevant for jsonb, array, and range columns. Match only rows where `column` contains every element appearing in `value`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "value", - "type": { - "kind": "union", - "types": [ - "string", - { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "unknown" - ] - }, - { - "kind": "typeOperator" - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "On array columns", - "code": "const { data, error } = await supabase\n .from('issues')\n .select()\n .contains('tags', ['is:open', 'priority:low'])", - "sql": "create table\n issues (\n id int8 primary key,\n title text,\n tags text[]\n );\n\ninsert into\n issues (id, title, tags)\nvalues\n (1, 'Cache invalidation is not working', array['is:open', 'severity:high', 'priority:low']),\n (2, 'Use better names', array['is:open', 'severity:low', 'priority:medium']);", - "response": "{\n \"data\": [\n {\n \"title\": \"Cache invalidation is not working\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "On range columns\nPostgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - }, - { - "title": "On range columns", - "code": "const { data, error } = await supabase\n .from('reservations')\n .select()\n .contains('during', '[2000-01-01 13:00, 2000-01-01 13:30)')", - "sql": "create table\n reservations (\n id int8 primary key,\n room_name text,\n during tsrange\n );\n\ninsert into\n reservations (id, room_name, during)\nvalues\n (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),\n (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"room_name\": \"Emerald\",\n \"during\": \"[\\\"2000-01-01 13:00:00\\\",\\\"2000-01-01 15:00:00\\\")\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Postgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - }, - { - "title": "On `jsonb` columns", - "code": "const { data, error } = await supabase\n .from('users')\n .select('name')\n .contains('address', { postcode: 90210 })", - "sql": "create table\n users (\n id int8 primary key,\n name text,\n address jsonb\n );\n\ninsert into\n users (id, name, address)\nvalues\n (1, 'Michael', '{ \"postcode\": 90210, \"street\": \"Melrose Place\" }'),\n (2, 'Jane', '{}');", - "response": "{\n \"data\": [\n {\n \"name\": \"Michael\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "csv", - "description": "Return `data` as a string in CSV format.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Return data as CSV", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .csv()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": \"id,name\\n1,Luke\\n2,Leia\\n3,Han\",\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "By default, the data is returned in JSON format, but can also be returned as Comma Separated Values." - } - ] - }, - { - "name": "eq", - "description": "Match only rows where `column` is equal to `value`.\nTo check if the value of `column` is NULL, you should use `.is()` instead.", - "parameters": [ - { - "name": "column", - "description": "The column to filter on", - "type": { - "kind": "conditional" - } - }, - { - "name": "value", - "description": "The value to filter with", - "type": { - "kind": "conditional" - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .eq('name', 'Leia')", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 2,\n \"name\": \"Leia\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "explain", - "description": "Return `data` as the EXPLAIN plan for the query.\nYou need to enable the [db_plan_enabled](https://supabase.com/docs/guides/database/debugging-performance#enabling-explain) setting before using this method.", - "parameters": [ - { - "name": "options", - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "analyze", - "optional": true, - "description": "If `true`, the query will be executed and the actual run time will be returned", - "type": "boolean" - }, - { - "name": "buffers", - "optional": true, - "description": "If `true`, include information on buffer usage", - "type": "boolean" - }, - { - "name": "format", - "optional": true, - "description": "The format of the output, can be `\"text\"` (default) or `\"json\"`", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "text" - }, - { - "kind": "literal", - "value": "json" - } - ] - } - }, - { - "name": "settings", - "optional": true, - "description": "If `true`, include information on configuration parameters that affect query planning", - "type": "boolean" - }, - { - "name": "verbose", - "optional": true, - "description": "If `true`, the query identifier will be returned and `data` will include the output columns of the query", - "type": "boolean" - }, - { - "name": "wal", - "optional": true, - "description": "If `true`, include information on WAL record generation", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - } - ] - }, - "examples": [ - { - "title": "Get the execution plan", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .explain()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "Aggregate (cost=33.34..33.36 rows=1 width=112)\n -> Limit (cost=0.00..18.33 rows=1000 width=40)\n -> Seq Scan on characters (cost=0.00..22.00 rows=1200 width=40)", - "notes": "By default, the data is returned in TEXT format, but can also be returned as JSON by using the `format` parameter." - }, - { - "title": "Get the execution plan with analyze and verbose", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .explain({analyze:true,verbose:true})", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "Aggregate (cost=33.34..33.36 rows=1 width=112) (actual time=0.041..0.041 rows=1 loops=1)\n Output: NULL::bigint, count(ROW(characters.id, characters.name)), COALESCE(json_agg(ROW(characters.id, characters.name)), '[]'::json), NULLIF(current_setting('response.headers'::text, true), ''::text), NULLIF(current_setting('response.status'::text, true), ''::text)\n -> Limit (cost=0.00..18.33 rows=1000 width=40) (actual time=0.005..0.006 rows=3 loops=1)\n Output: characters.id, characters.name\n -> Seq Scan on public.characters (cost=0.00..22.00 rows=1200 width=40) (actual time=0.004..0.005 rows=3 loops=1)\n Output: characters.id, characters.name\nQuery Identifier: -4730654291623321173\nPlanning Time: 0.407 ms\nExecution Time: 0.119 ms", - "notes": "By default, the data is returned in TEXT format, but can also be returned as JSON by using the `format` parameter." - } - ] - }, - { - "name": "filter", - "description": "Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "remarks": [ - "filter() expects you to use the raw PostgREST syntax for the filter values.\n```ts .filter('id', 'in', '(5,6,7)') // Use `()` for `in` filter .filter('arraycol', 'cs', '{\"a\",\"b\"}') // Use `cs` for `contains()`, `{}` for array values ```" - ], - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "operator", - "type": { - "kind": "union", - "types": [ - { - "kind": "reference", - "name": "FilterOperator" - }, - { - "kind": "literal", - "value": "not.match" - }, - { - "kind": "literal", - "value": "not.eq" - }, - { - "kind": "literal", - "value": "not.neq" - }, - { - "kind": "literal", - "value": "not.gt" - }, - { - "kind": "literal", - "value": "not.gte" - }, - { - "kind": "literal", - "value": "not.lt" - }, - { - "kind": "literal", - "value": "not.lte" - }, - { - "kind": "literal", - "value": "not.like" - }, - { - "kind": "literal", - "value": "not.ilike" - }, - { - "kind": "literal", - "value": "not.is" - }, - { - "kind": "literal", - "value": "not.isdistinct" - }, - { - "kind": "literal", - "value": "not.in" - }, - { - "kind": "literal", - "value": "not.cs" - }, - { - "kind": "literal", - "value": "not.cd" - }, - { - "kind": "literal", - "value": "not.sl" - }, - { - "kind": "literal", - "value": "not.sr" - }, - { - "kind": "literal", - "value": "not.nxl" - }, - { - "kind": "literal", - "value": "not.nxr" - }, - { - "kind": "literal", - "value": "not.adj" - }, - { - "kind": "literal", - "value": "not.ov" - }, - { - "kind": "literal", - "value": "not.fts" - }, - { - "kind": "literal", - "value": "not.plfts" - }, - { - "kind": "literal", - "value": "not.phfts" - }, - { - "kind": "literal", - "value": "not.wfts" - }, - { - "kind": "literal", - "value": "not.imatch" - } - ] - } - }, - { - "name": "value", - "type": "unknown" - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .filter('name', 'in', '(\"Han\",\"Yoda\")')", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 3,\n \"name\": \"Han\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - }, - { - "title": "On a referenced table", - "code": "const { data, error } = await supabase\n .from('orchestral_sections')\n .select(`\n name,\n instruments!inner (\n name\n )\n `)\n .filter('instruments.name', 'eq', 'flute')", - "sql": "create table\n orchestral_sections (id int8 primary key, name text);\ncreate table\n instruments (\n id int8 primary key,\n section_id int8 not null references orchestral_sections,\n name text\n );\n\ninsert into\n orchestral_sections (id, name)\nvalues\n (1, 'strings'),\n (2, 'woodwinds');\ninsert into\n instruments (id, section_id, name)\nvalues\n (1, 2, 'flute'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"woodwinds\",\n \"instruments\": [\n {\n \"name\": \"flute\"\n }\n ]\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "geojson", - "description": "Return `data` as an object in [GeoJSON](https://geojson.org) format.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "gt", - "description": "Match only rows where `column` is greater than `value`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "value", - "type": { - "kind": "indexedAccess", - "objectType": { - "kind": "typeParam", - "name": "Row" - }, - "indexType": null - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .gt('id', 2)", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 3,\n \"name\": \"Han\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "With `select()`\nWhen using [reserved words](https://www.postgresql.org/docs/current/sql-keywords-appendix.html) for column names you need\nto add double quotes e.g. `.gt('\"order\"', 2)`" - } - ] - }, - { - "name": "gte", - "description": "Match only rows where `column` is greater than or equal to `value`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "value", - "type": { - "kind": "indexedAccess", - "objectType": { - "kind": "typeParam", - "name": "Row" - }, - "indexType": null - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .gte('id', 2)", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 2,\n \"name\": \"Leia\"\n },\n {\n \"id\": 3,\n \"name\": \"Han\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "ilike", - "description": "Match only rows where `column` matches `pattern` case-insensitively.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "pattern", - "type": "string" - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .ilike('name', '%lu%')", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Luke\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "ilikeAllOf", - "description": "Match only rows where `column` matches all of `patterns` case-insensitively.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "patterns", - "type": { - "kind": "typeOperator" - } - } - ], - "returnType": "this" - }, - { - "name": "ilikeAnyOf", - "description": "Match only rows where `column` matches any of `patterns` case-insensitively.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "patterns", - "type": { - "kind": "typeOperator" - } - } - ], - "returnType": "this" - }, - { - "name": "in", - "description": "Match only rows where `column` is included in the `values` array.", - "parameters": [ - { - "name": "column", - "description": "The column to filter on", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "values", - "description": "The values array to filter with", - "type": { - "kind": "typeOperator" - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .in('name', ['Leia', 'Han'])", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 2,\n \"name\": \"Leia\"\n },\n {\n \"id\": 3,\n \"name\": \"Han\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "is", - "description": "Match only rows where `column` IS `value`.\nFor non-boolean columns, this is only relevant for checking if the value of `column` is NULL by setting `value` to `null`.\nFor boolean columns, you can also set `value` to `true` or `false` and it will behave the same way as `.eq()`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "value", - "type": { - "kind": "intersection", - "types": [ - { - "kind": "indexedAccess", - "objectType": { - "kind": "typeParam", - "name": "Row" - }, - "indexType": null - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "boolean" - ] - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "Checking for nullness, true or false", - "code": "const { data, error } = await supabase\n .from('countries')\n .select()\n .is('name', null)", - "sql": "create table\n countries (id int8 primary key, name text);\n\ninsert into\n countries (id, name)\nvalues\n (1, 'null'),\n (2, null);", - "response": "{\n \"data\": [\n {\n \"id\": 2,\n \"name\": \"null\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Using the `eq()` filter doesn't work when filtering for `null`.\n\nInstead, you need to use `is()`." - } - ] - }, - { - "name": "like", - "description": "Match only rows where `column` matches `pattern` case-sensitively.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "pattern", - "type": "string" - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .like('name', '%Lu%')", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Luke\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "likeAllOf", - "description": "Match only rows where `column` matches all of `patterns` case-sensitively.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "patterns", - "type": { - "kind": "typeOperator" - } - } - ], - "returnType": "this" - }, - { - "name": "likeAnyOf", - "description": "Match only rows where `column` matches any of `patterns` case-sensitively.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "patterns", - "type": { - "kind": "typeOperator" - } - } - ], - "returnType": "this" - }, - { - "name": "limit", - "description": "Limit the query result by `count`.", - "parameters": [ - { - "name": "count", - "description": "The maximum number of rows to return", - "type": "number" - }, - { - "name": "options", - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "foreignTable", - "optional": true, - "description": "Deprecated, use `options.referencedTable` instead", - "type": "string" - }, - { - "name": "referencedTable", - "optional": true, - "description": "Set this to limit rows of referenced tables instead of the parent table", - "type": "string" - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('name')\n .limit(1)", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"name\": \"Luke\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - }, - { - "title": "On a referenced table", - "code": "const { data, error } = await supabase\n .from('orchestral_sections')\n .select(`\n name,\n instruments (\n name\n )\n `)\n .limit(1, { referencedTable: 'instruments' })", - "sql": "create table\n orchestral_sections (id int8 primary key, name text);\ncreate table\n instruments (\n id int8 primary key,\n section_id int8 not null references orchestral_sections,\n name text\n );\n\ninsert into\n orchestral_sections (id, name)\nvalues\n (1, 'strings');\ninsert into\n instruments (id, section_id, name)\nvalues\n (1, 1, 'harp'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"strings\",\n \"instruments\": [\n {\n \"name\": \"violin\"\n }\n ]\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "lt", - "description": "Match only rows where `column` is less than `value`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "value", - "type": { - "kind": "indexedAccess", - "objectType": { - "kind": "typeParam", - "name": "Row" - }, - "indexType": null - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .lt('id', 2)", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Luke\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "lte", - "description": "Match only rows where `column` is less than or equal to `value`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "value", - "type": { - "kind": "indexedAccess", - "objectType": { - "kind": "typeParam", - "name": "Row" - }, - "indexType": null - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .lte('id', 2)", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Luke\"\n },\n {\n \"id\": 2,\n \"name\": \"Leia\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "match", - "description": "Match only rows where each column in `query` keys is equal to its associated value. Shorthand for multiple `.eq()`s.", - "parameters": [ - { - "name": "query", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - { - "kind": "typeParam", - "name": "ColumnName" - }, - { - "kind": "indexedAccess", - "objectType": { - "kind": "typeParam", - "name": "Row" - }, - "indexType": null - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('name')\n .match({ id: 2, name: 'Leia' })", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"name\": \"Leia\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "maxAffected", - "description": "Set the maximum number of rows that can be affected by the query. Only available in PostgREST v13+ and only works with PATCH and DELETE methods.", - "parameters": [ - { - "name": "value", - "description": "The maximum number of rows that can be affected", - "type": "number" - } - ], - "returnType": { - "kind": "conditional" - } - }, - { - "name": "maybeSingle", - "description": "Return `data` as a single object instead of an array of objects.\nQuery result must be zero or one row (e.g. using `.limit(1)`), otherwise this returns an error.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .eq('name', 'Katniss')\n .maybeSingle()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "neq", - "description": "Match only rows where `column` is not equal to `value`.", - "parameters": [ - { - "name": "column", - "description": "The column to filter on", - "type": { - "kind": "conditional" - } - }, - { - "name": "value", - "description": "The value to filter with", - "type": { - "kind": "conditional" - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .neq('name', 'Leia')", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Luke\"\n },\n {\n \"id\": 3,\n \"name\": \"Han\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "not", - "description": "Match only rows which doesn't satisfy the filter.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "remarks": [ - "not() expects you to use the raw PostgREST syntax for the filter values.\n```ts .not('id', 'in', '(5,6,7)') // Use `()` for `in` filter .not('arraycol', 'cs', '{\"a\",\"b\"}') // Use `cs` for `contains()`, `{}` for array values ```" - ], - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "operator", - "type": { - "kind": "reference", - "name": "FilterOperator" - } - }, - { - "name": "value", - "type": { - "kind": "indexedAccess", - "objectType": { - "kind": "typeParam", - "name": "Row" - }, - "indexType": null - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('countries')\n .select()\n .not('name', 'is', null)", - "sql": "create table\n countries (id int8 primary key, name text);\n\ninsert into\n countries (id, name)\nvalues\n (1, 'null'),\n (2, null);", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"null\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n }" - } - ] - }, - { - "name": "or", - "description": "Match only rows which satisfy at least one of the filters.\nUnlike most filters, `filters` is used as-is and needs to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure it's properly sanitized.\nIt's currently not possible to do an `.or()` filter across multiple tables.", - "remarks": [ - "or() expects you to use the raw PostgREST syntax for the filter names and values.\n```ts .or('id.in.(5,6,7), arraycol.cs.{\"a\",\"b\"}') // Use `()` for `in` filter, `{}` for array values and `cs` for `contains()`. .or('id.in.(5,6,7), arraycol.cd.{\"a\",\"b\"}') // Use `cd` for `containedBy()` ```" - ], - "parameters": [ - { - "name": "filters", - "description": "The filters to use, following PostgREST syntax", - "type": "string" - }, - { - "name": "options", - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "foreignTable", - "optional": true, - "description": "Deprecated, use `referencedTable` instead", - "type": "string" - }, - { - "name": "referencedTable", - "optional": true, - "description": "Set this to filter on referenced tables instead of the parent table", - "type": "string" - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('name')\n .or('id.eq.2,name.eq.Han')", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"name\": \"Leia\"\n },\n {\n \"name\": \"Han\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - }, - { - "title": "Use `or` with `and`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('name')\n .or('id.gt.3,and(id.eq.1,name.eq.Luke)')", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"name\": \"Luke\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - }, - { - "title": "Use `or` on referenced tables", - "code": "const { data, error } = await supabase\n .from('orchestral_sections')\n .select(`\n name,\n instruments!inner (\n name\n )\n `)\n .or('section_id.eq.1,name.eq.guzheng', { referencedTable: 'instruments' })", - "sql": "create table\n orchestral_sections (id int8 primary key, name text);\ncreate table\n instruments (\n id int8 primary key,\n section_id int8 not null references orchestral_sections,\n name text\n );\n\ninsert into\n orchestral_sections (id, name)\nvalues\n (1, 'strings'),\n (2, 'woodwinds');\ninsert into\n instruments (id, section_id, name)\nvalues\n (1, 2, 'flute'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"strings\",\n \"instruments\": [\n {\n \"name\": \"violin\"\n }\n ]\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "order", - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "ascending", - "optional": true, - "type": "boolean" - }, - { - "name": "nullsFirst", - "optional": true, - "type": "boolean" - }, - { - "name": "referencedTable", - "optional": true, - "type": "undefined" - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('id, name')\n .order('id', { ascending: false })", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 3,\n \"name\": \"Han\"\n },\n {\n \"id\": 2,\n \"name\": \"Leia\"\n },\n {\n \"id\": 1,\n \"name\": \"Luke\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "On a referenced table\nOrdering with `referencedTable` doesn't affect the ordering of the\nparent table." - }, - { - "title": "On a referenced table", - "code": "const { data, error } = await supabase\n .from('orchestral_sections')\n .select(`\n name,\n instruments (\n name\n )\n `)\n .order('name', { referencedTable: 'instruments', ascending: false })", - "sql": "create table\n orchestral_sections (id int8 primary key, name text);\ncreate table\n instruments (\n id int8 primary key,\n section_id int8 not null references orchestral_sections,\n name text\n );\n\ninsert into\n orchestral_sections (id, name)\nvalues\n (1, 'strings'),\n (2, 'woodwinds');\ninsert into\n instruments (id, section_id, name)\nvalues\n (1, 1, 'harp'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"strings\",\n \"instruments\": [\n {\n \"name\": \"violin\"\n },\n {\n \"name\": \"harp\"\n }\n ]\n },\n {\n \"name\": \"woodwinds\",\n \"instruments\": []\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Ordering with `referencedTable` doesn't affect the ordering of the\nparent table." - }, - { - "title": "Order parent table by a referenced table", - "code": "const { data, error } = await supabase\n .from('instruments')\n .select(`\n name,\n section:orchestral_sections (\n name\n )\n `)\n .order('section(name)', { ascending: true })", - "sql": "create table\n orchestral_sections (id int8 primary key, name text);\ncreate table\n instruments (\n id int8 primary key,\n section_id int8 not null references orchestral_sections,\n name text\n );\n\ninsert into\n orchestral_sections (id, name)\nvalues\n (1, 'strings'),\n (2, 'woodwinds');\ninsert into\n instruments (id, section_id, name)\nvalues\n (1, 2, 'flute'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"violin\",\n \"orchestral_sections\": {\"name\": \"strings\"}\n },\n {\n \"name\": \"flute\",\n \"orchestral_sections\": {\"name\": \"woodwinds\"}\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Ordering with `referenced_table(col)` affects the ordering of the\nparent table." - } - ] - }, - { - "name": "overlaps", - "description": "Only relevant for array and range columns. Match only rows where `column` and `value` have an element in common.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "value", - "type": { - "kind": "union", - "types": [ - "string", - { - "kind": "typeOperator" - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "On array columns", - "code": "const { data, error } = await supabase\n .from('issues')\n .select('title')\n .overlaps('tags', ['is:closed', 'severity:high'])", - "sql": "create table\n issues (\n id int8 primary key,\n title text,\n tags text[]\n );\n\ninsert into\n issues (id, title, tags)\nvalues\n (1, 'Cache invalidation is not working', array['is:open', 'severity:high', 'priority:low']),\n (2, 'Use better names', array['is:open', 'severity:low', 'priority:medium']);", - "response": "{\n \"data\": [\n {\n \"title\": \"Cache invalidation is not working\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "On range columns\nPostgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - }, - { - "title": "On range columns", - "code": "const { data, error } = await supabase\n .from('reservations')\n .select()\n .overlaps('during', '[2000-01-01 12:45, 2000-01-01 13:15)')", - "sql": "create table\n reservations (\n id int8 primary key,\n room_name text,\n during tsrange\n );\n\ninsert into\n reservations (id, room_name, during)\nvalues\n (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),\n (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"room_name\": \"Emerald\",\n \"during\": \"[\\\"2000-01-01 13:00:00\\\",\\\"2000-01-01 15:00:00\\\")\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Postgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - } - ] - }, - { - "name": "overrideTypes", - "description": "Override the type of the returned `data` field in the response.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Example 1", - "code": "// Merge with existing types (default behavior)\nconst query = supabase\n .from('users')\n .select()\n .overrideTypes<{ custom_field: string }>()\n\n// Replace existing types completely\nconst replaceQuery = supabase\n .from('users')\n .select()\n .overrideTypes<{ id: number; name: string }, { merge: false }>()", - "response": "let x: typeof data // MyType[]" - }, - { - "title": "Complete Override type of successful response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .overrideTypes, { merge: false }>()", - "response": "let x: typeof data // MyType[]" - }, - { - "title": "Complete Override type of object response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .maybeSingle()\n .overrideTypes()", - "response": "let x: typeof data // MyType | null" - }, - { - "title": "Partial Override type of successful response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .overrideTypes>()", - "response": "let x: typeof data // Array" - }, - { - "title": "Partial Override type of object response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .maybeSingle()\n .overrideTypes<{ status: \"A\" | \"B\" }>()", - "response": "let x: typeof data // CountryRowProperties & { status: \"A\" | \"B\" } | null" - }, - { - "title": "Example 5", - "code": "// Merge with existing types (default behavior)\nconst query = supabase\n .from('users')\n .select()\n .overrideTypes<{ custom_field: string }>()\n\n// Replace existing types completely\nconst replaceQuery = supabase\n .from('users')\n .select()\n .overrideTypes<{ id: number; name: string }, { merge: false }>()" - } - ] - }, - { - "name": "range", - "description": "Limit the query result by starting at an offset `from` and ending at the offset `to`. Only records within this range are returned. This respects the query order and if there is no order clause the range could behave unexpectedly. The `from` and `to` values are 0-based and inclusive: `range(1, 3)` will include the second, third and fourth rows of the query.", - "parameters": [ - { - "name": "from", - "description": "The starting index from which to limit the result", - "type": "number" - }, - { - "name": "to", - "description": "The last index to which to limit the result", - "type": "number" - }, - { - "name": "options", - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "foreignTable", - "optional": true, - "description": "Deprecated, use `options.referencedTable` instead", - "type": "string" - }, - { - "name": "referencedTable", - "optional": true, - "description": "Set this to limit rows of referenced tables instead of the parent table", - "type": "string" - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('name')\n .range(0, 1)", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"name\": \"Luke\"\n },\n {\n \"name\": \"Leia\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "rangeAdjacent", - "description": "Only relevant for range columns. Match only rows where `column` is mutually exclusive to `range` and there can be no element between the two ranges.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "range", - "type": "string" - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('reservations')\n .select()\n .rangeAdjacent('during', '[2000-01-01 12:00, 2000-01-01 13:00)')", - "sql": "create table\n reservations (\n id int8 primary key,\n room_name text,\n during tsrange\n );\n\ninsert into\n reservations (id, room_name, during)\nvalues\n (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),\n (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"room_name\": \"Emerald\",\n \"during\": \"[\\\"2000-01-01 13:00:00\\\",\\\"2000-01-01 15:00:00\\\")\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "With `select()`\nPostgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - } - ] - }, - { - "name": "rangeGt", - "description": "Only relevant for range columns. Match only rows where every element in `column` is greater than any element in `range`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "range", - "type": "string" - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('reservations')\n .select()\n .rangeGt('during', '[2000-01-02 08:00, 2000-01-02 09:00)')", - "sql": "create table\n reservations (\n id int8 primary key,\n room_name text,\n during tsrange\n );\n\ninsert into\n reservations (id, room_name, during)\nvalues\n (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),\n (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');", - "response": "{\n \"data\": [\n {\n \"id\": 2,\n \"room_name\": \"Topaz\",\n \"during\": \"[\\\"2000-01-02 09:00:00\\\",\\\"2000-01-02 10:00:00\\\")\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n }", - "notes": "With `select()`\nPostgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - } - ] - }, - { - "name": "rangeGte", - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or greater than any element in `range`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "range", - "type": "string" - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('reservations')\n .select()\n .rangeGte('during', '[2000-01-02 08:30, 2000-01-02 09:30)')", - "sql": "create table\n reservations (\n id int8 primary key,\n room_name text,\n during tsrange\n );\n\ninsert into\n reservations (id, room_name, during)\nvalues\n (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),\n (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');", - "response": "{\n \"data\": [\n {\n \"id\": 2,\n \"room_name\": \"Topaz\",\n \"during\": \"[\\\"2000-01-02 09:00:00\\\",\\\"2000-01-02 10:00:00\\\")\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n }", - "notes": "With `select()`\nPostgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - } - ] - }, - { - "name": "rangeLt", - "description": "Only relevant for range columns. Match only rows where every element in `column` is less than any element in `range`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "range", - "type": "string" - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('reservations')\n .select()\n .rangeLt('during', '[2000-01-01 15:00, 2000-01-01 16:00)')", - "sql": "create table\n reservations (\n id int8 primary key,\n room_name text,\n during tsrange\n );\n\ninsert into\n reservations (id, room_name, during)\nvalues\n (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),\n (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"room_name\": \"Emerald\",\n \"during\": \"[\\\"2000-01-01 13:00:00\\\",\\\"2000-01-01 15:00:00\\\")\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "With `select()`\nPostgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - } - ] - }, - { - "name": "rangeLte", - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or less than any element in `range`.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "range", - "type": "string" - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('reservations')\n .select()\n .rangeLte('during', '[2000-01-01 14:00, 2000-01-01 16:00)')", - "sql": "create table\n reservations (\n id int8 primary key,\n room_name text,\n during tsrange\n );\n\ninsert into\n reservations (id, room_name, during)\nvalues\n (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),\n (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"room_name\": \"Emerald\",\n \"during\": \"[\\\"2000-01-01 13:00:00\\\",\\\"2000-01-01 15:00:00\\\")\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n }", - "notes": "With `select()`\nPostgres supports a number of [range\ntypes](https://www.postgresql.org/docs/current/rangetypes.html). You\ncan filter on range columns using the string representation of range\nvalues." - } - ] - }, - { - "name": "returns", - "description": "Override the type of the returned `data`.", - "remarks": [ - "- Deprecated: use overrideTypes method instead" - ], - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestTransformBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Override type of successful response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .returns>()", - "response": "let x: typeof data // MyType[]" - }, - { - "title": "Override type of object response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .maybeSingle()\n .returns()", - "response": "let x: typeof data // MyType | null" - } - ] - }, - { - "name": "rollback", - "description": "Rollback the query.\n`data` will still be returned, but the query is not committed.", - "parameters": [], - "returnType": "this" - }, - { - "name": "select", - "description": "Perform a SELECT on the query result.\nBy default, `.insert()`, `.update()`, `.upsert()`, and `.delete()` do not return modified rows. By calling this method, modified rows are returned in `data`.", - "parameters": [ - { - "name": "columns", - "optional": true, - "description": "The columns to retrieve, separated by commas", - "type": { - "kind": "typeParam", - "name": "Query" - } - } - ], - "returnType": { - "kind": "object", - "name": "PostgrestFilterBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "containedBy", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in `column` is contained by `value`.", - "type": null - }, - { - "name": "contains", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where `column` contains every element appearing in `value`.", - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "eq", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "filter", - "optional": false, - "description": "Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "gt", - "optional": false, - "description": "Match only rows where `column` is greater than `value`.", - "type": null - }, - { - "name": "gte", - "optional": false, - "description": "Match only rows where `column` is greater than or equal to `value`.", - "type": null - }, - { - "name": "ilike", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-insensitively.", - "type": null - }, - { - "name": "ilikeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-insensitively.", - "type": null - }, - { - "name": "ilikeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-insensitively.", - "type": null - }, - { - "name": "in", - "optional": false, - "type": null - }, - { - "name": "is", - "optional": false, - "description": "Match only rows where `column` IS `value`.\nFor non-boolean columns, this is only relevant for checking if the value of `column` is NULL by setting `value` to `null`.\nFor boolean columns, you can also set `value` to `true` or `false` and it will behave the same way as `.eq()`.", - "type": null - }, - { - "name": "isDistinct", - "optional": false, - "type": null - }, - { - "name": "like", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-sensitively.", - "type": null - }, - { - "name": "likeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-sensitively.", - "type": null - }, - { - "name": "likeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-sensitively.", - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "lt", - "optional": false, - "description": "Match only rows where `column` is less than `value`.", - "type": null - }, - { - "name": "lte", - "optional": false, - "description": "Match only rows where `column` is less than or equal to `value`.", - "type": null - }, - { - "name": "match", - "optional": false, - "description": "Match only rows where each column in `query` keys is equal to its associated value. Shorthand for multiple `.eq()`s.", - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "neq", - "optional": false, - "type": null - }, - { - "name": "not", - "optional": false, - "description": "Match only rows which doesn't satisfy the filter.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "notIn", - "optional": false, - "type": null - }, - { - "name": "or", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overlaps", - "optional": false, - "description": "Only relevant for array and range columns. Match only rows where `column` and `value` have an element in common.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "rangeAdjacent", - "optional": false, - "description": "Only relevant for range columns. Match only rows where `column` is mutually exclusive to `range` and there can be no element between the two ranges.", - "type": null - }, - { - "name": "rangeGt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is greater than any element in `range`.", - "type": null - }, - { - "name": "rangeGte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or greater than any element in `range`.", - "type": null - }, - { - "name": "rangeLt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is less than any element in `range`.", - "type": null - }, - { - "name": "rangeLte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or less than any element in `range`.", - "type": null - }, - { - "name": "regexIMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-insensitively (using the `~*` operator).", - "type": null - }, - { - "name": "regexMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-sensitively (using the `~` operator).", - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "textSearch", - "optional": false, - "description": "Only relevant for text and tsvector columns. Match only rows where `column` matches the query string in `query`.", - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "With `upsert()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .upsert({ id: 1, name: 'Han Solo' })\n .select()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Han Solo\"\n }\n ],\n \"status\": 201,\n \"statusText\": \"Created\"\n}" - } - ] - }, - { - "name": "setHeader", - "description": "Set an HTTP header for the request.", - "parameters": [ - { - "name": "name", - "type": "string" - }, - { - "name": "value", - "type": "string" - } - ], - "returnType": "this" - }, - { - "name": "single", - "description": "Return `data` as a single object instead of an array of objects.\nQuery result must be one row (e.g. using `.limit(1)`), otherwise this returns an error.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('name')\n .limit(1)\n .single()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": {\n \"name\": \"Luke\"\n },\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "textSearch", - "description": "Only relevant for text and tsvector columns. Match only rows where `column` matches the query string in `query`.", - "remarks": [ - "- For more information, see [Postgres full text search](/docs/guides/database/full-text-search)." - ], - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "query", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": true, - "type": "string" - }, - { - "name": "type", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "plain" - }, - { - "kind": "literal", - "value": "phrase" - }, - { - "kind": "literal", - "value": "websearch" - } - ] - } - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "Text search", - "code": "const result = await supabase\n .from(\"texts\")\n .select(\"content\")\n .textSearch(\"content\", `'eggs' & 'ham'`, {\n config: \"english\",\n });", - "sql": "create table texts (\n id bigint\n primary key\n generated always as identity,\n content text\n);\n\ninsert into texts (content) values\n ('Four score and seven years ago'),\n ('The road goes ever on and on'),\n ('Green eggs and ham')\n;", - "response": "{\n \"data\": [\n {\n \"content\": \"Green eggs and ham\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Basic normalization\nUses PostgreSQL's `plainto_tsquery` function." - }, - { - "title": "Basic normalization", - "code": "const { data, error } = await supabase\n .from('quotes')\n .select('catchphrase')\n .textSearch('catchphrase', `'fat' & 'cat'`, {\n type: 'plain',\n config: 'english'\n })", - "notes": "Uses PostgreSQL's `plainto_tsquery` function." - }, - { - "title": "Full normalization", - "code": "const { data, error } = await supabase\n .from('quotes')\n .select('catchphrase')\n .textSearch('catchphrase', `'fat' & 'cat'`, {\n type: 'phrase',\n config: 'english'\n })", - "notes": "Uses PostgreSQL's `phraseto_tsquery` function." - }, - { - "title": "Websearch", - "code": "const { data, error } = await supabase\n .from('quotes')\n .select('catchphrase')\n .textSearch('catchphrase', `'fat or cat'`, {\n type: 'websearch',\n config: 'english'\n })", - "notes": "Uses PostgreSQL's `websearch_to_tsquery` function.\nThis function will never raise syntax errors, which makes it possible to use raw user-supplied input for search, and can be used\nwith advanced operators.\n\n- `unquoted text`: text not inside quote marks will be converted to terms separated by & operators, as if processed by plainto_tsquery.\n- `\"quoted text\"`: text inside quote marks will be converted to terms separated by `<->` operators, as if processed by phraseto_tsquery.\n- `OR`: the word “or” will be converted to the | operator.\n- `-`: a dash will be converted to the ! operator." - } - ] - }, - { - "name": "then", - "description": "", - "parameters": [ - { - "name": "onfulfilled", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "onrejected", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "PromiseLike", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "typeParam", - "name": "TResult1" - }, - { - "kind": "typeParam", - "name": "TResult2" - } - ] - } - ] - } - }, - { - "name": "throwOnError", - "description": "If there's an error with the query, throwOnError will reject the promise by throwing the error instead of returning it as part of a successful response.\nhttps://github.com/supabase/supabase-js/issues/92", - "parameters": [], - "returnType": { - "kind": "intersection", - "types": [ - { - "kind": "object", - "name": "PostgrestFilterBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "containedBy", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in `column` is contained by `value`.", - "type": null - }, - { - "name": "contains", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where `column` contains every element appearing in `value`.", - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "eq", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "filter", - "optional": false, - "description": "Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "gt", - "optional": false, - "description": "Match only rows where `column` is greater than `value`.", - "type": null - }, - { - "name": "gte", - "optional": false, - "description": "Match only rows where `column` is greater than or equal to `value`.", - "type": null - }, - { - "name": "ilike", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-insensitively.", - "type": null - }, - { - "name": "ilikeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-insensitively.", - "type": null - }, - { - "name": "ilikeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-insensitively.", - "type": null - }, - { - "name": "in", - "optional": false, - "type": null - }, - { - "name": "is", - "optional": false, - "description": "Match only rows where `column` IS `value`.\nFor non-boolean columns, this is only relevant for checking if the value of `column` is NULL by setting `value` to `null`.\nFor boolean columns, you can also set `value` to `true` or `false` and it will behave the same way as `.eq()`.", - "type": null - }, - { - "name": "isDistinct", - "optional": false, - "type": null - }, - { - "name": "like", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-sensitively.", - "type": null - }, - { - "name": "likeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-sensitively.", - "type": null - }, - { - "name": "likeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-sensitively.", - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "lt", - "optional": false, - "description": "Match only rows where `column` is less than `value`.", - "type": null - }, - { - "name": "lte", - "optional": false, - "description": "Match only rows where `column` is less than or equal to `value`.", - "type": null - }, - { - "name": "match", - "optional": false, - "description": "Match only rows where each column in `query` keys is equal to its associated value. Shorthand for multiple `.eq()`s.", - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "neq", - "optional": false, - "type": null - }, - { - "name": "not", - "optional": false, - "description": "Match only rows which doesn't satisfy the filter.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "notIn", - "optional": false, - "type": null - }, - { - "name": "or", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overlaps", - "optional": false, - "description": "Only relevant for array and range columns. Match only rows where `column` and `value` have an element in common.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "rangeAdjacent", - "optional": false, - "description": "Only relevant for range columns. Match only rows where `column` is mutually exclusive to `range` and there can be no element between the two ranges.", - "type": null - }, - { - "name": "rangeGt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is greater than any element in `range`.", - "type": null - }, - { - "name": "rangeGte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or greater than any element in `range`.", - "type": null - }, - { - "name": "rangeLt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is less than any element in `range`.", - "type": null - }, - { - "name": "rangeLte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or less than any element in `range`.", - "type": null - }, - { - "name": "regexIMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-insensitively (using the `~*` operator).", - "type": null - }, - { - "name": "regexMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-sensitively (using the `~` operator).", - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "textSearch", - "optional": false, - "description": "Only relevant for text and tsvector columns. Match only rows where `column` matches the query string in `query`.", - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - } - ] - } - }, - { - "name": "delete", - "description": "Perform a DELETE on the table or view.\nBy default, deleted rows are not returned. To return it, chain the call with `.select()` after filters.", - "remarks": [ - "- `delete()` should always be combined with [filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to delete. - If you use `delete()` with filters and you have [RLS](/docs/learn/auth-deep-dive/auth-row-level-security) enabled, only rows visible through `SELECT` policies are deleted. Note that by default no rows are visible, so you need at least one `SELECT`/`ALL` policy that makes the rows visible. - When using `delete().in()`, specify an array of values to target multiple rows with a single query. This is particularly useful for batch deleting entries that share common criteria, such as deleting users by their IDs. Ensure that the array you provide accurately represents all records you intend to delete to avoid unintended data removal." - ], - "parameters": [ - { - "name": "options", - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "count", - "optional": true, - "description": "Count algorithm to use to count deleted rows.\n`\"exact\"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the hood.\n`\"planned\"`: Approximated but fast count algorithm. Uses the Postgres statistics under the hood.\n`\"estimated\"`: Uses exact count for low numbers and planned count for high numbers.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "exact" - }, - { - "kind": "literal", - "value": "planned" - }, - { - "kind": "literal", - "value": "estimated" - } - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "object", - "name": "PostgrestFilterBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "containedBy", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in `column` is contained by `value`.", - "type": null - }, - { - "name": "contains", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where `column` contains every element appearing in `value`.", - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "eq", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "filter", - "optional": false, - "description": "Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "gt", - "optional": false, - "description": "Match only rows where `column` is greater than `value`.", - "type": null - }, - { - "name": "gte", - "optional": false, - "description": "Match only rows where `column` is greater than or equal to `value`.", - "type": null - }, - { - "name": "ilike", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-insensitively.", - "type": null - }, - { - "name": "ilikeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-insensitively.", - "type": null - }, - { - "name": "ilikeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-insensitively.", - "type": null - }, - { - "name": "in", - "optional": false, - "type": null - }, - { - "name": "is", - "optional": false, - "description": "Match only rows where `column` IS `value`.\nFor non-boolean columns, this is only relevant for checking if the value of `column` is NULL by setting `value` to `null`.\nFor boolean columns, you can also set `value` to `true` or `false` and it will behave the same way as `.eq()`.", - "type": null - }, - { - "name": "isDistinct", - "optional": false, - "type": null - }, - { - "name": "like", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-sensitively.", - "type": null - }, - { - "name": "likeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-sensitively.", - "type": null - }, - { - "name": "likeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-sensitively.", - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "lt", - "optional": false, - "description": "Match only rows where `column` is less than `value`.", - "type": null - }, - { - "name": "lte", - "optional": false, - "description": "Match only rows where `column` is less than or equal to `value`.", - "type": null - }, - { - "name": "match", - "optional": false, - "description": "Match only rows where each column in `query` keys is equal to its associated value. Shorthand for multiple `.eq()`s.", - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "neq", - "optional": false, - "type": null - }, - { - "name": "not", - "optional": false, - "description": "Match only rows which doesn't satisfy the filter.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "notIn", - "optional": false, - "type": null - }, - { - "name": "or", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overlaps", - "optional": false, - "description": "Only relevant for array and range columns. Match only rows where `column` and `value` have an element in common.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "rangeAdjacent", - "optional": false, - "description": "Only relevant for range columns. Match only rows where `column` is mutually exclusive to `range` and there can be no element between the two ranges.", - "type": null - }, - { - "name": "rangeGt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is greater than any element in `range`.", - "type": null - }, - { - "name": "rangeGte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or greater than any element in `range`.", - "type": null - }, - { - "name": "rangeLt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is less than any element in `range`.", - "type": null - }, - { - "name": "rangeLte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or less than any element in `range`.", - "type": null - }, - { - "name": "regexIMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-insensitively (using the `~*` operator).", - "type": null - }, - { - "name": "regexMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-sensitively (using the `~` operator).", - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "textSearch", - "optional": false, - "description": "Only relevant for text and tsvector columns. Match only rows where `column` matches the query string in `query`.", - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Delete a single record", - "code": "const response = await supabase\n .from('countries')\n .delete()\n .eq('id', 1)", - "sql": "create table\n countries (id int8 primary key, name text);\n\ninsert into\n countries (id, name)\nvalues\n (1, 'Mordor');", - "response": "{\n \"status\": 204,\n \"statusText\": \"No Content\"\n}" - }, - { - "title": "Delete a record and return it", - "code": "const { data, error } = await supabase\n .from('countries')\n .delete()\n .eq('id', 1)\n .select()", - "sql": "create table\n countries (id int8 primary key, name text);\n\ninsert into\n countries (id, name)\nvalues\n (1, 'Mordor');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Mordor\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - }, - { - "title": "Delete multiple records", - "code": "const response = await supabase\n .from('countries')\n .delete()\n .in('id', [1, 2, 3])", - "sql": "create table\n countries (id int8 primary key, name text);\n\ninsert into\n countries (id, name)\nvalues\n (1, 'Rohan'), (2, 'The Shire'), (3, 'Mordor');", - "response": "{\n \"status\": 204,\n \"statusText\": \"No Content\"\n}" - } - ] - }, - { - "name": "insert", - "description": "Perform an INSERT into the table or view.\nBy default, inserted rows are not returned. To return it, chain the call with `.select()`.", - "parameters": [ - { - "name": "values", - "type": { - "kind": "typeParam", - "name": "Row" - } - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "count", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "exact" - }, - { - "kind": "literal", - "value": "planned" - }, - { - "kind": "literal", - "value": "estimated" - } - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "object", - "name": "PostgrestFilterBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "containedBy", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in `column` is contained by `value`.", - "type": null - }, - { - "name": "contains", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where `column` contains every element appearing in `value`.", - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "eq", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "filter", - "optional": false, - "description": "Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "gt", - "optional": false, - "description": "Match only rows where `column` is greater than `value`.", - "type": null - }, - { - "name": "gte", - "optional": false, - "description": "Match only rows where `column` is greater than or equal to `value`.", - "type": null - }, - { - "name": "ilike", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-insensitively.", - "type": null - }, - { - "name": "ilikeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-insensitively.", - "type": null - }, - { - "name": "ilikeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-insensitively.", - "type": null - }, - { - "name": "in", - "optional": false, - "type": null - }, - { - "name": "is", - "optional": false, - "description": "Match only rows where `column` IS `value`.\nFor non-boolean columns, this is only relevant for checking if the value of `column` is NULL by setting `value` to `null`.\nFor boolean columns, you can also set `value` to `true` or `false` and it will behave the same way as `.eq()`.", - "type": null - }, - { - "name": "isDistinct", - "optional": false, - "type": null - }, - { - "name": "like", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-sensitively.", - "type": null - }, - { - "name": "likeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-sensitively.", - "type": null - }, - { - "name": "likeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-sensitively.", - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "lt", - "optional": false, - "description": "Match only rows where `column` is less than `value`.", - "type": null - }, - { - "name": "lte", - "optional": false, - "description": "Match only rows where `column` is less than or equal to `value`.", - "type": null - }, - { - "name": "match", - "optional": false, - "description": "Match only rows where each column in `query` keys is equal to its associated value. Shorthand for multiple `.eq()`s.", - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "neq", - "optional": false, - "type": null - }, - { - "name": "not", - "optional": false, - "description": "Match only rows which doesn't satisfy the filter.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "notIn", - "optional": false, - "type": null - }, - { - "name": "or", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overlaps", - "optional": false, - "description": "Only relevant for array and range columns. Match only rows where `column` and `value` have an element in common.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "rangeAdjacent", - "optional": false, - "description": "Only relevant for range columns. Match only rows where `column` is mutually exclusive to `range` and there can be no element between the two ranges.", - "type": null - }, - { - "name": "rangeGt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is greater than any element in `range`.", - "type": null - }, - { - "name": "rangeGte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or greater than any element in `range`.", - "type": null - }, - { - "name": "rangeLt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is less than any element in `range`.", - "type": null - }, - { - "name": "rangeLte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or less than any element in `range`.", - "type": null - }, - { - "name": "regexIMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-insensitively (using the `~*` operator).", - "type": null - }, - { - "name": "regexMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-sensitively (using the `~` operator).", - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "textSearch", - "optional": false, - "description": "Only relevant for text and tsvector columns. Match only rows where `column` matches the query string in `query`.", - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Create a record", - "code": "const { error } = await supabase\n .from('countries')\n .insert({ id: 1, name: 'Mordor' })", - "sql": "create table\n countries (id int8 primary key, name text);", - "response": "{\n \"status\": 201,\n \"statusText\": \"Created\"\n}", - "notes": "Bulk create\nA bulk create operation is handled in a single transaction.\nIf any of the inserts fail, none of the rows are inserted." - }, - { - "title": "Create a record and return it", - "code": "const { data, error } = await supabase\n .from('countries')\n .insert({ id: 1, name: 'Mordor' })\n .select()", - "sql": "create table\n countries (id int8 primary key, name text);", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Mordor\"\n }\n ],\n \"status\": 201,\n \"statusText\": \"Created\"\n}" - }, - { - "title": "Bulk create", - "code": "const { error } = await supabase\n .from('countries')\n .insert([\n { id: 1, name: 'Mordor' },\n { id: 1, name: 'The Shire' },\n ])", - "sql": "create table\n countries (id int8 primary key, name text);", - "response": "{\n \"error\": {\n \"code\": \"23505\",\n \"details\": \"Key (id)=(1) already exists.\",\n \"hint\": null,\n \"message\": \"duplicate key value violates unique constraint \\\"countries_pkey\\\"\"\n },\n \"status\": 409,\n \"statusText\": \"Conflict\"\n}", - "notes": "A bulk create operation is handled in a single transaction.\nIf any of the inserts fail, none of the rows are inserted." - } - ] - }, - { - "name": "select", - "description": "Perform a SELECT query on the table or view.", - "remarks": [ - "When using `count` with `.range()` or `.limit()`, the returned `count` is the total number of rows that match your filters, not the number of rows in the current page. Use this to build pagination UI.\n- By default, Supabase projects return a maximum of 1,000 rows. This setting can be changed in your project's [API settings](/dashboard/project/_/settings/api). It's recommended that you keep it low to limit the payload size of accidental or malicious requests. You can use `range()` queries to paginate through your data. - `select()` can be combined with [Filters](/docs/reference/javascript/using-filters) - `select()` can be combined with [Modifiers](/docs/reference/javascript/using-modifiers) - `apikey` is a reserved keyword if you're using the [Supabase Platform](/docs/guides/platform) and [should be avoided as a column name](https://github.com/supabase/supabase/issues/5465). *" - ], - "parameters": [ - { - "name": "columns", - "optional": true, - "description": "The columns to retrieve, separated by commas. Columns can be renamed when returned with `customName:columnName`", - "type": { - "kind": "typeParam", - "name": "Query" - } - }, - { - "name": "options", - "optional": true, - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "count", - "optional": true, - "description": "Count algorithm to use to count rows in the table or view.\n`\"exact\"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the hood.\n`\"planned\"`: Approximated but fast count algorithm. Uses the Postgres statistics under the hood.\n`\"estimated\"`: Uses exact count for low numbers and planned count for high numbers.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "exact" - }, - { - "kind": "literal", - "value": "planned" - }, - { - "kind": "literal", - "value": "estimated" - } - ] - } - }, - { - "name": "head", - "optional": true, - "description": "When set to `true`, `data` will not be returned. Useful if you only need the count.", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "object", - "name": "PostgrestFilterBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "containedBy", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in `column` is contained by `value`.", - "type": null - }, - { - "name": "contains", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where `column` contains every element appearing in `value`.", - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "eq", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "filter", - "optional": false, - "description": "Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "gt", - "optional": false, - "description": "Match only rows where `column` is greater than `value`.", - "type": null - }, - { - "name": "gte", - "optional": false, - "description": "Match only rows where `column` is greater than or equal to `value`.", - "type": null - }, - { - "name": "ilike", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-insensitively.", - "type": null - }, - { - "name": "ilikeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-insensitively.", - "type": null - }, - { - "name": "ilikeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-insensitively.", - "type": null - }, - { - "name": "in", - "optional": false, - "type": null - }, - { - "name": "is", - "optional": false, - "description": "Match only rows where `column` IS `value`.\nFor non-boolean columns, this is only relevant for checking if the value of `column` is NULL by setting `value` to `null`.\nFor boolean columns, you can also set `value` to `true` or `false` and it will behave the same way as `.eq()`.", - "type": null - }, - { - "name": "isDistinct", - "optional": false, - "type": null - }, - { - "name": "like", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-sensitively.", - "type": null - }, - { - "name": "likeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-sensitively.", - "type": null - }, - { - "name": "likeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-sensitively.", - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "lt", - "optional": false, - "description": "Match only rows where `column` is less than `value`.", - "type": null - }, - { - "name": "lte", - "optional": false, - "description": "Match only rows where `column` is less than or equal to `value`.", - "type": null - }, - { - "name": "match", - "optional": false, - "description": "Match only rows where each column in `query` keys is equal to its associated value. Shorthand for multiple `.eq()`s.", - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "neq", - "optional": false, - "type": null - }, - { - "name": "not", - "optional": false, - "description": "Match only rows which doesn't satisfy the filter.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "notIn", - "optional": false, - "type": null - }, - { - "name": "or", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overlaps", - "optional": false, - "description": "Only relevant for array and range columns. Match only rows where `column` and `value` have an element in common.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "rangeAdjacent", - "optional": false, - "description": "Only relevant for range columns. Match only rows where `column` is mutually exclusive to `range` and there can be no element between the two ranges.", - "type": null - }, - { - "name": "rangeGt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is greater than any element in `range`.", - "type": null - }, - { - "name": "rangeGte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or greater than any element in `range`.", - "type": null - }, - { - "name": "rangeLt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is less than any element in `range`.", - "type": null - }, - { - "name": "rangeLte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or less than any element in `range`.", - "type": null - }, - { - "name": "regexIMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-insensitively (using the `~*` operator).", - "type": null - }, - { - "name": "regexMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-sensitively (using the `~` operator).", - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "textSearch", - "optional": false, - "description": "Only relevant for text and tsvector columns. Match only rows where `column` matches the query string in `query`.", - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Getting your data", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Harry'),\n (2, 'Frodo'),\n (3, 'Katniss');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Harry\"\n },\n {\n \"id\": 2,\n \"name\": \"Frodo\"\n },\n {\n \"id\": 3,\n \"name\": \"Katniss\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Query referenced tables\nIf your database has foreign key relationships, you can query related tables too." - }, - { - "title": "Selecting specific columns", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('name')", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Frodo'),\n (2, 'Harry'),\n (3, 'Katniss');", - "response": "{\n \"data\": [\n {\n \"name\": \"Frodo\"\n },\n {\n \"name\": \"Harry\"\n },\n {\n \"name\": \"Katniss\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Query referenced tables with spaces in their names\nIf your table name contains spaces, you must use double quotes in the `select` statement to reference the table." - }, - { - "title": "Query referenced tables", - "code": "const { data, error } = await supabase\n .from('orchestral_sections')\n .select(`\n name,\n instruments (\n name\n )\n `)", - "sql": "create table\n orchestral_sections (id int8 primary key, name text);\ncreate table\n instruments (\n id int8 primary key,\n section_id int8 not null references orchestral_sections,\n name text\n );\n\ninsert into\n orchestral_sections (id, name)\nvalues\n (1, 'strings'),\n (2, 'woodwinds');\ninsert into\n instruments (id, section_id, name)\nvalues\n (1, 2, 'flute'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"strings\",\n \"instruments\": [\n {\n \"name\": \"violin\"\n }\n ]\n },\n {\n \"name\": \"woodwinds\",\n \"instruments\": [\n {\n \"name\": \"flute\"\n }\n ]\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "If your database has foreign key relationships, you can query related tables too." - }, - { - "title": "Query referenced tables with spaces in their names", - "code": "const { data, error } = await supabase\n .from('orchestral sections')\n .select(`\n name,\n \"musical instruments\" (\n name\n )\n `)", - "sql": "create table\n \"orchestral sections\" (id int8 primary key, name text);\ncreate table\n \"musical instruments\" (\n id int8 primary key,\n section_id int8 not null references \"orchestral sections\",\n name text\n );\n\ninsert into\n \"orchestral sections\" (id, name)\nvalues\n (1, 'strings'),\n (2, 'woodwinds');\ninsert into\n \"musical instruments\" (id, section_id, name)\nvalues\n (1, 2, 'flute'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"strings\",\n \"musical instruments\": [\n {\n \"name\": \"violin\"\n }\n ]\n },\n {\n \"name\": \"woodwinds\",\n \"musical instruments\": [\n {\n \"name\": \"flute\"\n }\n ]\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "If your table name contains spaces, you must use double quotes in the `select` statement to reference the table." - }, - { - "title": "Query referenced tables through a join table", - "code": "const { data, error } = await supabase\n .from('users')\n .select(`\n name,\n teams (\n name\n )\n `)", - "sql": "create table\n users (\n id int8 primary key,\n name text\n );\ncreate table\n teams (\n id int8 primary key,\n name text\n );\n-- join table\ncreate table\n users_teams (\n user_id int8 not null references users,\n team_id int8 not null references teams,\n -- both foreign keys must be part of a composite primary key\n primary key (user_id, team_id)\n );\n\ninsert into\n users (id, name)\nvalues\n (1, 'Kiran'),\n (2, 'Evan');\ninsert into\n teams (id, name)\nvalues\n (1, 'Green'),\n (2, 'Blue');\ninsert into\n users_teams (user_id, team_id)\nvalues\n (1, 1),\n (1, 2),\n (2, 2);", - "response": "{\n \"data\": [\n {\n \"name\": \"Kiran\",\n \"teams\": [\n {\n \"name\": \"Green\"\n },\n {\n \"name\": \"Blue\"\n }\n ]\n },\n {\n \"name\": \"Evan\",\n \"teams\": [\n {\n \"name\": \"Blue\"\n }\n ]\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n }", - "notes": "If you're in a situation where your tables are **NOT** directly\nrelated, but instead are joined by a _join table_, you can still use\nthe `select()` method to query the related data. The join table needs\nto have the foreign keys as part of its composite primary key." - }, - { - "title": "Query the same referenced table multiple times", - "code": "const { data, error } = await supabase\n .from('messages')\n .select(`\n content,\n from:sender_id(name),\n to:receiver_id(name)\n `)\n\n// To infer types, use the name of the table (in this case `users`) and\n// the name of the foreign key constraint.\nconst { data, error } = await supabase\n .from('messages')\n .select(`\n content,\n from:users!messages_sender_id_fkey(name),\n to:users!messages_receiver_id_fkey(name)\n `)", - "sql": "create table\n users (\n id int8 primary key,\n name text\n );\ncreate table\n teams (\n id int8 primary key,\n name text\n );\n-- join table\ncreate table\n users_teams (\n user_id int8 not null references users,\n team_id int8 not null references teams,\n\n primary key (user_id, team_id)\n );\ncreate table\n games (\n id int8 primary key,\n home_team int8 not null references teams,\n away_team int8 not null references teams,\n name text\n );\n\ninsert into users (id, name)\nvalues\n (1, 'Kiran'),\n (2, 'Evan');\ninsert into\n teams (id, name)\nvalues\n (1, 'Green'),\n (2, 'Blue');\ninsert into\n users_teams (user_id, team_id)\nvalues\n (1, 1),\n (1, 2),\n (2, 2);\ninsert into\n games (id, home_team, away_team, name)\nvalues\n (1, 1, 2, 'Green vs Blue'),\n (2, 2, 1, 'Blue vs Green');", - "response": "{\n \"data\": [\n {\n \"game_id\": 1,\n \"away_team\": {\n \"users\": [\n {\n \"id\": 1,\n \"name\": \"Kiran\"\n },\n {\n \"id\": 2,\n \"name\": \"Evan\"\n }\n ]\n }\n },\n {\n \"game_id\": 2,\n \"away_team\": {\n \"users\": [\n {\n \"id\": 1,\n \"name\": \"Kiran\"\n }\n ]\n }\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n }", - "notes": "If you need to query the same referenced table twice, use the name of the\njoined column to identify which join to use. You can also give each\ncolumn an alias." - }, - { - "title": "Filtering through referenced tables", - "code": "const { data, error } = await supabase\n .from('instruments')\n .select('name, orchestral_sections(*)')\n .eq('orchestral_sections.name', 'percussion')", - "sql": "create table\n orchestral_sections (id int8 primary key, name text);\ncreate table\n instruments (\n id int8 primary key,\n section_id int8 not null references orchestral_sections,\n name text\n );\n\ninsert into\n orchestral_sections (id, name)\nvalues\n (1, 'strings'),\n (2, 'woodwinds');\ninsert into\n instruments (id, section_id, name)\nvalues\n (1, 2, 'flute'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"flute\",\n \"orchestral_sections\": null\n },\n {\n \"name\": \"violin\",\n \"orchestral_sections\": null\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "If the filter on a referenced table's column is not satisfied, the referenced\ntable returns `[]` or `null` but the parent table is not filtered out.\nIf you want to filter out the parent table rows, use the `!inner` hint" - }, - { - "title": "Querying referenced table with count", - "code": "const { data, error } = await supabase\n .from('orchestral_sections')\n .select(`*, instruments(count)`)", - "sql": "create table orchestral_sections (\n \"id\" \"uuid\" primary key default \"extensions\".\"uuid_generate_v4\"() not null,\n \"name\" text\n);\n\ncreate table characters (\n \"id\" \"uuid\" primary key default \"extensions\".\"uuid_generate_v4\"() not null,\n \"name\" text,\n \"section_id\" \"uuid\" references public.orchestral_sections on delete cascade\n);\n\nwith section as (\n insert into orchestral_sections (name)\n values ('strings') returning id\n)\ninsert into instruments (name, section_id) values\n('violin', (select id from section)),\n('viola', (select id from section)),\n('cello', (select id from section)),\n('double bass', (select id from section));", - "response": "[\n {\n \"id\": \"693694e7-d993-4360-a6d7-6294e325d9b6\",\n \"name\": \"strings\",\n \"instruments\": [\n {\n \"count\": 4\n }\n ]\n }\n]", - "notes": "You can get the number of rows in a related table by using the\n**count** property." - }, - { - "title": "Querying with count option", - "code": "const { count, error } = await supabase\n .from('characters')\n .select('*', { count: 'exact', head: true })", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"count\": 3,\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "You can get the number of rows by using the\n[count](/docs/reference/javascript/select#parameters) option." - }, - { - "title": "Querying JSON data", - "code": "const { data, error } = await supabase\n .from('users')\n .select(`\n id, name,\n address->city\n `)", - "sql": "create table\n users (\n id int8 primary key,\n name text,\n address jsonb\n );\n\ninsert into\n users (id, name, address)\nvalues\n (1, 'Frodo', '{\"city\":\"Hobbiton\"}');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Frodo\",\n \"city\": \"Hobbiton\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "You can select and filter data inside of\n[JSON](/docs/guides/database/json) columns. Postgres offers some\n[operators](/docs/guides/database/json#query-the-jsonb-data) for\nquerying JSON data." - }, - { - "title": "Querying referenced table with inner join", - "code": "const { data, error } = await supabase\n .from('instruments')\n .select('name, orchestral_sections!inner(name)')\n .eq('orchestral_sections.name', 'woodwinds')\n .limit(1)", - "sql": "create table orchestral_sections (\n \"id\" \"uuid\" primary key default \"extensions\".\"uuid_generate_v4\"() not null,\n \"name\" text\n);\n\ncreate table instruments (\n \"id\" \"uuid\" primary key default \"extensions\".\"uuid_generate_v4\"() not null,\n \"name\" text,\n \"section_id\" \"uuid\" references public.orchestral_sections on delete cascade\n);\n\nwith section as (\n insert into orchestral_sections (name)\n values ('woodwinds') returning id\n)\ninsert into instruments (name, section_id) values\n('flute', (select id from section)),\n('clarinet', (select id from section)),\n('bassoon', (select id from section)),\n('piccolo', (select id from section));", - "response": "{\n \"data\": [\n {\n \"name\": \"flute\",\n \"orchestral_sections\": {\"name\": \"woodwinds\"}\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "If you don't want to return the referenced table contents, you can leave the parenthesis empty.\nLike `.select('name, orchestral_sections!inner()')`." - }, - { - "title": "Switching schemas per query", - "code": "const { data, error } = await supabase\n .schema('myschema')\n .from('mytable')\n .select()", - "sql": "create schema myschema;\n\ncreate table myschema.mytable (\n id uuid primary key default gen_random_uuid(),\n data text\n);\n\ninsert into myschema.mytable (data) values ('mydata');", - "response": "{\n \"data\": [\n {\n \"id\": \"4162e008-27b0-4c0f-82dc-ccaeee9a624d\",\n \"data\": \"mydata\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "In addition to setting the schema during initialization, you can also switch schemas on a per-query basis.\nMake sure you've set up your [database privileges and API settings](/docs/guides/api/using-custom-schemas)." - } - ] - }, - { - "name": "update", - "description": "Perform an UPDATE on the table or view.\nBy default, updated rows are not returned. To return it, chain the call with `.select()` after filters.", - "remarks": [ - "- `update()` should always be combined with [Filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to update." - ], - "parameters": [ - { - "name": "values", - "description": "The values to update with", - "type": { - "kind": "typeParam", - "name": "Row" - } - }, - { - "name": "options", - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "count", - "optional": true, - "description": "Count algorithm to use to count updated rows.\n`\"exact\"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the hood.\n`\"planned\"`: Approximated but fast count algorithm. Uses the Postgres statistics under the hood.\n`\"estimated\"`: Uses exact count for low numbers and planned count for high numbers.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "exact" - }, - { - "kind": "literal", - "value": "planned" - }, - { - "kind": "literal", - "value": "estimated" - } - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "object", - "name": "PostgrestFilterBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "containedBy", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in `column` is contained by `value`.", - "type": null - }, - { - "name": "contains", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where `column` contains every element appearing in `value`.", - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "eq", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "filter", - "optional": false, - "description": "Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "gt", - "optional": false, - "description": "Match only rows where `column` is greater than `value`.", - "type": null - }, - { - "name": "gte", - "optional": false, - "description": "Match only rows where `column` is greater than or equal to `value`.", - "type": null - }, - { - "name": "ilike", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-insensitively.", - "type": null - }, - { - "name": "ilikeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-insensitively.", - "type": null - }, - { - "name": "ilikeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-insensitively.", - "type": null - }, - { - "name": "in", - "optional": false, - "type": null - }, - { - "name": "is", - "optional": false, - "description": "Match only rows where `column` IS `value`.\nFor non-boolean columns, this is only relevant for checking if the value of `column` is NULL by setting `value` to `null`.\nFor boolean columns, you can also set `value` to `true` or `false` and it will behave the same way as `.eq()`.", - "type": null - }, - { - "name": "isDistinct", - "optional": false, - "type": null - }, - { - "name": "like", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-sensitively.", - "type": null - }, - { - "name": "likeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-sensitively.", - "type": null - }, - { - "name": "likeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-sensitively.", - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "lt", - "optional": false, - "description": "Match only rows where `column` is less than `value`.", - "type": null - }, - { - "name": "lte", - "optional": false, - "description": "Match only rows where `column` is less than or equal to `value`.", - "type": null - }, - { - "name": "match", - "optional": false, - "description": "Match only rows where each column in `query` keys is equal to its associated value. Shorthand for multiple `.eq()`s.", - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "neq", - "optional": false, - "type": null - }, - { - "name": "not", - "optional": false, - "description": "Match only rows which doesn't satisfy the filter.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "notIn", - "optional": false, - "type": null - }, - { - "name": "or", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overlaps", - "optional": false, - "description": "Only relevant for array and range columns. Match only rows where `column` and `value` have an element in common.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "rangeAdjacent", - "optional": false, - "description": "Only relevant for range columns. Match only rows where `column` is mutually exclusive to `range` and there can be no element between the two ranges.", - "type": null - }, - { - "name": "rangeGt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is greater than any element in `range`.", - "type": null - }, - { - "name": "rangeGte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or greater than any element in `range`.", - "type": null - }, - { - "name": "rangeLt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is less than any element in `range`.", - "type": null - }, - { - "name": "rangeLte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or less than any element in `range`.", - "type": null - }, - { - "name": "regexIMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-insensitively (using the `~*` operator).", - "type": null - }, - { - "name": "regexMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-sensitively (using the `~` operator).", - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "textSearch", - "optional": false, - "description": "Only relevant for text and tsvector columns. Match only rows where `column` matches the query string in `query`.", - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Updating your data", - "code": "const { error } = await supabase\n .from('instruments')\n .update({ name: 'piano' })\n .eq('id', 1)", - "sql": "create table\n instruments (id int8 primary key, name text);\n\ninsert into\n instruments (id, name)\nvalues\n (1, 'harpsichord');", - "response": "{\n \"status\": 204,\n \"statusText\": \"No Content\"\n}", - "notes": "Updating JSON data\nPostgres offers some\n[operators](/docs/guides/database/json#query-the-jsonb-data) for\nworking with JSON data. Currently, it is only possible to update the entire JSON document." - }, - { - "title": "Update a record and return it", - "code": "const { data, error } = await supabase\n .from('instruments')\n .update({ name: 'piano' })\n .eq('id', 1)\n .select()", - "sql": "create table\n instruments (id int8 primary key, name text);\n\ninsert into\n instruments (id, name)\nvalues\n (1, 'harpsichord');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"piano\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - }, - { - "title": "Updating JSON data", - "code": "const { data, error } = await supabase\n .from('users')\n .update({\n address: {\n street: 'Melrose Place',\n postcode: 90210\n }\n })\n .eq('address->postcode', 90210)\n .select()", - "sql": "create table\n users (\n id int8 primary key,\n name text,\n address jsonb\n );\n\ninsert into\n users (id, name, address)\nvalues\n (1, 'Michael', '{ \"postcode\": 90210 }');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Michael\",\n \"address\": {\n \"street\": \"Melrose Place\",\n \"postcode\": 90210\n }\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Postgres offers some\n[operators](/docs/guides/database/json#query-the-jsonb-data) for\nworking with JSON data. Currently, it is only possible to update the entire JSON document." - } - ] - }, - { - "name": "upsert", - "description": "Perform an UPSERT on the table or view. Depending on the column(s) passed to `onConflict`, `.upsert()` allows you to perform the equivalent of `.insert()` if a row with the corresponding `onConflict` columns doesn't exist, or if it does exist, perform an alternative action depending on `ignoreDuplicates`.\nBy default, upserted rows are not returned. To return it, chain the call with `.select()`.", - "remarks": [ - "- Primary keys must be included in `values` to use upsert." - ], - "parameters": [ - { - "name": "values", - "type": { - "kind": "typeParam", - "name": "Row" - } - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "count", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "exact" - }, - { - "kind": "literal", - "value": "planned" - }, - { - "kind": "literal", - "value": "estimated" - } - ] - } - }, - { - "name": "ignoreDuplicates", - "optional": true, - "type": "boolean" - }, - { - "name": "onConflict", - "optional": true, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "object", - "name": "PostgrestFilterBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "containedBy", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in `column` is contained by `value`.", - "type": null - }, - { - "name": "contains", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where `column` contains every element appearing in `value`.", - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "eq", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "filter", - "optional": false, - "description": "Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "gt", - "optional": false, - "description": "Match only rows where `column` is greater than `value`.", - "type": null - }, - { - "name": "gte", - "optional": false, - "description": "Match only rows where `column` is greater than or equal to `value`.", - "type": null - }, - { - "name": "ilike", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-insensitively.", - "type": null - }, - { - "name": "ilikeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-insensitively.", - "type": null - }, - { - "name": "ilikeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-insensitively.", - "type": null - }, - { - "name": "in", - "optional": false, - "type": null - }, - { - "name": "is", - "optional": false, - "description": "Match only rows where `column` IS `value`.\nFor non-boolean columns, this is only relevant for checking if the value of `column` is NULL by setting `value` to `null`.\nFor boolean columns, you can also set `value` to `true` or `false` and it will behave the same way as `.eq()`.", - "type": null - }, - { - "name": "isDistinct", - "optional": false, - "type": null - }, - { - "name": "like", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-sensitively.", - "type": null - }, - { - "name": "likeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-sensitively.", - "type": null - }, - { - "name": "likeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-sensitively.", - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "lt", - "optional": false, - "description": "Match only rows where `column` is less than `value`.", - "type": null - }, - { - "name": "lte", - "optional": false, - "description": "Match only rows where `column` is less than or equal to `value`.", - "type": null - }, - { - "name": "match", - "optional": false, - "description": "Match only rows where each column in `query` keys is equal to its associated value. Shorthand for multiple `.eq()`s.", - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "neq", - "optional": false, - "type": null - }, - { - "name": "not", - "optional": false, - "description": "Match only rows which doesn't satisfy the filter.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "notIn", - "optional": false, - "type": null - }, - { - "name": "or", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overlaps", - "optional": false, - "description": "Only relevant for array and range columns. Match only rows where `column` and `value` have an element in common.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "rangeAdjacent", - "optional": false, - "description": "Only relevant for range columns. Match only rows where `column` is mutually exclusive to `range` and there can be no element between the two ranges.", - "type": null - }, - { - "name": "rangeGt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is greater than any element in `range`.", - "type": null - }, - { - "name": "rangeGte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or greater than any element in `range`.", - "type": null - }, - { - "name": "rangeLt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is less than any element in `range`.", - "type": null - }, - { - "name": "rangeLte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or less than any element in `range`.", - "type": null - }, - { - "name": "regexIMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-insensitively (using the `~*` operator).", - "type": null - }, - { - "name": "regexMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-sensitively (using the `~` operator).", - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "textSearch", - "optional": false, - "description": "Only relevant for text and tsvector columns. Match only rows where `column` matches the query string in `query`.", - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Upsert a single row using a unique key", - "code": "// Upserting a single row, overwriting based on the 'username' unique column\nconst { data, error } = await supabase\n .from('users')\n .upsert({ username: 'supabot' }, { onConflict: 'username' })\n\n// Example response:\n// {\n// data: [\n// { id: 4, message: 'bar', username: 'supabot' }\n// ],\n// error: null\n// }", - "sql": "create table\n instruments (id int8 primary key, name text);\n\ninsert into\n instruments (id, name)\nvalues\n (1, 'harpsichord');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"piano\"\n }\n ],\n \"status\": 201,\n \"statusText\": \"Created\"\n}", - "notes": "Upserting into tables with constraints\nIn the following query, `upsert()` implicitly uses the `id`\n(primary key) column to determine conflicts. If there is no existing\nrow with the same `id`, `upsert()` inserts a new row, which\nwill fail in this case as there is already a row with `handle``\"saoirse\"`.\nUsing the `onConflict` option, you can instruct `upsert()` to use\nanother column with a unique constraint to determine conflicts." - }, - { - "title": "Upsert with conflict resolution and exact row counting", - "code": "// Upserting and returning exact count\nconst { data, error, count } = await supabase\n .from('users')\n .upsert(\n {\n id: 3,\n message: 'foo',\n username: 'supabot'\n },\n {\n onConflict: 'username',\n count: 'exact'\n }\n )\n\n// Example response:\n// {\n// data: [\n// {\n// id: 42,\n// handle: \"saoirse\",\n// display_name: \"Saoirse\"\n// }\n// ],\n// count: 1,\n// error: null\n// }", - "sql": "create table\n instruments (id int8 primary key, name text);\n\ninsert into\n instruments (id, name)\nvalues\n (1, 'harpsichord');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"piano\"\n },\n {\n \"id\": 2,\n \"name\": \"harp\"\n }\n ],\n \"status\": 201,\n \"statusText\": \"Created\"\n}" - }, - { - "title": "Upsert your data", - "code": "const { data, error } = await supabase\n .from('instruments')\n .upsert({ id: 1, name: 'piano' })\n .select()", - "sql": "create table\n instruments (id int8 primary key, name text);\n\ninsert into\n instruments (id, name)\nvalues\n (1, 'harpsichord');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"piano\"\n }\n ],\n \"status\": 201,\n \"statusText\": \"Created\"\n}" - }, - { - "title": "Bulk Upsert your data", - "code": "const { data, error } = await supabase\n .from('instruments')\n .upsert([\n { id: 1, name: 'piano' },\n { id: 2, name: 'harp' },\n ])\n .select()", - "sql": "create table\n instruments (id int8 primary key, name text);\n\ninsert into\n instruments (id, name)\nvalues\n (1, 'harpsichord');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"piano\"\n },\n {\n \"id\": 2,\n \"name\": \"harp\"\n }\n ],\n \"status\": 201,\n \"statusText\": \"Created\"\n}" - }, - { - "title": "Upserting into tables with constraints", - "code": "const { data, error } = await supabase\n .from('users')\n .upsert({ id: 42, handle: 'saoirse', display_name: 'Saoirse' })\n .select()", - "sql": "create table\n users (\n id int8 generated by default as identity primary key,\n handle text not null unique,\n display_name text\n );\n\ninsert into\n users (id, handle, display_name)\nvalues\n (1, 'saoirse', null);", - "response": "{\n \"error\": {\n \"code\": \"23505\",\n \"details\": \"Key (handle)=(saoirse) already exists.\",\n \"hint\": null,\n \"message\": \"duplicate key value violates unique constraint \\\"users_handle_key\\\"\"\n },\n \"status\": 409,\n \"statusText\": \"Conflict\"\n}", - "notes": "In the following query, `upsert()` implicitly uses the `id`\n(primary key) column to determine conflicts. If there is no existing\nrow with the same `id`, `upsert()` inserts a new row, which\nwill fail in this case as there is already a row with `handle``\"saoirse\"`.\nUsing the `onConflict` option, you can instruct `upsert()` to use\nanother column with a unique constraint to determine conflicts." - } - ] - }, - { - "name": "abortSignal", - "description": "Set the AbortSignal for the fetch request.", - "remarks": [ - "You can use this to set a timeout for the request." - ], - "parameters": [ - { - "name": "signal", - "description": "The AbortSignal to use for the fetch request", - "type": { - "kind": "reference", - "name": "AbortSignal" - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "Aborting requests in-flight", - "code": "const ac = new AbortController()\n\nconst { data, error } = await supabase\n .from('very_big_table')\n .select()\n .abortSignal(ac.signal)\n\n// Abort the request after 100 ms\nsetTimeout(() => ac.abort(), 100)", - "response": "{\n \"error\": {\n \"message\": \"AbortError: The user aborted a request.\",\n \"details\": \"\",\n \"hint\": \"The request was aborted locally via the provided AbortSignal.\",\n \"code\": \"\"\n },\n \"status\": 0,\n \"statusText\": \"\"\n }", - "notes": "You can use an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to abort requests.\nNote that `status` and `statusText` don't mean anything for aborted requests as the request wasn't fulfilled." - }, - { - "title": "Set a timeout", - "code": "const { data, error } = await supabase\n .from('very_big_table')\n .select()\n .abortSignal(AbortSignal.timeout(1000 /* ms */))", - "response": "{\n \"error\": {\n \"message\": \"FetchError: The user aborted a request.\",\n \"details\": \"\",\n \"hint\": \"\",\n \"code\": \"\"\n },\n \"status\": 400,\n \"statusText\": \"Bad Request\"\n }" - } - ] - }, - { - "name": "csv", - "description": "Return `data` as a string in CSV format.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Return data as CSV", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .csv()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": \"id,name\\n1,Luke\\n2,Leia\\n3,Han\",\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "By default, the data is returned in JSON format, but can also be returned as Comma Separated Values." - } - ] - }, - { - "name": "explain", - "description": "Return `data` as the EXPLAIN plan for the query.\nYou need to enable the [db_plan_enabled](https://supabase.com/docs/guides/database/debugging-performance#enabling-explain) setting before using this method.", - "parameters": [ - { - "name": "options", - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "analyze", - "optional": true, - "description": "If `true`, the query will be executed and the actual run time will be returned", - "type": "boolean" - }, - { - "name": "buffers", - "optional": true, - "description": "If `true`, include information on buffer usage", - "type": "boolean" - }, - { - "name": "format", - "optional": true, - "description": "The format of the output, can be `\"text\"` (default) or `\"json\"`", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "text" - }, - { - "kind": "literal", - "value": "json" - } - ] - } - }, - { - "name": "settings", - "optional": true, - "description": "If `true`, include information on configuration parameters that affect query planning", - "type": "boolean" - }, - { - "name": "verbose", - "optional": true, - "description": "If `true`, the query identifier will be returned and `data` will include the output columns of the query", - "type": "boolean" - }, - { - "name": "wal", - "optional": true, - "description": "If `true`, include information on WAL record generation", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - } - ] - }, - "examples": [ - { - "title": "Get the execution plan", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .explain()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "Aggregate (cost=33.34..33.36 rows=1 width=112)\n -> Limit (cost=0.00..18.33 rows=1000 width=40)\n -> Seq Scan on characters (cost=0.00..22.00 rows=1200 width=40)", - "notes": "By default, the data is returned in TEXT format, but can also be returned as JSON by using the `format` parameter." - }, - { - "title": "Get the execution plan with analyze and verbose", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .explain({analyze:true,verbose:true})", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "Aggregate (cost=33.34..33.36 rows=1 width=112) (actual time=0.041..0.041 rows=1 loops=1)\n Output: NULL::bigint, count(ROW(characters.id, characters.name)), COALESCE(json_agg(ROW(characters.id, characters.name)), '[]'::json), NULLIF(current_setting('response.headers'::text, true), ''::text), NULLIF(current_setting('response.status'::text, true), ''::text)\n -> Limit (cost=0.00..18.33 rows=1000 width=40) (actual time=0.005..0.006 rows=3 loops=1)\n Output: characters.id, characters.name\n -> Seq Scan on public.characters (cost=0.00..22.00 rows=1200 width=40) (actual time=0.004..0.005 rows=3 loops=1)\n Output: characters.id, characters.name\nQuery Identifier: -4730654291623321173\nPlanning Time: 0.407 ms\nExecution Time: 0.119 ms", - "notes": "By default, the data is returned in TEXT format, but can also be returned as JSON by using the `format` parameter." - } - ] - }, - { - "name": "geojson", - "description": "Return `data` as an object in [GeoJSON](https://geojson.org) format.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "limit", - "description": "Limit the query result by `count`.", - "parameters": [ - { - "name": "count", - "description": "The maximum number of rows to return", - "type": "number" - }, - { - "name": "options", - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "foreignTable", - "optional": true, - "description": "Deprecated, use `options.referencedTable` instead", - "type": "string" - }, - { - "name": "referencedTable", - "optional": true, - "description": "Set this to limit rows of referenced tables instead of the parent table", - "type": "string" - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('name')\n .limit(1)", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"name\": \"Luke\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - }, - { - "title": "On a referenced table", - "code": "const { data, error } = await supabase\n .from('orchestral_sections')\n .select(`\n name,\n instruments (\n name\n )\n `)\n .limit(1, { referencedTable: 'instruments' })", - "sql": "create table\n orchestral_sections (id int8 primary key, name text);\ncreate table\n instruments (\n id int8 primary key,\n section_id int8 not null references orchestral_sections,\n name text\n );\n\ninsert into\n orchestral_sections (id, name)\nvalues\n (1, 'strings');\ninsert into\n instruments (id, section_id, name)\nvalues\n (1, 1, 'harp'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"strings\",\n \"instruments\": [\n {\n \"name\": \"violin\"\n }\n ]\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "maxAffected", - "description": "Set the maximum number of rows that can be affected by the query. Only available in PostgREST v13+ and only works with PATCH and DELETE methods.", - "parameters": [ - { - "name": "value", - "description": "The maximum number of rows that can be affected", - "type": "number" - } - ], - "returnType": { - "kind": "conditional" - } - }, - { - "name": "maybeSingle", - "description": "Return `data` as a single object instead of an array of objects.\nQuery result must be zero or one row (e.g. using `.limit(1)`), otherwise this returns an error.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select()\n .eq('name', 'Katniss')\n .maybeSingle()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "order", - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "parameters": [ - { - "name": "column", - "type": { - "kind": "typeParam", - "name": "ColumnName" - } - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "ascending", - "optional": true, - "type": "boolean" - }, - { - "name": "nullsFirst", - "optional": true, - "type": "boolean" - }, - { - "name": "referencedTable", - "optional": true, - "type": "undefined" - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('id, name')\n .order('id', { ascending: false })", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 3,\n \"name\": \"Han\"\n },\n {\n \"id\": 2,\n \"name\": \"Leia\"\n },\n {\n \"id\": 1,\n \"name\": \"Luke\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "On a referenced table\nOrdering with `referencedTable` doesn't affect the ordering of the\nparent table." - }, - { - "title": "On a referenced table", - "code": "const { data, error } = await supabase\n .from('orchestral_sections')\n .select(`\n name,\n instruments (\n name\n )\n `)\n .order('name', { referencedTable: 'instruments', ascending: false })", - "sql": "create table\n orchestral_sections (id int8 primary key, name text);\ncreate table\n instruments (\n id int8 primary key,\n section_id int8 not null references orchestral_sections,\n name text\n );\n\ninsert into\n orchestral_sections (id, name)\nvalues\n (1, 'strings'),\n (2, 'woodwinds');\ninsert into\n instruments (id, section_id, name)\nvalues\n (1, 1, 'harp'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"strings\",\n \"instruments\": [\n {\n \"name\": \"violin\"\n },\n {\n \"name\": \"harp\"\n }\n ]\n },\n {\n \"name\": \"woodwinds\",\n \"instruments\": []\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Ordering with `referencedTable` doesn't affect the ordering of the\nparent table." - }, - { - "title": "Order parent table by a referenced table", - "code": "const { data, error } = await supabase\n .from('instruments')\n .select(`\n name,\n section:orchestral_sections (\n name\n )\n `)\n .order('section(name)', { ascending: true })", - "sql": "create table\n orchestral_sections (id int8 primary key, name text);\ncreate table\n instruments (\n id int8 primary key,\n section_id int8 not null references orchestral_sections,\n name text\n );\n\ninsert into\n orchestral_sections (id, name)\nvalues\n (1, 'strings'),\n (2, 'woodwinds');\ninsert into\n instruments (id, section_id, name)\nvalues\n (1, 2, 'flute'),\n (2, 1, 'violin');", - "response": "{\n \"data\": [\n {\n \"name\": \"violin\",\n \"orchestral_sections\": {\"name\": \"strings\"}\n },\n {\n \"name\": \"flute\",\n \"orchestral_sections\": {\"name\": \"woodwinds\"}\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}", - "notes": "Ordering with `referenced_table(col)` affects the ordering of the\nparent table." - } - ] - }, - { - "name": "overrideTypes", - "description": "Override the type of the returned `data` field in the response.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Example 1", - "code": "// Merge with existing types (default behavior)\nconst query = supabase\n .from('users')\n .select()\n .overrideTypes<{ custom_field: string }>()\n\n// Replace existing types completely\nconst replaceQuery = supabase\n .from('users')\n .select()\n .overrideTypes<{ id: number; name: string }, { merge: false }>()", - "response": "let x: typeof data // MyType[]" - }, - { - "title": "Complete Override type of successful response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .overrideTypes, { merge: false }>()", - "response": "let x: typeof data // MyType[]" - }, - { - "title": "Complete Override type of object response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .maybeSingle()\n .overrideTypes()", - "response": "let x: typeof data // MyType | null" - }, - { - "title": "Partial Override type of successful response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .overrideTypes>()", - "response": "let x: typeof data // Array" - }, - { - "title": "Partial Override type of object response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .maybeSingle()\n .overrideTypes<{ status: \"A\" | \"B\" }>()", - "response": "let x: typeof data // CountryRowProperties & { status: \"A\" | \"B\" } | null" - }, - { - "title": "Example 5", - "code": "// Merge with existing types (default behavior)\nconst query = supabase\n .from('users')\n .select()\n .overrideTypes<{ custom_field: string }>()\n\n// Replace existing types completely\nconst replaceQuery = supabase\n .from('users')\n .select()\n .overrideTypes<{ id: number; name: string }, { merge: false }>()" - } - ] - }, - { - "name": "range", - "description": "Limit the query result by starting at an offset `from` and ending at the offset `to`. Only records within this range are returned. This respects the query order and if there is no order clause the range could behave unexpectedly. The `from` and `to` values are 0-based and inclusive: `range(1, 3)` will include the second, third and fourth rows of the query.", - "parameters": [ - { - "name": "from", - "description": "The starting index from which to limit the result", - "type": "number" - }, - { - "name": "to", - "description": "The last index to which to limit the result", - "type": "number" - }, - { - "name": "options", - "description": "Named parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "foreignTable", - "optional": true, - "description": "Deprecated, use `options.referencedTable` instead", - "type": "string" - }, - { - "name": "referencedTable", - "optional": true, - "description": "Set this to limit rows of referenced tables instead of the parent table", - "type": "string" - } - ] - } - } - ], - "returnType": "this", - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('name')\n .range(0, 1)", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": [\n {\n \"name\": \"Luke\"\n },\n {\n \"name\": \"Leia\"\n }\n ],\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "returns", - "description": "Override the type of the returned `data`.", - "remarks": [ - "- Deprecated: use overrideTypes method instead" - ], - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestTransformBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Override type of successful response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .returns>()", - "response": "let x: typeof data // MyType[]" - }, - { - "title": "Override type of object response", - "code": "const { data } = await supabase\n .from('countries')\n .select()\n .maybeSingle()\n .returns()", - "response": "let x: typeof data // MyType | null" - } - ] - }, - { - "name": "rollback", - "description": "Rollback the query.\n`data` will still be returned, but the query is not committed.", - "parameters": [], - "returnType": "this" - }, - { - "name": "select", - "description": "Perform a SELECT on the query result.\nBy default, `.insert()`, `.update()`, `.upsert()`, and `.delete()` do not return modified rows. By calling this method, modified rows are returned in `data`.", - "parameters": [ - { - "name": "columns", - "optional": true, - "description": "The columns to retrieve, separated by commas", - "type": { - "kind": "typeParam", - "name": "Query" - } - } - ], - "returnType": { - "kind": "object", - "name": "PostgrestFilterBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "containedBy", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in `column` is contained by `value`.", - "type": null - }, - { - "name": "contains", - "optional": false, - "description": "Only relevant for jsonb, array, and range columns. Match only rows where `column` contains every element appearing in `value`.", - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "eq", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "filter", - "optional": false, - "description": "Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "gt", - "optional": false, - "description": "Match only rows where `column` is greater than `value`.", - "type": null - }, - { - "name": "gte", - "optional": false, - "description": "Match only rows where `column` is greater than or equal to `value`.", - "type": null - }, - { - "name": "ilike", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-insensitively.", - "type": null - }, - { - "name": "ilikeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-insensitively.", - "type": null - }, - { - "name": "ilikeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-insensitively.", - "type": null - }, - { - "name": "in", - "optional": false, - "type": null - }, - { - "name": "is", - "optional": false, - "description": "Match only rows where `column` IS `value`.\nFor non-boolean columns, this is only relevant for checking if the value of `column` is NULL by setting `value` to `null`.\nFor boolean columns, you can also set `value` to `true` or `false` and it will behave the same way as `.eq()`.", - "type": null - }, - { - "name": "isDistinct", - "optional": false, - "type": null - }, - { - "name": "like", - "optional": false, - "description": "Match only rows where `column` matches `pattern` case-sensitively.", - "type": null - }, - { - "name": "likeAllOf", - "optional": false, - "description": "Match only rows where `column` matches all of `patterns` case-sensitively.", - "type": null - }, - { - "name": "likeAnyOf", - "optional": false, - "description": "Match only rows where `column` matches any of `patterns` case-sensitively.", - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "lt", - "optional": false, - "description": "Match only rows where `column` is less than `value`.", - "type": null - }, - { - "name": "lte", - "optional": false, - "description": "Match only rows where `column` is less than or equal to `value`.", - "type": null - }, - { - "name": "match", - "optional": false, - "description": "Match only rows where each column in `query` keys is equal to its associated value. Shorthand for multiple `.eq()`s.", - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "neq", - "optional": false, - "type": null - }, - { - "name": "not", - "optional": false, - "description": "Match only rows which doesn't satisfy the filter.\nUnlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized.", - "type": null - }, - { - "name": "notIn", - "optional": false, - "type": null - }, - { - "name": "or", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overlaps", - "optional": false, - "description": "Only relevant for array and range columns. Match only rows where `column` and `value` have an element in common.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "rangeAdjacent", - "optional": false, - "description": "Only relevant for range columns. Match only rows where `column` is mutually exclusive to `range` and there can be no element between the two ranges.", - "type": null - }, - { - "name": "rangeGt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is greater than any element in `range`.", - "type": null - }, - { - "name": "rangeGte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or greater than any element in `range`.", - "type": null - }, - { - "name": "rangeLt", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is less than any element in `range`.", - "type": null - }, - { - "name": "rangeLte", - "optional": false, - "description": "Only relevant for range columns. Match only rows where every element in `column` is either contained in `range` or less than any element in `range`.", - "type": null - }, - { - "name": "regexIMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-insensitively (using the `~*` operator).", - "type": null - }, - { - "name": "regexMatch", - "optional": false, - "description": "Match only rows where `column` matches the PostgreSQL regex `pattern` case-sensitively (using the `~` operator).", - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "textSearch", - "optional": false, - "description": "Only relevant for text and tsvector columns. Match only rows where `column` matches the query string in `query`.", - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "With `upsert()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .upsert({ id: 1, name: 'Han Solo' })\n .select()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Han');", - "response": "{\n \"data\": [\n {\n \"id\": 1,\n \"name\": \"Han Solo\"\n }\n ],\n \"status\": 201,\n \"statusText\": \"Created\"\n}" - } - ] - }, - { - "name": "setHeader", - "description": "Set an HTTP header for the request.", - "parameters": [ - { - "name": "name", - "type": "string" - }, - { - "name": "value", - "type": "string" - } - ], - "returnType": "this" - }, - { - "name": "single", - "description": "Return `data` as a single object instead of an array of objects.\nQuery result must be one row (e.g. using `.limit(1)`), otherwise this returns an error.", - "parameters": [], - "returnType": { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "With `select()`", - "code": "const { data, error } = await supabase\n .from('characters')\n .select('name')\n .limit(1)\n .single()", - "sql": "create table\n characters (id int8 primary key, name text);\n\ninsert into\n characters (id, name)\nvalues\n (1, 'Luke'),\n (2, 'Leia'),\n (3, 'Han');", - "response": "{\n \"data\": {\n \"name\": \"Luke\"\n },\n \"status\": 200,\n \"statusText\": \"OK\"\n}" - } - ] - }, - { - "name": "then", - "description": "", - "parameters": [ - { - "name": "onfulfilled", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "onrejected", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "PromiseLike", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "typeParam", - "name": "TResult1" - }, - { - "kind": "typeParam", - "name": "TResult2" - } - ] - } - ] - } - }, - { - "name": "throwOnError", - "description": "If there's an error with the query, throwOnError will reject the promise by throwing the error instead of returning it as part of a successful response.\nhttps://github.com/supabase/supabase-js/issues/92", - "parameters": [], - "returnType": { - "kind": "intersection", - "types": [ - { - "kind": "object", - "name": "PostgrestTransformBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "abortSignal", - "optional": false, - "type": null - }, - { - "name": "csv", - "optional": false, - "type": null - }, - { - "name": "explain", - "optional": false, - "type": null - }, - { - "name": "geojson", - "optional": false, - "type": null - }, - { - "name": "limit", - "optional": false, - "type": null - }, - { - "name": "maxAffected", - "optional": false, - "type": null - }, - { - "name": "maybeSingle", - "optional": false, - "type": null - }, - { - "name": "order", - "optional": false, - "description": "Order the query result by `column`.\nYou can call this method multiple times to order by multiple columns.\nYou can order referenced tables, but it only affects the ordering of the parent table if you use `!inner` in the query.", - "type": null - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "range", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "rollback", - "optional": false, - "type": null - }, - { - "name": "select", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "single", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - { - "kind": "object", - "name": "PostgrestBuilder", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "body", - "optional": true, - "type": "unknown" - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": false, - "type": { - "kind": "reference", - "name": "Headers" - } - }, - { - "name": "isMaybeSingle", - "optional": false, - "type": "boolean" - }, - { - "name": "method", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "HEAD" - }, - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "schema", - "optional": true, - "type": "string" - }, - { - "name": "shouldThrowOnError", - "optional": false, - "type": "boolean" - }, - { - "name": "signal", - "optional": true, - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "reference", - "name": "URL" - } - }, - { - "name": "urlLengthLimit", - "optional": false, - "type": "number" - }, - { - "name": "overrideTypes", - "optional": false, - "type": null - }, - { - "name": "returns", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - } - ] - } - } - ] - }, - { - "category": "Auth", - "definitions": [ - { - "name": "createUser", - "description": "Creates a new user. This function should only be called on a server. Never expose your `service_role` key in the browser.", - "remarks": [ - "- To confirm the user's email address or phone number, set `email_confirm` or `phone_confirm` to true. Both arguments default to false. - `createUser()` will not send a confirmation email to the user. You can use [`inviteUserByEmail()`](/docs/reference/javascript/auth-admin-inviteuserbyemail) if you want to send them an email invite instead. - If you are sure that the created user's email or phone number is legitimate and verified, you can set the `email_confirm` or `phone_confirm` param to `true`." - ], - "parameters": [ - { - "name": "attributes", - "type": { - "kind": "object", - "name": "AdminUserAttributes", - "properties": [ - { - "name": "app_metadata", - "optional": true, - "description": "A custom data object to store the user's application specific metadata. This maps to the `auth.users.app_metadata` column.\nOnly a service role can modify.\nThe `app_metadata` should be a JSON object that includes app-specific info, such as identity providers, roles, and other access control information.", - "type": "object" - }, - { - "name": "ban_duration", - "optional": true, - "description": "Determines how long a user is banned for.\nThe format for the ban duration follows a strict sequence of decimal numbers with a unit suffix. Valid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\".\nFor example, some possible durations include: '300ms', '2h45m'.\nSetting the ban duration to 'none' lifts the ban on the user.", - "type": "string" - }, - { - "name": "current_password", - "optional": true, - "description": "The user's current password\nThis is only ever present when the user is resetting their password and GOTRUE_SECURITY_UPDATE_PASSWORD_REQUIRE_CURRENT_PASSWORD is true.", - "type": "string" - }, - { - "name": "email", - "optional": true, - "description": "The user's email.", - "type": "string" - }, - { - "name": "email_confirm", - "optional": true, - "description": "Sets the user's email as confirmed when true, or unconfirmed when false.\nOnly a service role can modify.", - "type": "boolean" - }, - { - "name": "id", - "optional": true, - "description": "The `id` for the user.\nAllows you to overwrite the default `id` set for the user.", - "type": "string" - }, - { - "name": "nonce", - "optional": true, - "description": "The nonce sent for reauthentication if the user's password is to be updated.\nCall reauthenticate() to obtain the nonce first.", - "type": "string" - }, - { - "name": "password", - "optional": true, - "description": "The user's password.", - "type": "string" - }, - { - "name": "password_hash", - "optional": true, - "description": "The `password_hash` for the user's password.\nAllows you to specify a password hash for the user. This is useful for migrating a user's password hash from another service.\nSupports bcrypt, scrypt (firebase), and argon2 password hashes.", - "type": "string" - }, - { - "name": "phone", - "optional": true, - "description": "The user's phone.", - "type": "string" - }, - { - "name": "phone_confirm", - "optional": true, - "description": "Sets the user's phone as confirmed when true, or unconfirmed when false.\nOnly a service role can modify.", - "type": "boolean" - }, - { - "name": "role", - "optional": true, - "description": "The `role` claim set in the user's access token JWT.\nWhen a user signs up, this role is set to `authenticated` by default. You should only modify the `role` if you need to provision several levels of admin access that have different permissions on individual columns in your database.\nSetting this role to `service_role` is not recommended as it grants the user admin privileges.", - "type": "string" - }, - { - "name": "user_metadata", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `user_metadata` should be a JSON object that includes user-specific info, such as their first and last name.\nNote: When using the GoTrueAdminApi and wanting to modify a user's metadata, this attribute is used instead of UserAttributes data.", - "type": "object" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "With custom user metadata", - "code": "const { data, error } = await supabase.auth.admin.createUser({\n email: 'user@email.com',\n password: 'password',\n user_metadata: { name: 'Yoda' }\n})", - "response": "{\n data: {\n user: {\n id: '1',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com',\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {},\n user_metadata: {},\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"1\",\n \"user_id\": \"1\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"phone_verified\": false,\n \"sub\": \"1\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false,\n }\n }\n error: null\n}" - }, - { - "title": "Auto-confirm the user's email", - "code": "const { data, error } = await supabase.auth.admin.createUser({\n email: 'user@email.com',\n email_confirm: true\n})" - }, - { - "title": "Auto-confirm the user's phone number", - "code": "const { data, error } = await supabase.auth.admin.createUser({\n phone: '1234567890',\n phone_confirm: true\n})" - } - ] - }, - { - "name": "deleteUser", - "description": "Delete a user. Requires a `service_role` key.", - "remarks": [ - "- The `deleteUser()` method requires the user's ID, which maps to the `auth.users.id` column." - ], - "parameters": [ - { - "name": "id", - "description": "The user id you want to remove.", - "type": "string" - }, - { - "name": "shouldSoftDelete", - "description": "If true, then the user will be soft-deleted from the auth schema. Soft deletion allows user identification from the hashed user ID but is not reversible. Defaults to false for backward compatibility.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "type": "boolean" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Removes a user", - "code": "const { data, error } = await supabase.auth.admin.deleteUser(\n '715ed5db-f090-4b8c-a067-640ecee36aa0'\n)", - "response": "{\n \"data\": {\n \"user\": {}\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "generateLink", - "description": "Generates email links and OTPs to be sent via a custom email provider.", - "remarks": [ - "- 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`." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "reference", - "name": "Pick", - "typeArguments": [ - { - "kind": "object", - "name": "GenerateLinkOptions", - "properties": [ - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL which will be appended to the email link generated.", - "type": "string" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "data" - }, - { - "kind": "literal", - "value": "redirectTo" - } - ] - } - ] - } - }, - { - "name": "password", - "optional": false, - "type": "string" - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "literal", - "value": "signup" - } - } - ], - "name": "GenerateSignupLinkParams" - }, - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "description": "The user's email", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "reference", - "name": "Pick", - "typeArguments": [ - { - "kind": "object", - "name": "GenerateLinkOptions", - "properties": [ - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL which will be appended to the email link generated.", - "type": "string" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "data" - }, - { - "kind": "literal", - "value": "redirectTo" - } - ] - } - ] - } - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "invite" - }, - { - "kind": "literal", - "value": "magiclink" - } - ] - } - } - ], - "name": "GenerateInviteOrMagiclinkParams" - }, - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "description": "The user's email", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "reference", - "name": "Pick", - "typeArguments": [ - { - "kind": "object", - "name": "GenerateLinkOptions", - "properties": [ - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL which will be appended to the email link generated.", - "type": "string" - } - ] - }, - { - "kind": "literal", - "value": "redirectTo" - } - ] - } - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "literal", - "value": "recovery" - } - } - ], - "name": "GenerateRecoveryLinkParams" - }, - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "description": "The user's email", - "type": "string" - }, - { - "name": "newEmail", - "optional": false, - "description": "The user's new email. Only required if type is 'email_change_current' or 'email_change_new'.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "reference", - "name": "Pick", - "typeArguments": [ - { - "kind": "object", - "name": "GenerateLinkOptions", - "properties": [ - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL which will be appended to the email link generated.", - "type": "string" - } - ] - }, - { - "kind": "literal", - "value": "redirectTo" - } - ] - } - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "email_change_current" - }, - { - "kind": "literal", - "value": "email_change_new" - } - ] - } - } - ], - "name": "GenerateEmailChangeLinkParams" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "properties", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "action_link", - "optional": false, - "description": "The email link to send to the user. The action_link follows the following format: auth/v1/verify?type={verification_type}&token={hashed_token}&redirect_to={redirect_to}", - "type": "string" - }, - { - "name": "email_otp", - "optional": false, - "description": "The raw email OTP. You should send this in the email if you want your users to verify using an OTP instead of the action link.", - "type": "string" - }, - { - "name": "hashed_token", - "optional": false, - "description": "The hashed token appended to the action link.", - "type": "string" - }, - { - "name": "redirect_to", - "optional": false, - "description": "The URL appended to the action link.", - "type": "string" - }, - { - "name": "verification_type", - "optional": false, - "description": "The verification type that the email link is associated to.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "signup" - }, - { - "kind": "literal", - "value": "invite" - }, - { - "kind": "literal", - "value": "magiclink" - }, - { - "kind": "literal", - "value": "recovery" - }, - { - "kind": "literal", - "value": "email_change_current" - }, - { - "kind": "literal", - "value": "email_change_new" - } - ] - } - } - ], - "name": "GenerateLinkProperties" - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Generate a signup link", - "code": "const { data, error } = await supabase.auth.admin.generateLink({\n type: 'signup',\n email: 'email@example.com',\n password: 'secret'\n})", - "response": "{\n \"data\": {\n \"properties\": {\n \"action_link\": \"\",\n \"email_otp\": \"999999\",\n \"hashed_token\": \"\",\n \"verification_type\": \"signup\"\n },\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"email@example.com\",\n \"phone\": \"\",\n \"confirmation_sent_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"email@example.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}" - }, - { - "title": "Generate an invite link", - "code": "const { data, error } = await supabase.auth.admin.generateLink({\n type: 'invite',\n email: 'email@example.com'\n})" - }, - { - "title": "Generate a magic link", - "code": "const { data, error } = await supabase.auth.admin.generateLink({\n type: 'magiclink',\n email: 'email@example.com'\n})" - }, - { - "title": "Generate a recovery link", - "code": "const { data, error } = await supabase.auth.admin.generateLink({\n type: 'recovery',\n email: 'email@example.com'\n})" - }, - { - "title": "Generate links to change current email address", - "code": "// generate an email change link to be sent to the current email address\nconst { data, error } = await supabase.auth.admin.generateLink({\n type: 'email_change_current',\n email: 'current.email@example.com',\n newEmail: 'new.email@example.com'\n})\n\n// generate an email change link to be sent to the new email address\nconst { data, error } = await supabase.auth.admin.generateLink({\n type: 'email_change_new',\n email: 'current.email@example.com',\n newEmail: 'new.email@example.com'\n})" - } - ] - }, - { - "name": "getUserById", - "description": "Get user by id.", - "remarks": [ - "- Fetches the user object from the database based on the user's id. - The `getUserById()` method requires the user's id which maps to the `auth.users.id` column." - ], - "parameters": [ - { - "name": "uid", - "description": "The user's unique identifier\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Fetch the user object using the access_token jwt", - "code": "const { data, error } = await supabase.auth.admin.getUserById(1)", - "response": "{\n data: {\n user: {\n id: '1',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com',\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {},\n user_metadata: {},\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"1\",\n \"user_id\": \"1\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"phone_verified\": false,\n \"sub\": \"1\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false,\n }\n }\n error: null\n}" - } - ] - }, - { - "name": "inviteUserByEmail", - "description": "Sends an invite link to an email address.", - "remarks": [ - "- Sends an invite link to the user's email address. - The `inviteUserByEmail()` method is typically used by administrators to invite users to join the application. - Note that PKCE is not supported when using `inviteUserByEmail`. This is because the browser initiating the invite is often different from the browser accepting the invite which makes it difficult to provide the security guarantees required of the PKCE flow." - ], - "parameters": [ - { - "name": "email", - "description": "The email address of the user.", - "type": "string" - }, - { - "name": "options", - "description": "Additional options to be included when inviting.", - "type": { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": true, - "description": "A custom data object to store additional metadata about the user. This maps to the `auth.users.user_metadata` column.", - "type": "object" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL which will be appended to the email link sent to the user's email address. Once clicked the user will end up on this URL.", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Invite a user", - "code": "const { data, error } = await supabase.auth.admin.inviteUserByEmail('email@example.com')", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"invited_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmation_sent_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "listUsers", - "description": "Get a list of users.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "remarks": [ - "- Defaults to return 50 users per page." - ], - "parameters": [ - { - "name": "params", - "optional": true, - "description": "An object which supports `page` and `perPage` as numbers, to alter the paginated results.", - "type": { - "kind": "object", - "properties": [ - { - "name": "page", - "optional": true, - "description": "The page number", - "type": "number" - }, - { - "name": "perPage", - "optional": true, - "description": "Number of items returned per page", - "type": "number" - } - ], - "name": "PageParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "intersection", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "users", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "lastPage", - "optional": false, - "type": "number" - }, - { - "name": "nextPage", - "optional": false, - "type": { - "kind": "union", - "types": [ - "number", - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "total", - "optional": false, - "type": "number" - } - ], - "name": "Pagination" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "users", - "optional": false, - "type": { - "kind": "tuple", - "elements": [] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get a page of users", - "code": "const { data: { users }, error } = await supabase.auth.admin.listUsers()" - }, - { - "title": "Paginated list of users", - "code": "const { data: { users }, error } = await supabase.auth.admin.listUsers({\n page: 1,\n perPage: 1000\n})" - } - ] - }, - { - "name": "signOut", - "description": "Removes a logged-in session.", - "parameters": [ - { - "name": "jwt", - "description": "A valid, logged-in JWT.", - "type": "string" - }, - { - "name": "scope", - "description": "The logout sope.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "global" - }, - { - "kind": "literal", - "value": "local" - }, - { - "kind": "literal", - "value": "others" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - ] - } - } - ] - } - ] - } - }, - { - "name": "updateUserById", - "description": "Updates the user data. Changes are applied directly without confirmation flows.", - "remarks": [ - "**Important:** This is a server-side operation and does **not** trigger client-side `onAuthStateChange` listeners. The admin API has no connection to client state.\nTo sync changes to the client after calling this method: 1. On the client, call `supabase.auth.refreshSession()` to fetch the updated user data 2. This will trigger the `TOKEN_REFRESHED` event and notify all listeners" - ], - "parameters": [ - { - "name": "uid", - "description": "The user's unique identifier", - "type": "string" - }, - { - "name": "attributes", - "description": "The data you want to update.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "type": { - "kind": "object", - "name": "AdminUserAttributes", - "properties": [ - { - "name": "app_metadata", - "optional": true, - "description": "A custom data object to store the user's application specific metadata. This maps to the `auth.users.app_metadata` column.\nOnly a service role can modify.\nThe `app_metadata` should be a JSON object that includes app-specific info, such as identity providers, roles, and other access control information.", - "type": "object" - }, - { - "name": "ban_duration", - "optional": true, - "description": "Determines how long a user is banned for.\nThe format for the ban duration follows a strict sequence of decimal numbers with a unit suffix. Valid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\".\nFor example, some possible durations include: '300ms', '2h45m'.\nSetting the ban duration to 'none' lifts the ban on the user.", - "type": "string" - }, - { - "name": "current_password", - "optional": true, - "description": "The user's current password\nThis is only ever present when the user is resetting their password and GOTRUE_SECURITY_UPDATE_PASSWORD_REQUIRE_CURRENT_PASSWORD is true.", - "type": "string" - }, - { - "name": "email", - "optional": true, - "description": "The user's email.", - "type": "string" - }, - { - "name": "email_confirm", - "optional": true, - "description": "Sets the user's email as confirmed when true, or unconfirmed when false.\nOnly a service role can modify.", - "type": "boolean" - }, - { - "name": "id", - "optional": true, - "description": "The `id` for the user.\nAllows you to overwrite the default `id` set for the user.", - "type": "string" - }, - { - "name": "nonce", - "optional": true, - "description": "The nonce sent for reauthentication if the user's password is to be updated.\nCall reauthenticate() to obtain the nonce first.", - "type": "string" - }, - { - "name": "password", - "optional": true, - "description": "The user's password.", - "type": "string" - }, - { - "name": "password_hash", - "optional": true, - "description": "The `password_hash` for the user's password.\nAllows you to specify a password hash for the user. This is useful for migrating a user's password hash from another service.\nSupports bcrypt, scrypt (firebase), and argon2 password hashes.", - "type": "string" - }, - { - "name": "phone", - "optional": true, - "description": "The user's phone.", - "type": "string" - }, - { - "name": "phone_confirm", - "optional": true, - "description": "Sets the user's phone as confirmed when true, or unconfirmed when false.\nOnly a service role can modify.", - "type": "boolean" - }, - { - "name": "role", - "optional": true, - "description": "The `role` claim set in the user's access token JWT.\nWhen a user signs up, this role is set to `authenticated` by default. You should only modify the `role` if you need to provision several levels of admin access that have different permissions on individual columns in your database.\nSetting this role to `service_role` is not recommended as it grants the user admin privileges.", - "type": "string" - }, - { - "name": "user_metadata", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `user_metadata` should be a JSON object that includes user-specific info, such as their first and last name.\nNote: When using the GoTrueAdminApi and wanting to modify a user's metadata, this attribute is used instead of UserAttributes data.", - "type": "object" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Example 1", - "code": "// Server-side (Edge Function)\nconst { data, error } = await supabase.auth.admin.updateUserById(\n userId,\n { user_metadata: { preferences: { theme: 'dark' } } }\n)\n\n// Client-side (to sync the changes)\nconst { data, error } = await supabase.auth.refreshSession()\n// onAuthStateChange listeners will now be notified with updated user", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"new@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"recovery_sent_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}" - }, - { - "title": "Updates a user's email", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '11111111-1111-1111-1111-111111111111',\n { email: 'new@email.com' }\n)", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"new@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"recovery_sent_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}" - }, - { - "title": "Updates a user's password", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { password: 'new_password' }\n)" - }, - { - "title": "Updates a user's metadata", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { user_metadata: { hello: 'world' } }\n)" - }, - { - "title": "Updates a user's app_metadata", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { app_metadata: { plan: 'trial' } }\n)" - }, - { - "title": "Confirms a user's email address", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { email_confirm: true }\n)" - }, - { - "title": "Confirms a user's phone number", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { phone_confirm: true }\n)" - }, - { - "title": "Ban a user for 100 years", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { ban_duration: '876000h' }\n)" - } - ] - }, - { - "name": "exchangeCodeForSession", - "description": "Log in an existing user by exchanging an Auth Code issued during the PKCE flow.", - "remarks": [ - "- Used when `flowType` is set to `pkce` in client options." - ], - "parameters": [ - { - "name": "authCode", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Exchange Auth Code", - "code": "supabase.auth.exchangeCodeForSession('34e770dd-9ff9-416c-87fa-43b31d7ef225')", - "response": "{\n \"data\": {\n session: {\n access_token: '',\n token_type: 'bearer',\n expires_in: 3600,\n expires_at: 1700000000,\n refresh_token: '',\n user: {\n id: '11111111-1111-1111-1111-111111111111',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com'\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {\n \"provider\": \"email\",\n \"providers\": [\n \"email\",\n \"\"\n ]\n },\n user_metadata: {\n email: 'email@email.com',\n email_verified: true,\n full_name: 'User Name',\n iss: '',\n name: 'User Name',\n phone_verified: false,\n provider_id: '',\n sub: ''\n },\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n {\n \"identity_id\": \"33333333-3333-3333-3333-333333333333\",\n \"id\": \"\",\n \"user_id\": \"\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"full_name\": \"User Name\",\n \"iss\": \"\",\n \"name\": \"User Name\",\n \"phone_verified\": false,\n \"provider_id\": \"\",\n \"sub\": \"\"\n },\n \"provider\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false\n },\n provider_token: '',\n provider_refresh_token: ''\n },\n user: {\n id: '11111111-1111-1111-1111-111111111111',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com',\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {\n provider: 'email',\n providers: [\n \"email\",\n \"\"\n ]\n },\n user_metadata: {\n email: 'email@email.com',\n email_verified: true,\n full_name: 'User Name',\n iss: '',\n name: 'User Name',\n phone_verified: false,\n provider_id: '',\n sub: ''\n },\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n {\n \"identity_id\": \"33333333-3333-3333-3333-333333333333\",\n \"id\": \"\",\n \"user_id\": \"\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"full_name\": \"User Name\",\n \"iss\": \"\",\n \"name\": \"User Name\",\n \"phone_verified\": false,\n \"provider_id\": \"\",\n \"sub\": \"\"\n },\n \"provider\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false\n },\n redirectType: null\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "getClaims", - "description": "Extracts the JWT claims present in the access token by first verifying the JWT against the server's JSON Web Key Set endpoint `/.well-known/jwks.json` which is often cached, resulting in significantly faster responses. Prefer this method over #getUser which always sends a request to the Auth server for each JWT.\nIf the project is not using an asymmetric JWT signing key (like ECC or RSA) it always sends a request to the Auth server (similar to #getUser) to verify the JWT.", - "remarks": [ - "- Parses the user's [access token](/docs/guides/auth/sessions#access-token-jwt-claims) as a [JSON Web Token (JWT)](/docs/guides/auth/jwts) and returns its components if valid and not expired. - If your project is using asymmetric JWT signing keys, then the verification is done locally usually without a network request using the [WebCrypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API). - A network request is sent to your project's JWT signing key discovery endpoint `https://project-id.supabase.co/auth/v1/.well-known/jwks.json`, which is cached locally. If your environment is ephemeral, such as a Lambda function that is destroyed after every request, a network request will be sent for each new invocation. Supabase provides a network-edge cache providing fast responses for these situations. - If the user's access token is about to expire when calling this function, the user's session will first be refreshed before validating the JWT. - If your project is using a symmetric secret to sign the JWT, it always sends a request similar to `getUser()` to validate the JWT at the server before returning the decoded token. This is also used if the WebCrypto API is not available in the environment. Make sure you polyfill it in such situations. - The returned claims can be customized per project using the [Custom Access Token Hook](/docs/guides/auth/auth-hooks/custom-access-token-hook)." - ], - "parameters": [ - { - "name": "jwt", - "optional": true, - "description": "An optional specific JWT you wish to verify, not the one you can obtain from #getSession.", - "type": "string" - }, - { - "name": "options", - "description": "Various additional options that allow you to customize the behavior of this method.", - "type": { - "kind": "object", - "properties": [ - { - "name": "allowExpired", - "optional": true, - "description": "If set to `true` the `exp` claim will not be validated against the current time.", - "type": "boolean" - }, - { - "name": "jwks", - "optional": true, - "description": "If set, this JSON Web Key Set is going to have precedence over the cached value available on the server.", - "type": { - "kind": "object", - "properties": [ - { - "name": "keys", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "JWK", - "properties": [ - { - "name": "alg", - "optional": true, - "type": "string" - }, - { - "name": "key_ops", - "optional": false, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "kid", - "optional": true, - "type": "string" - }, - { - "name": "kty", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "RSA" - }, - { - "kind": "literal", - "value": "EC" - }, - { - "kind": "literal", - "value": "oct" - } - ] - } - } - ] - } - } - } - ] - } - }, - { - "name": "keys", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "JWK", - "properties": [ - { - "name": "alg", - "optional": true, - "type": "string" - }, - { - "name": "key_ops", - "optional": false, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "kid", - "optional": true, - "type": "string" - }, - { - "name": "kty", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "RSA" - }, - { - "kind": "literal", - "value": "EC" - }, - { - "kind": "literal", - "value": "oct" - } - ] - } - } - ] - } - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "claims", - "optional": false, - "type": { - "kind": "object", - "name": "JwtPayload", - "properties": [ - { - "name": "aal", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "aal1" - }, - { - "kind": "literal", - "value": "aal2" - } - ] - } - }, - { - "name": "amr", - "optional": true, - "description": "Authentication Method References. Supports both RFC-8176 compliant format (string[]) and detailed format (AMREntry[]). - String format: ['password', 'otp'] - RFC-8176 compliant - Object format: [{ method: 'password', timestamp: 1234567890 }] - includes timestamps", - "type": { - "kind": "union", - "types": [ - { - "kind": "array", - "elementType": "string" - }, - { - "kind": "array", - "elementType": { - "kind": "object", - "name": "AMREntry", - "properties": [ - { - "name": "method", - "optional": false, - "description": "Authentication method name.", - "type": { - "kind": "union", - "types": [ - { - "kind": "indexedAccess", - "objectType": { - "kind": "query" - }, - "indexType": null - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "timestamp", - "optional": false, - "description": "Timestamp when the method was successfully used. Represents number of seconds since 1st January 1970 (UNIX epoch) in UTC.", - "type": "number" - } - ] - } - } - ] - } - }, - { - "name": "app_metadata", - "optional": true, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": { - "kind": "union", - "types": [ - "string", - { - "kind": "array", - "elementType": "string" - } - ] - } - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "exp", - "optional": false, - "type": "number" - }, - { - "name": "iat", - "optional": false, - "type": "number" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "iss", - "optional": false, - "type": "string" - }, - { - "name": "jti", - "optional": true, - "type": "string" - }, - { - "name": "nbf", - "optional": true, - "type": "number" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "ref", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": false, - "type": "string" - }, - { - "name": "session_id", - "optional": false, - "type": "string" - }, - { - "name": "sub", - "optional": false, - "type": "string" - }, - { - "name": "user_metadata", - "optional": true, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - }, - { - "name": "header", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "alg", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "RS256" - }, - { - "kind": "literal", - "value": "ES256" - }, - { - "kind": "literal", - "value": "HS256" - } - ] - } - }, - { - "name": "kid", - "optional": false, - "type": "string" - }, - { - "name": "typ", - "optional": false, - "type": "string" - } - ], - "name": "JwtHeader" - } - }, - { - "name": "signature", - "optional": false, - "type": { - "kind": "reference", - "name": "Uint8Array" - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get JWT claims, header and signature", - "code": "const { data, error } = await supabase.auth.getClaims()", - "response": "{\n \"data\": {\n \"claims\": {\n \"aal\": \"aal1\",\n \"amr\": [{\n \"method\": \"email\",\n \"timestamp\": 1715766000\n }],\n \"app_metadata\": {},\n \"aud\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"exp\": 1715769600,\n \"iat\": 1715766000,\n \"is_anonymous\": false,\n \"iss\": \"https://project-id.supabase.co/auth/v1\",\n \"phone\": \"+13334445555\",\n \"role\": \"authenticated\",\n \"session_id\": \"11111111-1111-1111-1111-111111111111\",\n \"sub\": \"11111111-1111-1111-1111-111111111111\",\n \"user_metadata\": {}\n },\n \"header\": {\n \"alg\": \"RS256\",\n \"typ\": \"JWT\",\n \"kid\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"signature\": [/** Uint8Array */],\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "getSession", - "description": "Returns the session, refreshing it if necessary.\nThe session returned can be null if the session is not detected which can happen in the event a user is not signed-in or has logged out.\n**IMPORTANT:** This method loads values directly from the storage attached to the client. If that storage is based on request cookies for example, the values in it may not be authentic and therefore it's strongly advised against using this method and its results in such circumstances. A warning will be emitted if this is detected. Use #getUser() instead.", - "remarks": [ - "- Since the introduction of [asymmetric JWT signing keys](/docs/guides/auth/signing-keys), this method is considered low-level and we encourage you to use `getClaims()` or `getUser()` instead. - Retrieves the current [user session](/docs/guides/auth/sessions) from the storage medium (local storage, cookies). - The session contains an access token (signed JWT), a refresh token and the user object. - If the session's access token is expired or is about to expire, this method will use the refresh token to refresh the session. - When using in a browser, or you've called `startAutoRefresh()` in your environment (React Native, etc.) this function always returns a valid access token without refreshing the session itself, as this is done in the background. This function returns very fast. - **IMPORTANT SECURITY NOTICE:** If using an insecure storage medium, such as cookies or request headers, the user object returned by this function **must not be trusted**. Always verify the JWT using `getClaims()` or your own JWT verification library to securely establish the user's identity and access. You can also use `getUser()` to fetch the user object directly from the Auth server for this purpose. - When using in a browser, this function is synchronized across all tabs using the [LockManager](https://developer.mozilla.org/en-US/docs/Web/API/LockManager) API. In other environments make sure you've defined a proper `lock` property, if necessary, to make sure there are no race conditions while the session is being refreshed." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get the session data", - "code": "const { data, error } = await supabase.auth.getSession()", - "response": "{\n \"data\": {\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n }\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "getUser", - "description": "Gets the current user details if there is an existing session. This method performs a network request to the Supabase Auth server, so the returned value is authentic and can be used to base authorization rules on.", - "remarks": [ - "- This method fetches the user object from the database instead of local session. - This method is useful for checking if the user is authorized because it validates the user's access token JWT on the server. - Should always be used when checking for user authorization on the server. On the client, you can instead use `getSession().session.user` for faster results. `getSession` is insecure on the server." - ], - "parameters": [ - { - "name": "jwt", - "optional": true, - "description": "Takes in an optional access token JWT. If no JWT is provided, the JWT from the current session is used.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get the logged in user with the current existing session", - "code": "const { data: { user } } = await supabase.auth.getUser()", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}" - }, - { - "title": "Get the logged in user with a custom access token jwt", - "code": "const { data: { user } } = await supabase.auth.getUser(jwt)" - } - ] - }, - { - "name": "getUserIdentities", - "description": "Gets all the identities linked to a user.", - "remarks": [ - "- The user needs to be signed in to call `getUserIdentities()`." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "identities", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Returns a list of identities linked to the user", - "code": "const { data, error } = await supabase.auth.getUserIdentities()", - "response": "{\n \"data\": {\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"2024-01-01T00:00:00Z\",\n \"user_id\": \"2024-01-01T00:00:00Z\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ]\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "initialize", - "description": "Initializes the client session either from the url or from storage. This method is automatically called when instantiating the client, but should also be called manually when checking for an error from an auth redirect (oauth, magiclink, password recovery, etc).", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "object", - "properties": [ - { - "name": "error", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ], - "name": "InitializeResult" - } - ] - } - }, - { - "name": "linkIdentity", - "description": "", - "remarks": [ - "- The **Enable Manual Linking** option must be enabled from your [project's authentication settings](/dashboard/project/_/auth/providers). - 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." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "queryParams", - "optional": true, - "description": "An object of query params", - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they are confirmed.", - "type": "string" - }, - { - "name": "scopes", - "optional": true, - "description": "A space-separated list of scopes granted to the OAuth application.", - "type": "string" - }, - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If set to true does not immediately redirect the current browser context to visit the OAuth authorization page for the provider.", - "type": "boolean" - } - ] - } - }, - { - "name": "provider", - "optional": false, - "description": "One of the providers supported by GoTrue.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "bitbucket" - }, - { - "kind": "literal", - "value": "discord" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "figma" - }, - { - "kind": "literal", - "value": "github" - }, - { - "kind": "literal", - "value": "gitlab" - }, - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "literal", - "value": "keycloak" - }, - { - "kind": "literal", - "value": "linkedin" - }, - { - "kind": "literal", - "value": "linkedin_oidc" - }, - { - "kind": "literal", - "value": "notion" - }, - { - "kind": "literal", - "value": "slack" - }, - { - "kind": "literal", - "value": "slack_oidc" - }, - { - "kind": "literal", - "value": "spotify" - }, - { - "kind": "literal", - "value": "twitch" - }, - { - "kind": "literal", - "value": "twitter" - }, - { - "kind": "literal", - "value": "x" - }, - { - "kind": "literal", - "value": "workos" - }, - { - "kind": "literal", - "value": "zoom" - }, - { - "kind": "literal", - "value": "fly" - }, - { - "kind": "templateLiteral" - } - ] - } - } - ], - "name": "SignInWithOAuthCredentials" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "provider", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "bitbucket" - }, - { - "kind": "literal", - "value": "discord" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "figma" - }, - { - "kind": "literal", - "value": "github" - }, - { - "kind": "literal", - "value": "gitlab" - }, - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "literal", - "value": "keycloak" - }, - { - "kind": "literal", - "value": "linkedin" - }, - { - "kind": "literal", - "value": "linkedin_oidc" - }, - { - "kind": "literal", - "value": "notion" - }, - { - "kind": "literal", - "value": "slack" - }, - { - "kind": "literal", - "value": "slack_oidc" - }, - { - "kind": "literal", - "value": "spotify" - }, - { - "kind": "literal", - "value": "twitch" - }, - { - "kind": "literal", - "value": "twitter" - }, - { - "kind": "literal", - "value": "x" - }, - { - "kind": "literal", - "value": "workos" - }, - { - "kind": "literal", - "value": "zoom" - }, - { - "kind": "literal", - "value": "fly" - }, - { - "kind": "templateLiteral" - } - ] - } - }, - { - "name": "url", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "provider", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "bitbucket" - }, - { - "kind": "literal", - "value": "discord" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "figma" - }, - { - "kind": "literal", - "value": "github" - }, - { - "kind": "literal", - "value": "gitlab" - }, - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "literal", - "value": "keycloak" - }, - { - "kind": "literal", - "value": "linkedin" - }, - { - "kind": "literal", - "value": "linkedin_oidc" - }, - { - "kind": "literal", - "value": "notion" - }, - { - "kind": "literal", - "value": "slack" - }, - { - "kind": "literal", - "value": "slack_oidc" - }, - { - "kind": "literal", - "value": "spotify" - }, - { - "kind": "literal", - "value": "twitch" - }, - { - "kind": "literal", - "value": "twitter" - }, - { - "kind": "literal", - "value": "x" - }, - { - "kind": "literal", - "value": "workos" - }, - { - "kind": "literal", - "value": "zoom" - }, - { - "kind": "literal", - "value": "fly" - }, - { - "kind": "templateLiteral" - } - ] - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Link an identity to a user", - "code": "const { data, error } = await supabase.auth.linkIdentity({\n provider: 'github'\n})", - "response": "{\n data: {\n provider: 'github',\n url: \n },\n error: null\n}" - } - ] - }, - { - "name": "onAuthStateChange", - "description": "", - "remarks": [ - "- Subscribes to important events occurring on the user's session. - Use on the frontend/client. It is less useful on the server. - Events are emitted across tabs to keep your application's UI up-to-date. Some events can fire very frequently, based on the number of tabs open. Use a quick and efficient callback function, and defer or debounce as many operations as you can to be performed outside of the callback. - **Important:** A callback can be an `async` function and it runs synchronously during the processing of the changes causing the event. You can easily create a dead-lock by using `await` on a call to another method of the Supabase library. - Avoid using `async` functions as callbacks. - Limit the number of `await` calls in `async` callbacks. - Do not use other Supabase functions in the callback function. If you must, dispatch the functions once the callback has finished executing. Use this as a quick way to achieve this: ```js supabase.auth.onAuthStateChange((event, session) => { setTimeout(async () => { // await on other Supabase function here // this runs right after the callback has finished }, 0) }) ``` - Emitted events: - `INITIAL_SESSION` - Emitted right after the Supabase client is constructed and the initial session from storage is loaded. - `SIGNED_IN` - Emitted each time a user session is confirmed or re-established, including on user sign in and when refocusing a tab. - Avoid making assumptions as to when this event is fired, this may occur even when the user is already signed in. Instead, check the user object attached to the event to see if a new user has signed in and update your application's UI. - This event can fire very frequently depending on the number of tabs open in your application. - `SIGNED_OUT` - Emitted when the user signs out. This can be after: - A call to `supabase.auth.signOut()`. - After the user's session has expired for any reason: - User has signed out on another device. - The session has reached its timebox limit or inactivity timeout. - User has signed in on another device with single session per user enabled. - Check the [User Sessions](/docs/guides/auth/sessions) docs for more information. - Use this to clean up any local storage your application has associated with the user. - `TOKEN_REFRESHED` - Emitted each time a new access and refresh token are fetched for the signed in user. - It's best practice and highly recommended to extract the access token (JWT) and store it in memory for further use in your application. - Avoid frequent calls to `supabase.auth.getSession()` for the same purpose. - There is a background process that keeps track of when the session should be refreshed so you will always receive valid tokens by listening to this event. - The frequency of this event is related to the JWT expiry limit configured on your project. - `USER_UPDATED` - Emitted each time the `supabase.auth.updateUser()` method finishes successfully. Listen to it to update your application's UI based on new profile information. - `PASSWORD_RECOVERY` - Emitted instead of the `SIGNED_IN` event when the user lands on a page that includes a password recovery link in the URL. - Use it to show a UI to the user where they can [reset their password](/docs/guides/auth/passwords#resetting-a-users-password-forgot-password)." - ], - "parameters": [ - { - "name": "callback", - "description": "A callback function to be invoked when an auth event happens.", - "type": { - "kind": "object", - "properties": [] - } - } - ], - "returnType": { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "subscription", - "optional": false, - "type": { - "kind": "object", - "name": "Subscription", - "properties": [ - { - "name": "callback", - "optional": false, - "description": "The function to call every time there is an event. eg: (eventName) => {}", - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "id", - "optional": false, - "description": "A unique identifier for this subscription, set by the client. This is an internal identifier used for managing callbacks and should not be relied upon by application code. Use the unsubscribe() method to remove listeners.", - "type": { - "kind": "union", - "types": [ - "string", - "symbol" - ] - } - }, - { - "name": "unsubscribe", - "optional": false, - "description": "Call this to remove the listener.", - "type": { - "kind": "object", - "properties": [] - } - } - ] - } - } - ] - } - } - ] - }, - "examples": [ - { - "title": "Listen to auth changes", - "code": "const { data } = supabase.auth.onAuthStateChange((event, session) => {\n console.log(event, session)\n\n if (event === 'INITIAL_SESSION') {\n // handle initial session\n } else if (event === 'SIGNED_IN') {\n // handle sign in event\n } else if (event === 'SIGNED_OUT') {\n // handle sign out event\n } else if (event === 'PASSWORD_RECOVERY') {\n // handle password recovery event\n } else if (event === 'TOKEN_REFRESHED') {\n // handle token refreshed event\n } else if (event === 'USER_UPDATED') {\n // handle user updated event\n }\n})\n\n// call unsubscribe to remove the callback\ndata.subscription.unsubscribe()", - "notes": "Listen to sign out\nMake sure you clear out any local data, such as local and session storage, after the client library has detected the user's sign out." - }, - { - "title": "Listen to sign out", - "code": "supabase.auth.onAuthStateChange((event, session) => {\n if (event === 'SIGNED_OUT') {\n console.log('SIGNED_OUT', session)\n\n // clear local and session storage\n [\n window.localStorage,\n window.sessionStorage,\n ].forEach((storage) => {\n Object.entries(storage)\n .forEach(([key]) => {\n storage.removeItem(key)\n })\n })\n }\n})", - "notes": "Make sure you clear out any local data, such as local and session storage, after the client library has detected the user's sign out." - }, - { - "title": "Store OAuth provider tokens on sign in", - "code": "// Register this immediately after calling createClient!\n// Because signInWithOAuth causes a redirect, you need to fetch the\n// provider tokens from the callback.\nsupabase.auth.onAuthStateChange((event, session) => {\n if (session && session.provider_token) {\n window.localStorage.setItem('oauth_provider_token', session.provider_token)\n }\n\n if (session && session.provider_refresh_token) {\n window.localStorage.setItem('oauth_provider_refresh_token', session.provider_refresh_token)\n }\n\n if (event === 'SIGNED_OUT') {\n window.localStorage.removeItem('oauth_provider_token')\n window.localStorage.removeItem('oauth_provider_refresh_token')\n }\n})", - "notes": "When using [OAuth (Social Login)](/docs/guides/auth/social-login) you sometimes wish to get access to the provider's access token and refresh token, in order to call provider APIs in the name of the user.\n\nFor example, if you are using [Sign in with Google](/docs/guides/auth/social-login/auth-google) you may want to use the provider token to call Google APIs on behalf of the user. Supabase Auth does not keep track of the provider access and refresh token, but does return them for you once, immediately after sign in. You can use the `onAuthStateChange` method to listen for the presence of the provider tokens and store them in local storage. You can further send them to your server's APIs for use on the backend.\n\nFinally, make sure you remove them from local storage on the `SIGNED_OUT` event. If the OAuth provider supports token revocation, make sure you call those APIs either from the frontend or schedule them to be called on the backend." - }, - { - "title": "Use React Context for the User's session", - "code": "const SessionContext = React.createContext(null)\n\nfunction main() {\n const [session, setSession] = React.useState(null)\n\n React.useEffect(() => {\n const {data: { subscription }} = supabase.auth.onAuthStateChange(\n (event, session) => {\n if (event === 'SIGNED_OUT') {\n setSession(null)\n } else if (session) {\n setSession(session)\n }\n })\n\n return () => {\n subscription.unsubscribe()\n }\n }, [])\n\n return (\n \n \n \n )\n}", - "notes": "Instead of relying on `supabase.auth.getSession()` within your React components, you can use a [React Context](https://react.dev/reference/react/createContext) to store the latest session information from the `onAuthStateChange` callback and access it that way." - }, - { - "title": "Listen to password recovery events", - "code": "supabase.auth.onAuthStateChange((event, session) => {\n if (event === 'PASSWORD_RECOVERY') {\n console.log('PASSWORD_RECOVERY', session)\n // show screen to update user's password\n showPasswordResetScreen(true)\n }\n})" - }, - { - "title": "Listen to sign in", - "code": "supabase.auth.onAuthStateChange((event, session) => {\n if (event === 'SIGNED_IN') console.log('SIGNED_IN', session)\n})" - }, - { - "title": "Listen to token refresh", - "code": "supabase.auth.onAuthStateChange((event, session) => {\n if (event === 'TOKEN_REFRESHED') console.log('TOKEN_REFRESHED', session)\n})" - }, - { - "title": "Listen to user updates", - "code": "supabase.auth.onAuthStateChange((event, session) => {\n if (event === 'USER_UPDATED') console.log('USER_UPDATED', session)\n})" - } - ] - }, - { - "name": "reauthenticate", - "description": "Sends a reauthentication OTP to the user's email or phone number. Requires the user to be signed-in.", - "remarks": [ - "- This method is used together with `updateUser()` when a user's password needs to be updated. - If you require your user to reauthenticate before updating their password, you need to enable the **Secure password change** option in your [project's email provider settings](/dashboard/project/_/auth/providers). - A user is only require to reauthenticate before updating their password if **Secure password change** is enabled and the user **hasn't recently signed in**. A user is deemed recently signed in if the session was created in the last 24 hours. - This method will send a nonce to the user's email. If the user doesn't have a confirmed email address, the method will send the nonce to the user's confirmed phone number instead. - After receiving the OTP, include it as the `nonce` in your `updateUser()` call to finalize the password change." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Send reauthentication nonce", - "code": "const { error } = await supabase.auth.reauthenticate()", - "notes": "Sends a reauthentication nonce to the user's email or phone number." - } - ] - }, - { - "name": "refreshSession", - "description": "Returns a new session, regardless of expiry status. Takes in an optional current session. If not passed in, then refreshSession() will attempt to retrieve it from getSession(). If the current session's refresh token is invalid, an error will be thrown.", - "remarks": [ - "- This method will refresh and return a new session whether the current one is expired or not." - ], - "parameters": [ - { - "name": "currentSession", - "optional": true, - "description": "The current session. If passed in, it must contain a refresh token.", - "type": { - "kind": "object", - "properties": [ - { - "name": "refresh_token", - "optional": false, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Refresh session using the current session", - "code": "const { data, error } = await supabase.auth.refreshSession()\nconst { session, user } = data", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n }\n },\n \"error\": null\n}" - }, - { - "title": "Refresh session using a refresh token", - "code": "const { data, error } = await supabase.auth.refreshSession({ refresh_token })\nconst { session, user } = data" - } - ] - }, - { - "name": "resend", - "description": "Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP.", - "remarks": [ - "- Resends a signup confirmation, email change or phone change email to the user. - Passwordless sign-ins can be resent by calling the `signInWithOtp()` method again. - Password recovery emails can be resent by calling the `resetPasswordForEmail()` method again. - This method will only resend an email or phone OTP to the user if there was an initial signup, email change or phone change request being made(note: For existing users signing in with OTP, you should use `signInWithOtp()` again to resend the OTP). - You can specify a redirect url when you resend an email link using the `emailRedirectTo` option." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "emailRedirectTo", - "optional": true, - "description": "A URL to send the user to after they have signed-in.", - "type": "string" - } - ] - } - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "reference", - "name": "Extract", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "signup" - }, - { - "kind": "literal", - "value": "invite" - }, - { - "kind": "literal", - "value": "magiclink" - }, - { - "kind": "literal", - "value": "recovery" - }, - { - "kind": "literal", - "value": "email_change" - }, - { - "kind": "literal", - "value": "email" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "signup" - }, - { - "kind": "literal", - "value": "email_change" - } - ] - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - } - ] - } - }, - { - "name": "phone", - "optional": false, - "type": "string" - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "reference", - "name": "Extract", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "sms" - }, - { - "kind": "literal", - "value": "phone_change" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "sms" - }, - { - "kind": "literal", - "value": "phone_change" - } - ] - } - ] - } - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "messageId", - "optional": true, - "type": { - "kind": "union", - "types": [ - "string", - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "session", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Resend an email signup confirmation", - "code": "const { error } = await supabase.auth.resend({\n type: 'signup',\n email: 'email@example.com',\n options: {\n emailRedirectTo: 'https://example.com/welcome'\n }\n})", - "notes": "Resends the email signup confirmation to the user" - }, - { - "title": "Resend a phone signup confirmation", - "code": "const { error } = await supabase.auth.resend({\n type: 'sms',\n phone: '1234567890'\n})", - "notes": "Resends the phone signup confirmation email to the user" - }, - { - "title": "Resend email change email", - "code": "const { error } = await supabase.auth.resend({\n type: 'email_change',\n email: 'email@example.com'\n})", - "notes": "Resends the email change email to the user" - }, - { - "title": "Resend phone change OTP", - "code": "const { error } = await supabase.auth.resend({\n type: 'phone_change',\n phone: '1234567890'\n})", - "notes": "Resends the phone change OTP to the user" - } - ] - }, - { - "name": "resetPasswordForEmail", - "description": "Sends a password reset request to an email address. This method supports the PKCE flow.", - "remarks": [ - "- The password reset flow consist of 2 broad steps: (i) Allow the user to login via the password reset link; (ii) Update the user's password. - The `resetPasswordForEmail()` only sends a password reset link to the user's email. To update the user's password, see [`updateUser()`](/docs/reference/javascript/auth-updateuser). - A `PASSWORD_RECOVERY` event will be emitted when the password recovery link is clicked. You can use [`onAuthStateChange()`](/docs/reference/javascript/auth-onauthstatechange) to listen and invoke a callback function on these events. - When the user clicks the reset link in the email they are redirected back to your application. You can configure the URL that the user is redirected to with the `redirectTo` parameter. See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project. - After the user has been redirected successfully, prompt them for a new password and call `updateUser()`: ```js const { data, error } = await supabase.auth.updateUser({ password: new_password }) ```" - ], - "parameters": [ - { - "name": "email", - "description": "The email address of the user.", - "type": "string" - }, - { - "name": "options", - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL to send the user to after they click the password reset link.", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Reset password", - "code": "const { data, error } = await supabase.auth.resetPasswordForEmail(email, {\n redirectTo: 'https://example.com/update-password',\n})", - "response": "{\n data: {}\n error: null\n}" - }, - { - "title": "Reset password (React)", - "code": "/**\n * Step 1: Send the user an email to get a password reset token.\n * This email contains a link which sends the user back to your application.\n */\nconst { data, error } = await supabase.auth\n .resetPasswordForEmail('user@email.com')\n\n/**\n * Step 2: Once the user is redirected back to your application,\n * ask the user to reset their password.\n */\n useEffect(() => {\n supabase.auth.onAuthStateChange(async (event, session) => {\n if (event == \"PASSWORD_RECOVERY\") {\n const newPassword = prompt(\"What would you like your new password to be?\");\n const { data, error } = await supabase.auth\n .updateUser({ password: newPassword })\n\n if (data) alert(\"Password updated successfully!\")\n if (error) alert(\"There was an error updating your password.\")\n }\n })\n }, [])" - } - ] - }, - { - "name": "setSession", - "description": "Sets the session data from the current session. If the current session is expired, setSession will take care of refreshing it to obtain a new session. If the refresh token or access token in the current session is invalid, an error will be thrown.", - "remarks": [ - "- This method sets the session using an `access_token` and `refresh_token`. - If successful, a `SIGNED_IN` event is emitted." - ], - "parameters": [ - { - "name": "currentSession", - "description": "The current session that minimally contains an access token and refresh token.", - "type": { - "kind": "object", - "properties": [ - { - "name": "access_token", - "optional": false, - "type": "string" - }, - { - "name": "refresh_token", - "optional": false, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Set the session", - "code": "const { data, error } = await supabase.auth.setSession({\n access_token,\n refresh_token\n })", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n },\n \"session\": {\n \"access_token\": \"\",\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"11111111-1111-1111-1111-111111111111\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"2024-01-01T00:00:00Z\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n },\n \"token_type\": \"bearer\",\n \"expires_in\": 3500,\n \"expires_at\": 1700000000\n }\n },\n \"error\": null\n}", - "notes": "Sets the session data from an access_token and refresh_token, then returns an auth response or error." - } - ] - }, - { - "name": "signInAnonymously", - "description": "Creates a new anonymous user.", - "remarks": [ - "- Returns an anonymous user - It is recommended to set up captcha for anonymous sign-ins to prevent abuse. You can pass in the captcha token in the `options` param." - ], - "parameters": [ - { - "name": "credentials", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - } - ] - } - } - ], - "name": "SignInAnonymouslyCredentials" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create an anonymous user", - "code": "const { data, error } = await supabase.auth.signInAnonymously({\n options: {\n captchaToken\n }\n});", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {},\n \"user_metadata\": {},\n \"identities\": [],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": true\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {},\n \"user_metadata\": {},\n \"identities\": [],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": true\n }\n }\n },\n \"error\": null\n}" - }, - { - "title": "Create an anonymous user with custom user metadata", - "code": "const { data, error } = await supabase.auth.signInAnonymously({\n options: {\n data\n }\n})" - } - ] - }, - { - "name": "signInWithIdToken", - "description": "Allows signing in with an OIDC ID token. The authentication provider used should be enabled and configured.", - "remarks": [ - "- Use an ID token to sign in. - Especially useful when implementing sign in using native platform dialogs in mobile or desktop apps using Sign in with Apple or Sign in with Google on iOS and Android. - You can also use Google's [One Tap](https://developers.google.com/identity/gsi/web/guides/display-google-one-tap) and [Automatic sign-in](https://developers.google.com/identity/gsi/web/guides/automatic-sign-in-sign-out) via this API." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "object", - "properties": [ - { - "name": "access_token", - "optional": true, - "description": "If the ID token contains an `at_hash` claim, then the hash of this value is compared to the value in the ID token.", - "type": "string" - }, - { - "name": "nonce", - "optional": true, - "description": "If the ID token contains a `nonce` claim, then the hash of this value is compared to the value in the ID token.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - } - ] - } - }, - { - "name": "provider", - "optional": false, - "description": "Provider name or OIDC `iss` value identifying which provider should be used to verify the provided token. Supported names: `google`, `apple`, `azure`, `facebook`, `kakao`. Use the `custom:` prefix for custom OIDC providers (e.g. `custom:my-oidc-provider`).", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "templateLiteral" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "token", - "optional": false, - "description": "OIDC ID token issued by the specified provider. The `iss` claim in the ID token must match the supplied provider. Some ID tokens contain an `at_hash` which require that you provide an `access_token` value to be accepted properly. If the token contains a `nonce` claim you must supply the nonce used to obtain the ID token.", - "type": "string" - } - ], - "name": "SignInWithIdTokenCredentials" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign In using ID Token", - "code": "const { data, error } = await supabase.auth.signInWithIdToken({\n provider: 'google',\n token: 'your-id-token'\n})", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n ...\n },\n \"user_metadata\": {\n ...\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"provider\": \"google\",\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n ...\n },\n \"user_metadata\": {\n ...\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"provider\": \"google\",\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n }\n }\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "signInWithOAuth", - "description": "Log in an existing user via a third-party provider. This method supports the PKCE flow.", - "remarks": [ - "- This method is used for signing in using [Social Login (OAuth) providers](/docs/guides/auth#configure-third-party-providers). - It works by redirecting your application to the provider's authorization screen, before bringing back the user to your app." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "queryParams", - "optional": true, - "description": "An object of query params", - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they are confirmed.", - "type": "string" - }, - { - "name": "scopes", - "optional": true, - "description": "A space-separated list of scopes granted to the OAuth application.", - "type": "string" - }, - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If set to true does not immediately redirect the current browser context to visit the OAuth authorization page for the provider.", - "type": "boolean" - } - ] - } - }, - { - "name": "provider", - "optional": false, - "description": "One of the providers supported by GoTrue.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "bitbucket" - }, - { - "kind": "literal", - "value": "discord" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "figma" - }, - { - "kind": "literal", - "value": "github" - }, - { - "kind": "literal", - "value": "gitlab" - }, - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "literal", - "value": "keycloak" - }, - { - "kind": "literal", - "value": "linkedin" - }, - { - "kind": "literal", - "value": "linkedin_oidc" - }, - { - "kind": "literal", - "value": "notion" - }, - { - "kind": "literal", - "value": "slack" - }, - { - "kind": "literal", - "value": "slack_oidc" - }, - { - "kind": "literal", - "value": "spotify" - }, - { - "kind": "literal", - "value": "twitch" - }, - { - "kind": "literal", - "value": "twitter" - }, - { - "kind": "literal", - "value": "x" - }, - { - "kind": "literal", - "value": "workos" - }, - { - "kind": "literal", - "value": "zoom" - }, - { - "kind": "literal", - "value": "fly" - }, - { - "kind": "templateLiteral" - } - ] - } - } - ], - "name": "SignInWithOAuthCredentials" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "provider", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "bitbucket" - }, - { - "kind": "literal", - "value": "discord" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "figma" - }, - { - "kind": "literal", - "value": "github" - }, - { - "kind": "literal", - "value": "gitlab" - }, - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "literal", - "value": "keycloak" - }, - { - "kind": "literal", - "value": "linkedin" - }, - { - "kind": "literal", - "value": "linkedin_oidc" - }, - { - "kind": "literal", - "value": "notion" - }, - { - "kind": "literal", - "value": "slack" - }, - { - "kind": "literal", - "value": "slack_oidc" - }, - { - "kind": "literal", - "value": "spotify" - }, - { - "kind": "literal", - "value": "twitch" - }, - { - "kind": "literal", - "value": "twitter" - }, - { - "kind": "literal", - "value": "x" - }, - { - "kind": "literal", - "value": "workos" - }, - { - "kind": "literal", - "value": "zoom" - }, - { - "kind": "literal", - "value": "fly" - }, - { - "kind": "templateLiteral" - } - ] - } - }, - { - "name": "url", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "provider", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "bitbucket" - }, - { - "kind": "literal", - "value": "discord" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "figma" - }, - { - "kind": "literal", - "value": "github" - }, - { - "kind": "literal", - "value": "gitlab" - }, - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "literal", - "value": "keycloak" - }, - { - "kind": "literal", - "value": "linkedin" - }, - { - "kind": "literal", - "value": "linkedin_oidc" - }, - { - "kind": "literal", - "value": "notion" - }, - { - "kind": "literal", - "value": "slack" - }, - { - "kind": "literal", - "value": "slack_oidc" - }, - { - "kind": "literal", - "value": "spotify" - }, - { - "kind": "literal", - "value": "twitch" - }, - { - "kind": "literal", - "value": "twitter" - }, - { - "kind": "literal", - "value": "x" - }, - { - "kind": "literal", - "value": "workos" - }, - { - "kind": "literal", - "value": "zoom" - }, - { - "kind": "literal", - "value": "fly" - }, - { - "kind": "templateLiteral" - } - ] - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign in using a third-party provider", - "code": "const { data, error } = await supabase.auth.signInWithOAuth({\n provider: 'github'\n})", - "response": "{\n data: {\n provider: 'github',\n url: \n },\n error: null\n}", - "notes": "with redirect\n- When the OAuth provider successfully authenticates the user, they are redirected to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls). It does not redirect the user immediately after invoking this method.\n- See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project." - }, - { - "title": "Sign in using a third-party provider with redirect", - "code": "const { data, error } = await supabase.auth.signInWithOAuth({\n provider: 'github',\n options: {\n redirectTo: 'https://example.com/welcome'\n }\n})", - "notes": "- When the OAuth provider successfully authenticates the user, they are redirected to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls). It does not redirect the user immediately after invoking this method.\n- See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project." - }, - { - "title": "Sign in with scopes and access provider tokens", - "code": "// Register this immediately after calling createClient!\n// Because signInWithOAuth causes a redirect, you need to fetch the\n// provider tokens from the callback.\nsupabase.auth.onAuthStateChange((event, session) => {\n if (session && session.provider_token) {\n window.localStorage.setItem('oauth_provider_token', session.provider_token)\n }\n\n if (session && session.provider_refresh_token) {\n window.localStorage.setItem('oauth_provider_refresh_token', session.provider_refresh_token)\n }\n\n if (event === 'SIGNED_OUT') {\n window.localStorage.removeItem('oauth_provider_token')\n window.localStorage.removeItem('oauth_provider_refresh_token')\n }\n})\n\n// Call this on your Sign in with GitHub button to initiate OAuth\n// with GitHub with the requested elevated scopes.\nawait supabase.auth.signInWithOAuth({\n provider: 'github',\n options: {\n scopes: 'repo gist notifications'\n }\n})", - "notes": "If you need additional access from an OAuth provider, in order to access provider specific APIs in the name of the user, you can do this by passing in the scopes the user should authorize for your application. Note that the `scopes` option takes in **a space-separated list** of scopes.\n\nBecause OAuth sign-in often includes redirects, you should register an `onAuthStateChange` callback immediately after you create the Supabase client. This callback will listen for the presence of `provider_token` and `provider_refresh_token` properties on the `session` object and store them in local storage. The client library will emit these values **only once** immediately after the user signs in. You can then access them by looking them up in local storage, or send them to your backend servers for further processing.\n\nFinally, make sure you remove them from local storage on the `SIGNED_OUT` event. If the OAuth provider supports token revocation, make sure you call those APIs either from the frontend or schedule them to be called on the backend." - } - ] - }, - { - "name": "signInWithOtp", - "description": "Log in a user using magiclink or a one-time password (OTP).\nIf the `{{ .ConfirmationURL }}` variable is specified in the email template, a magiclink will be sent. If the `{{ .Token }}` variable is specified in the email template, an OTP will be sent. If you're using phone sign-ins, only an OTP will be sent. You won't be able to send a magiclink for phone sign-ins.\nBe aware that you may get back an error message that will not distinguish between the cases where the account does not exist or, that the account can only be accessed via social login.\nDo note that you will need to configure a Whatsapp sender on Twilio if you are using phone sign in with the 'whatsapp' channel. The whatsapp channel is not supported on other providers at this time. This method supports PKCE when an email is passed.", - "remarks": [ - "- 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. - If the user doesn't exist, `signInWithOtp()` will signup the user instead. To restrict this behavior, you can set `shouldCreateUser` in `SignInWithPasswordlessCredentials.options` to `false`. - If you're using an email, you can configure whether you want the user to receive a magiclink or a OTP. - If you're using phone, you can configure whether you want the user to receive a OTP. - The magic link's destination URL is determined by the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls). - See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project. - Magic links and OTPs share the same implementation. To send users a one-time code instead of a magic link, [modify the magic link email template](/dashboard/project/_/auth/templates) to include `{{ .Token }}` instead of `{{ .ConfirmationURL }}`. - See our [Twilio Phone Auth Guide](/docs/guides/auth/phone-login?showSMSProvider=Twilio) for details about configuring WhatsApp sign in." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "description": "The user's email address.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "emailRedirectTo", - "optional": true, - "description": "The redirect url embedded in the email link", - "type": "string" - }, - { - "name": "shouldCreateUser", - "optional": true, - "description": "If set to false, this method will not create a new user. Defaults to true.", - "type": "boolean" - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "channel", - "optional": true, - "description": "Messaging channel to use (e.g. whatsapp or sms)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "sms" - }, - { - "kind": "literal", - "value": "whatsapp" - } - ] - } - }, - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "shouldCreateUser", - "optional": true, - "description": "If set to false, this method will not create a new user. Defaults to true.", - "type": "boolean" - } - ] - } - }, - { - "name": "phone", - "optional": false, - "description": "The user's phone number.", - "type": "string" - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "messageId", - "optional": true, - "type": { - "kind": "union", - "types": [ - "string", - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "session", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign in with email", - "code": "const { data, error } = await supabase.auth.signInWithOtp({\n email: 'example@email.com',\n options: {\n emailRedirectTo: 'https://example.com/welcome'\n }\n})", - "response": "{\n \"data\": {\n \"user\": null,\n \"session\": null\n },\n \"error\": null\n}", - "notes": "The user will be sent an email which contains either a magiclink or a OTP or both. By default, a given user can only request a OTP once every 60 seconds." - }, - { - "title": "Sign in with SMS OTP", - "code": "const { data, error } = await supabase.auth.signInWithOtp({\n phone: '+13334445555',\n})", - "notes": "The user will be sent a SMS which contains a OTP. By default, a given user can only request a OTP once every 60 seconds." - }, - { - "title": "Sign in with WhatsApp OTP", - "code": "const { data, error } = await supabase.auth.signInWithOtp({\n phone: '+13334445555',\n options: {\n channel:'whatsapp',\n }\n})", - "notes": "The user will be sent a WhatsApp message which contains a OTP. By default, a given user can only request a OTP once every 60 seconds. Note that a user will need to have a valid WhatsApp account that is linked to Twilio in order to use this feature." - } - ] - }, - { - "name": "signInWithPassword", - "description": "Log in an existing user with an email and password or phone and password.\nBe aware that you may get back an error message that will not distinguish between the cases where the account does not exist or that the email/phone and password combination is wrong or that the account can only be accessed via social login.", - "remarks": [ - "- Requires either an email and password or a phone number and password." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "intersection", - "types": [ - { - "kind": "reference", - "name": "PasswordCredentialsBase" - }, - { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "type": "string" - } - ] - } - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - }, - { - "name": "weakPassword", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "message", - "optional": false, - "type": "string" - }, - { - "name": "reasons", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "indexedAccess", - "objectType": { - "kind": "query" - }, - "indexType": null - } - } - } - ], - "name": "WeakPassword" - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign in with email and password", - "code": "const { data, error } = await supabase.auth.signInWithPassword({\n email: 'example@email.com',\n password: 'example-password',\n})", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n }\n }\n },\n \"error\": null\n}" - }, - { - "title": "Sign in with phone and password", - "code": "const { data, error } = await supabase.auth.signInWithPassword({\n phone: '+13334445555',\n password: 'some-password',\n})" - } - ] - }, - { - "name": "signInWithSSO", - "description": "Attempts a single-sign on using an enterprise Identity Provider. A successful SSO attempt will redirect the current page to the identity provider authorization page. The redirect URL is implementation and SSO protocol specific.\nYou can use it by providing a SSO domain. Typically you can extract this domain by asking users for their email address. If this domain is registered on the Auth instance the redirect will use that organization's currently active SSO Identity Provider for the login.\nIf you have built an organization-specific login page, you can use the organization's SSO Identity Provider UUID directly instead.", - "remarks": [ - "- 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. - In case you need to use a different way to start the authentication flow with an identity provider, you can use the `providerId` property. For example: - Mapping specific user email addresses with an identity provider. - Using different hints to identity the identity provider to be used by the user, like a company-specific page, IP address or other tracking information." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they have signed-in.", - "type": "string" - }, - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If set to true, the redirect will not happen on the client side. This parameter is used when you wish to handle the redirect yourself. Defaults to false.", - "type": "boolean" - } - ] - } - }, - { - "name": "providerId", - "optional": false, - "description": "UUID of the SSO provider to invoke single-sign on to.", - "type": "string" - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "domain", - "optional": false, - "description": "Domain name of the organization for which to invoke single-sign on.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they have signed-in.", - "type": "string" - }, - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If set to true, the redirect will not happen on the client side. This parameter is used when you wish to handle the redirect yourself. Defaults to false.", - "type": "boolean" - } - ] - } - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "url", - "optional": false, - "description": "URL to open in a browser which will complete the sign-in flow by taking the user to the identity provider's authentication flow.\nOn browsers you can set the URL to `window.location.href` to take the user to the authentication flow.", - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign in with email domain", - "code": "// You can extract the user's email domain and use it to trigger the\n // authentication flow with the correct identity provider.\n\n const { data, error } = await supabase.auth.signInWithSSO({\n domain: 'company.com'\n })\n\n if (data?.url) {\n // redirect the user to the identity provider's authentication flow\n window.location.href = data.url\n }" - }, - { - "title": "Sign in with provider UUID", - "code": "// Useful when you need to map a user's sign in request according\n // to different rules that can't use email domains.\n\n const { data, error } = await supabase.auth.signInWithSSO({\n providerId: '21648a9d-8d5a-4555-a9d1-d6375dc14e92'\n })\n\n if (data?.url) {\n // redirect the user to the identity provider's authentication flow\n window.location.href = data.url\n }" - } - ] - }, - { - "name": "signInWithWeb3", - "description": "Signs in a user by verifying a message signed by the user's private key. Supports Ethereum (via Sign-In-With-Ethereum) & Solana (Sign-In-With-Solana) standards, both of which derive from the EIP-4361 standard With slight variation on Solana's side.", - "remarks": [ - "- Uses a Web3 (Ethereum, Solana) wallet to sign a user in. - Read up on the [potential for abuse](/docs/guides/auth/auth-web3#potential-for-abuse) before using it." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "union", - "types": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "chain", - "optional": false, - "type": { - "kind": "literal", - "value": "solana" - } - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "signInWithSolana", - "optional": true, - "type": { - "kind": "reference", - "name": "Partial", - "typeArguments": [ - { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "reference", - "name": "SolanaSignInInput" - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "version" - }, - { - "kind": "literal", - "value": "chain" - }, - { - "kind": "literal", - "value": "domain" - }, - { - "kind": "literal", - "value": "uri" - }, - { - "kind": "literal", - "value": "statement" - } - ] - } - ] - } - ] - } - }, - { - "name": "url", - "optional": true, - "description": "URL to use with the wallet interface. Some wallets do not allow signing a message for URLs different from the current page.", - "type": "string" - } - ] - } - }, - { - "name": "statement", - "optional": true, - "description": "Optional statement to include in the Sign in with Solana message. Must not include new line characters. Most wallets like Phantom **require specifying a statement!**", - "type": "string" - }, - { - "name": "wallet", - "optional": true, - "description": "Wallet interface to use. If not specified will default to `window.solana`.", - "type": { - "kind": "object", - "properties": [ - { - "name": "publicKey", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "toBase58", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "signIn", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "signMessage", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - } - ], - "name": "SolanaWallet" - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "chain", - "optional": false, - "type": { - "kind": "literal", - "value": "solana" - } - }, - { - "name": "message", - "optional": false, - "description": "Sign in with Solana compatible message. Must include `Issued At`, `URI` and `Version`.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - } - ] - } - }, - { - "name": "signature", - "optional": false, - "description": "Ed25519 signature of the message.", - "type": { - "kind": "reference", - "name": "Uint8Array" - } - } - ] - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "chain", - "optional": false, - "type": { - "kind": "literal", - "value": "ethereum" - } - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "signInWithEthereum", - "optional": true, - "type": { - "kind": "reference", - "name": "Partial", - "typeArguments": [ - { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "reference", - "name": "EthereumSignInInput" - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "version" - }, - { - "kind": "literal", - "value": "domain" - }, - { - "kind": "literal", - "value": "uri" - }, - { - "kind": "literal", - "value": "statement" - } - ] - } - ] - } - ] - } - }, - { - "name": "url", - "optional": true, - "description": "URL to use with the wallet interface. Some wallets do not allow signing a message for URLs different from the current page.", - "type": "string" - } - ] - } - }, - { - "name": "statement", - "optional": true, - "description": "Optional statement to include in the Sign in with Ethereum message. Must not include new line characters. Most wallets like Phantom **require specifying a statement!**", - "type": "string" - }, - { - "name": "wallet", - "optional": true, - "description": "Wallet interface to use. If not specified will default to `window.ethereum`.", - "type": { - "kind": "reference", - "name": "EIP1193Provider" - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "chain", - "optional": false, - "type": { - "kind": "literal", - "value": "ethereum" - } - }, - { - "name": "message", - "optional": false, - "description": "Sign in with Ethereum compatible message. Must include `Issued At`, `URI` and `Version`.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - } - ] - } - }, - { - "name": "signature", - "optional": false, - "description": "Ethereum curve (secp256k1) signature of the message.", - "type": { - "kind": "reference", - "name": "Hex" - } - } - ] - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign in with Solana or Ethereum (Window API)", - "code": "// uses window.ethereum for the wallet\n const { data, error } = await supabase.auth.signInWithWeb3({\n chain: 'ethereum',\n statement: 'I accept the Terms of Service at https://example.com/tos'\n })\n\n // uses window.solana for the wallet\n const { data, error } = await supabase.auth.signInWithWeb3({\n chain: 'solana',\n statement: 'I accept the Terms of Service at https://example.com/tos'\n })" - }, - { - "title": "Sign in with Ethereum (Message and Signature)", - "code": "const { data, error } = await supabase.auth.signInWithWeb3({\n chain: 'ethereum',\n message: '',\n signature: '',\n })" - }, - { - "title": "Sign in with Solana (Brave)", - "code": "const { data, error } = await supabase.auth.signInWithWeb3({\n chain: 'solana',\n statement: 'I accept the Terms of Service at https://example.com/tos',\n wallet: window.braveSolana\n })" - }, - { - "title": "Sign in with Solana (Wallet Adapter)", - "code": "function SignInButton() {\n const wallet = useWallet()\n\n return (\n <>\n {wallet.connected ? (\n {\n supabase.auth.signInWithWeb3({\n chain: 'solana',\n statement: 'I accept the Terms of Service at https://example.com/tos',\n wallet,\n })\n }}\n >\n Sign in with Solana\n \n ) : (\n \n )}\n \n )\n}\n\nfunction App() {\n const endpoint = clusterApiUrl('devnet')\n const wallets = useMemo(() => [], [])\n\n return (\n \n \n \n \n \n \n \n )\n}" - } - ] - }, - { - "name": "signOut", - "description": "Inside a browser context, `signOut()` will remove the logged in user from the browser session and log them out - removing all items from localstorage and then trigger a `\"SIGNED_OUT\"` event.\nFor server-side management, you can revoke all refresh tokens for a user by passing a user's JWT through to `auth.api.signOut(JWT: string)`. There is no way to revoke a user's access token jwt until it expires. It is recommended to set a shorter expiry on the jwt for this reason.\nIf using `others` scope, no `SIGNED_OUT` event is fired!", - "remarks": [ - "- In order to use the `signOut()` method, the user needs to be signed in first. - By default, `signOut()` uses the global scope, which signs out all other sessions that the user is logged into as well. Customize this behavior by passing a scope parameter. - Since Supabase Auth uses JWTs for authentication, the access token JWT will be valid until it's expired. When the user signs out, Supabase revokes the refresh token and deletes the JWT from the client-side. This does not revoke the JWT and it will still be valid until it expires." - ], - "parameters": [ - { - "name": "options", - "type": { - "kind": "object", - "properties": [ - { - "name": "scope", - "optional": true, - "description": "Determines which sessions should be logged out. Global means all sessions by this account. Local means only this session. Others means all other sessions except the current one. When using others, there is no sign-out event fired on the current session!", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "global" - }, - { - "kind": "literal", - "value": "local" - }, - { - "kind": "literal", - "value": "others" - } - ] - } - } - ], - "name": "SignOut" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "object", - "properties": [ - { - "name": "error", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - ] - } - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign out (all sessions)", - "code": "const { error } = await supabase.auth.signOut()" - }, - { - "title": "Sign out (current session)", - "code": "const { error } = await supabase.auth.signOut({ scope: 'local' })" - }, - { - "title": "Sign out (other sessions)", - "code": "const { error } = await supabase.auth.signOut({ scope: 'others' })" - } - ] - }, - { - "name": "signUp", - "description": "Creates a new user.\nBe aware that if a user account exists in the system you may get back an error message that attempts to hide this information from the user. This method has support for PKCE via email signups. The PKCE flow cannot be used when autoconfirm is enabled.", - "remarks": [ - "- By default, the user needs to verify their email address before logging in. To turn this off, disable **Confirm email** in [your project](/dashboard/project/_/auth/providers). - **Confirm email** determines if users need to confirm their email address after signing up. - If **Confirm email** is enabled, a `user` is returned but `session` is null. - If **Confirm email** is disabled, both a `user` and a `session` are returned. - When the user confirms their email address, they are redirected to the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) by default. You can modify your `SITE_URL` or add additional redirect URLs in [your project](/dashboard/project/_/auth/url-configuration). - If signUp() is called for an existing confirmed user: - 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)." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "conditional" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign up with an email and password", - "code": "const { data, error } = await supabase.auth.signUp({\n email: 'example@email.com',\n password: 'example-password',\n})", - "response": "// Some fields may be null if \"confirm email\" is enabled.\n{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n }\n }\n },\n \"error\": null\n}", - "notes": "Sign up with a phone number and password (whatsapp)\nThe user will be sent a WhatsApp message which contains a OTP. By default, a given user can only request a OTP once every 60 seconds. Note that a user will need to have a valid WhatsApp account that is linked to Twilio in order to use this feature." - }, - { - "title": "Sign up with a phone number and password (SMS)", - "code": "const { data, error } = await supabase.auth.signUp({\n phone: '123456789',\n password: 'example-password',\n options: {\n channel: 'sms'\n }\n})", - "notes": "Sign up with a redirect URL\n- See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project." - }, - { - "title": "Sign up with a phone number and password (whatsapp)", - "code": "const { data, error } = await supabase.auth.signUp({\n phone: '123456789',\n password: 'example-password',\n options: {\n channel: 'whatsapp'\n }\n})", - "notes": "The user will be sent a WhatsApp message which contains a OTP. By default, a given user can only request a OTP once every 60 seconds. Note that a user will need to have a valid WhatsApp account that is linked to Twilio in order to use this feature." - }, - { - "title": "Sign up with additional user metadata", - "code": "const { data, error } = await supabase.auth.signUp(\n {\n email: 'example@email.com',\n password: 'example-password',\n options: {\n data: {\n first_name: 'John',\n age: 27,\n }\n }\n }\n)" - }, - { - "title": "Sign up with a redirect URL", - "code": "const { data, error } = await supabase.auth.signUp(\n {\n email: 'example@email.com',\n password: 'example-password',\n options: {\n emailRedirectTo: 'https://example.com/welcome'\n }\n }\n)", - "notes": "- See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project." - } - ] - }, - { - "name": "startAutoRefresh", - "description": "Starts an auto-refresh process in the background. The session is checked every few seconds. Close to the time of expiration a process is started to refresh the session. If refreshing fails it will be retried for as long as necessary.\nIf you set the GoTrueClientOptions#autoRefreshToken you don't need to call this function, it will be called for you.\nOn browsers the refresh process works only when the tab/window is in the foreground to conserve resources as well as prevent race conditions and flooding auth with requests. If you call this method any managed visibility change callback will be removed and you must manage visibility changes on your own.\nOn non-browser platforms the refresh process works *continuously* in the background, which may not be desirable. You should hook into your platform's foreground indication mechanism and call these methods appropriately to conserve resources.\n#stopAutoRefresh", - "remarks": [ - "- Only useful in non-browser environments such as React Native or Electron. - The Supabase Auth library automatically starts and stops proactively refreshing the session when a tab is focused or not. - On non-browser platforms, such as mobile or desktop apps built with web technologies, the library is not able to effectively determine whether the application is _focused_ or not. - To give this hint to the application, you should be calling this method when the app is in focus and calling `supabase.auth.stopAutoRefresh()` when it's out of focus." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - "void" - ] - }, - "examples": [ - { - "title": "Start and stop auto refresh in React Native", - "code": "import { AppState } from 'react-native'\n\n// make sure you register this only once!\nAppState.addEventListener('change', (state) => {\n if (state === 'active') {\n supabase.auth.startAutoRefresh()\n } else {\n supabase.auth.stopAutoRefresh()\n }\n})" - } - ] - }, - { - "name": "stopAutoRefresh", - "description": "Stops an active auto refresh process running in the background (if any).\nIf you call this method any managed visibility change callback will be removed and you must manage visibility changes on your own.\nSee #startAutoRefresh for more details.", - "remarks": [ - "- Only useful in non-browser environments such as React Native or Electron. - The Supabase Auth library automatically starts and stops proactively refreshing the session when a tab is focused or not. - On non-browser platforms, such as mobile or desktop apps built with web technologies, the library is not able to effectively determine whether the application is _focused_ or not. - When your application goes in the background or out of focus, call this method to stop the proactive refreshing of the session." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - "void" - ] - }, - "examples": [ - { - "title": "Start and stop auto refresh in React Native", - "code": "import { AppState } from 'react-native'\n\n// make sure you register this only once!\nAppState.addEventListener('change', (state) => {\n if (state === 'active') {\n supabase.auth.startAutoRefresh()\n } else {\n supabase.auth.stopAutoRefresh()\n }\n})" - } - ] - }, - { - "name": "unlinkIdentity", - "description": "Unlinks an identity from a user by deleting it. The user will no longer be able to sign in with that identity once it's unlinked.", - "remarks": [ - "- The **Enable Manual Linking** option must be enabled from your [project's authentication settings](/dashboard/project/_/auth/providers). - The user needs to be signed in to call `unlinkIdentity()`. - The user must have at least 2 identities in order to unlink an identity. - The identity to be unlinked must belong to the user." - ], - "parameters": [ - { - "name": "identity", - "type": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Unlink an identity", - "code": "// retrieve all identities linked to a user\nconst identities = await supabase.auth.getUserIdentities()\n\n// find the google identity\nconst googleIdentity = identities.find(\n identity => identity.provider === 'google'\n)\n\n// unlink the google identity\nconst { error } = await supabase.auth.unlinkIdentity(googleIdentity)" - } - ] - }, - { - "name": "updateUser", - "description": "Updates user data for a logged in user.", - "remarks": [ - "- In order to use the `updateUser()` method, the user needs to be signed in first. - By default, email updates sends a confirmation link to both the user's current and new email. To only send a confirmation link to the user's new email, disable **Secure email change** in your project's [email auth provider settings](/dashboard/project/_/auth/providers)." - ], - "parameters": [ - { - "name": "attributes", - "type": { - "kind": "object", - "name": "UserAttributes", - "properties": [ - { - "name": "current_password", - "optional": true, - "description": "The user's current password\nThis is only ever present when the user is resetting their password and GOTRUE_SECURITY_UPDATE_PASSWORD_REQUIRE_CURRENT_PASSWORD is true.", - "type": "string" - }, - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "email", - "optional": true, - "description": "The user's email.", - "type": "string" - }, - { - "name": "nonce", - "optional": true, - "description": "The nonce sent for reauthentication if the user's password is to be updated.\nCall reauthenticate() to obtain the nonce first.", - "type": "string" - }, - { - "name": "password", - "optional": true, - "description": "The user's password.", - "type": "string" - }, - { - "name": "phone", - "optional": true, - "description": "The user's phone.", - "type": "string" - } - ] - } - }, - { - "name": "options", - "type": { - "kind": "object", - "properties": [ - { - "name": "emailRedirectTo", - "optional": true, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Update the email for an authenticated user", - "code": "const { data, error } = await supabase.auth.updateUser({\n email: 'new@email.com'\n})", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"new_email\": \"new@email.com\",\n \"email_change_sent_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}", - "notes": "Sends a \"Confirm Email Change\" email to the new address. If **Secure Email Change** is enabled (default), confirmation is also required from the **old email** before the change is applied. To skip dual confirmation and apply the change after only the new email is verified, disable **Secure Email Change** in the [Email Auth Provider settings](/dashboard/project/_/auth/providers?provider=Email)." - }, - { - "title": "Update the phone number for an authenticated user", - "code": "const { data, error } = await supabase.auth.updateUser({\n phone: '123456789'\n})", - "notes": "Sends a one-time password (OTP) to the new phone number." - }, - { - "title": "Update the password for an authenticated user", - "code": "const { data, error } = await supabase.auth.updateUser({\n password: 'new password'\n})", - "notes": "Update the user's metadata\nUpdates the user's custom metadata.\n\n**Note**: The `data` field maps to the `auth.users.raw_user_meta_data` column in your Supabase database. When calling `getUser()`, the data will be available as `user.user_metadata`." - }, - { - "title": "Update the user's metadata", - "code": "const { data, error } = await supabase.auth.updateUser({\n data: { hello: 'world' }\n})", - "notes": "Updates the user's custom metadata.\n\n**Note**: The `data` field maps to the `auth.users.raw_user_meta_data` column in your Supabase database. When calling `getUser()`, the data will be available as `user.user_metadata`." - }, - { - "title": "Update the user's password with a nonce", - "code": "const { data, error } = await supabase.auth.updateUser({\n password: 'new password',\n nonce: '123456'\n})", - "notes": "If **Secure password change** is enabled in your [project's email provider settings](/dashboard/project/_/auth/providers), updating the user's password would require a nonce if the user **hasn't recently signed in**. The nonce is sent to the user's email or phone number. A user is deemed recently signed in if the session was created in the last 24 hours." - } - ] - }, - { - "name": "verifyOtp", - "description": "Log in a user given a User supplied OTP or TokenHash received through mobile or email.", - "remarks": [ - "- The `verifyOtp` method takes in different verification types. - If a phone number is used, the type can either be: 1. `sms` – Used when verifying a one-time password (OTP) sent via SMS during sign-up or sign-in. 2. `phone_change` – Used when verifying an OTP sent to a new phone number during a phone number update process. - If an email address is used, the type can be one of the following (note: `signup` and `magiclink` types are deprecated): 1. `email` – Used when verifying an OTP sent to the user's email during sign-up or sign-in. 2. `recovery` – Used when verifying an OTP sent for account recovery, typically after a password reset request. 3. `invite` – Used when verifying an OTP sent as part of an invitation to join a project or organization. 4. `email_change` – Used when verifying an OTP sent to a new email address during an email update process. - 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 for the PKCE flow for Server Side Auth. Read [the Password-based Auth guide](/docs/guides/auth/passwords) for more details." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "VerifyMobileOtpParams", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they are confirmed.", - "type": "string" - } - ] - } - }, - { - "name": "phone", - "optional": false, - "description": "The user's phone number.", - "type": "string" - }, - { - "name": "token", - "optional": false, - "description": "The otp sent to the user's phone number.", - "type": "string" - }, - { - "name": "type", - "optional": false, - "description": "The user's verification type.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "sms" - }, - { - "kind": "literal", - "value": "phone_change" - } - ] - } - } - ] - }, - { - "kind": "object", - "name": "VerifyEmailOtpParams", - "properties": [ - { - "name": "email", - "optional": false, - "description": "The user's email address.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they are confirmed.", - "type": "string" - } - ] - } - }, - { - "name": "token", - "optional": false, - "description": "The otp sent to the user's email address.", - "type": "string" - }, - { - "name": "type", - "optional": false, - "description": "The user's verification type.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "signup" - }, - { - "kind": "literal", - "value": "invite" - }, - { - "kind": "literal", - "value": "magiclink" - }, - { - "kind": "literal", - "value": "recovery" - }, - { - "kind": "literal", - "value": "email_change" - }, - { - "kind": "literal", - "value": "email" - } - ] - } - } - ] - }, - { - "kind": "object", - "name": "VerifyTokenHashParams", - "properties": [ - { - "name": "token_hash", - "optional": false, - "description": "The token hash used in an email link", - "type": "string" - }, - { - "name": "type", - "optional": false, - "description": "The user's verification type.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "signup" - }, - { - "kind": "literal", - "value": "invite" - }, - { - "kind": "literal", - "value": "magiclink" - }, - { - "kind": "literal", - "value": "recovery" - }, - { - "kind": "literal", - "value": "email_change" - }, - { - "kind": "literal", - "value": "email" - } - ] - } - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "Session", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Verify Signup One-Time Password (OTP)", - "code": "const { data, error } = await supabase.auth.verifyOtp({ email, token, type: 'email'})", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"recovery_sent_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"recovery_sent_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n }\n },\n \"error\": null\n}" - }, - { - "title": "Verify SMS One-Time Password (OTP)", - "code": "const { data, error } = await supabase.auth.verifyOtp({ phone, token, type: 'sms'})" - }, - { - "title": "Verify Email Auth (Token Hash)", - "code": "const { data, error } = await supabase.auth.verifyOtp({ token_hash: tokenHash, type: 'email'})" - } - ] - }, - { - "name": "approveAuthorization", - "description": "Approves an OAuth authorization request. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nAfter approval, the user's consent is stored and an authorization code is generated. The response contains a complete redirect URL with the authorization code and state.", - "parameters": [ - { - "name": "authorizationId", - "description": "The authorization ID to approve", - "type": "string" - }, - { - "name": "options", - "optional": true, - "description": "Optional parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If false (default), automatically redirects the browser to the OAuth client. If true, returns the redirect_url without automatic redirect (useful for custom handling).", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "redirect_url", - "optional": false, - "description": "Complete redirect URL with authorization code and state parameters (e.g., \"https://app.com/callback?code=xxx&state=yyy\")", - "type": "string" - } - ], - "name": "OAuthRedirect" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "denyAuthorization", - "description": "Denies an OAuth authorization request. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nAfter denial, the response contains a redirect URL with an OAuth error (access_denied) to inform the OAuth client that the user rejected the request.", - "parameters": [ - { - "name": "authorizationId", - "description": "The authorization ID to deny", - "type": "string" - }, - { - "name": "options", - "optional": true, - "description": "Optional parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If false (default), automatically redirects the browser to the OAuth client. If true, returns the redirect_url without automatic redirect (useful for custom handling).", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "redirect_url", - "optional": false, - "description": "Complete redirect URL with authorization code and state parameters (e.g., \"https://app.com/callback?code=xxx&state=yyy\")", - "type": "string" - } - ], - "name": "OAuthRedirect" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "getAuthorizationDetails", - "description": "Retrieves details about an OAuth authorization request. Used to display consent information to the user. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis method returns one of two response types: - `OAuthAuthorizationDetails`: User needs to consent - show consent page with client info - `OAuthRedirect`: User already consented - redirect immediately to the OAuth client\nUse type narrowing to distinguish between the responses: ```typescript if ('authorization_id' in data) { // Show consent page } else { // Redirect to data.redirect_url } ```", - "parameters": [ - { - "name": "authorizationId", - "description": "The authorization ID from the authorization request", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "authorization_id", - "optional": false, - "description": "The authorization ID used to approve or deny the request", - "type": "string" - }, - { - "name": "client", - "optional": false, - "description": "OAuth client requesting authorization", - "type": { - "kind": "object", - "properties": [ - { - "name": "id", - "optional": false, - "description": "Unique identifier for the OAuth client (UUID)", - "type": "string" - }, - { - "name": "logo_uri", - "optional": false, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "uri", - "optional": false, - "description": "URI of the OAuth client's website", - "type": "string" - } - ], - "name": "OAuthAuthorizationClient" - } - }, - { - "name": "redirect_uri", - "optional": false, - "description": "The OAuth client's registered redirect URI (base URI without query parameters)", - "type": "string" - }, - { - "name": "scope", - "optional": false, - "description": "Space-separated list of requested scopes (e.g., \"openid profile email\")", - "type": "string" - }, - { - "name": "user", - "optional": false, - "description": "User object associated with the authorization", - "type": { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "description": "User email", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "User ID (UUID)", - "type": "string" - } - ] - } - } - ], - "name": "OAuthAuthorizationDetails" - }, - { - "kind": "object", - "properties": [ - { - "name": "redirect_url", - "optional": false, - "description": "Complete redirect URL with authorization code and state parameters (e.g., \"https://app.com/callback?code=xxx&state=yyy\")", - "type": "string" - } - ], - "name": "OAuthRedirect" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "listGrants", - "description": "Lists all OAuth grants that the authenticated user has authorized. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "properties": [ - { - "name": "client", - "optional": false, - "description": "OAuth client information", - "type": { - "kind": "object", - "properties": [ - { - "name": "id", - "optional": false, - "description": "Unique identifier for the OAuth client (UUID)", - "type": "string" - }, - { - "name": "logo_uri", - "optional": false, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "uri", - "optional": false, - "description": "URI of the OAuth client's website", - "type": "string" - } - ], - "name": "OAuthAuthorizationClient" - } - }, - { - "name": "granted_at", - "optional": false, - "description": "Timestamp when the grant was created (ISO 8601 date-time)", - "type": "string" - }, - { - "name": "scopes", - "optional": false, - "description": "Array of scopes granted to this client", - "type": { - "kind": "array", - "elementType": "string" - } - } - ], - "name": "OAuthGrant" - } - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "revokeGrant", - "description": "Revokes a user's OAuth grant for a specific client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nRevocation marks consent as revoked, deletes active sessions for that OAuth client, and invalidates associated refresh tokens.", - "parameters": [ - { - "name": "options", - "description": "Revocation options", - "type": { - "kind": "object", - "properties": [ - { - "name": "clientId", - "optional": false, - "description": "The OAuth client identifier (UUID) to revoke access for", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "deleteFactor", - "description": "Deletes a factor on a user. This will log the user out of all active sessions if the deleted factor was verified.", - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "id", - "optional": false, - "description": "ID of the MFA factor to delete.", - "type": "string" - }, - { - "name": "userId", - "optional": false, - "description": "ID of the user whose factor is being deleted.", - "type": "string" - } - ], - "name": "AuthMFAAdminDeleteFactorParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "id", - "optional": false, - "description": "ID of the factor that was successfully deleted.", - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Delete a factor for a user", - "code": "const { data, error } = await supabase.auth.admin.mfa.deleteFactor({\n id: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n userId: 'a89baba7-b1b7-440f-b4bb-91026967f66b',\n})", - "response": "{\n data: {\n id: '34e770dd-9ff9-416c-87fa-43b31d7ef225'\n },\n error: null\n}" - } - ] - }, - { - "name": "listFactors", - "description": "Lists all factors associated to a user.", - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "userId", - "optional": false, - "description": "ID of the user.", - "type": "string" - } - ], - "name": "AuthMFAAdminListFactorsParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "factors", - "optional": false, - "description": "All factors attached to the user.", - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "typeParam", - "name": "Type" - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "typeParam", - "name": "Status" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "List all factors for a user", - "code": "const { data, error } = await supabase.auth.admin.mfa.listFactors()", - "response": "{\n data: {\n factors: Factor[\n {\n id: '',\n friendly_name: 'Auth App Factor',\n factor_type: 'totp',\n status: 'verified',\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z'\n }\n ]\n },\n error: null\n}" - } - ] - }, - { - "name": "createClient", - "description": "Creates a new OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "grant_types", - "optional": true, - "description": "Array of allowed grant types (optional, defaults to authorization_code and refresh_token)", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "response_types", - "optional": true, - "description": "Array of allowed response types (optional, defaults to code)", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": true, - "description": "Token endpoint authentication method (defaults to server default if not specified)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - } - ], - "name": "CreateOAuthClientParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "client_id", - "optional": false, - "description": "Unique identifier for the OAuth client", - "type": "string" - }, - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_secret", - "optional": true, - "description": "Client secret (only returned on registration and regeneration)", - "type": "string" - }, - { - "name": "client_type", - "optional": false, - "description": "Type of OAuth client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "public" - }, - { - "kind": "literal", - "value": "confidential" - } - ] - } - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "description": "Timestamp when the client was created", - "type": "string" - }, - { - "name": "grant_types", - "optional": false, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "registration_type", - "optional": false, - "description": "Registration type of the client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "dynamic" - }, - { - "kind": "literal", - "value": "manual" - } - ] - } - }, - { - "name": "response_types", - "optional": false, - "description": "Array of allowed response types", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": false, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "description": "Timestamp when the client was last updated", - "type": "string" - } - ], - "name": "OAuthClient" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "deleteClient", - "description": "Deletes an OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "clientId", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - ] - } - } - ] - } - ] - } - }, - { - "name": "getClient", - "description": "Gets details of a specific OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "clientId", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "client_id", - "optional": false, - "description": "Unique identifier for the OAuth client", - "type": "string" - }, - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_secret", - "optional": true, - "description": "Client secret (only returned on registration and regeneration)", - "type": "string" - }, - { - "name": "client_type", - "optional": false, - "description": "Type of OAuth client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "public" - }, - { - "kind": "literal", - "value": "confidential" - } - ] - } - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "description": "Timestamp when the client was created", - "type": "string" - }, - { - "name": "grant_types", - "optional": false, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "registration_type", - "optional": false, - "description": "Registration type of the client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "dynamic" - }, - { - "kind": "literal", - "value": "manual" - } - ] - } - }, - { - "name": "response_types", - "optional": false, - "description": "Array of allowed response types", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": false, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "description": "Timestamp when the client was last updated", - "type": "string" - } - ], - "name": "OAuthClient" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "listClients", - "description": "Lists all OAuth clients with optional pagination. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "page", - "optional": true, - "description": "The page number", - "type": "number" - }, - { - "name": "perPage", - "optional": true, - "description": "Number of items returned per page", - "type": "number" - } - ], - "name": "PageParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "intersection", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "clients", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "properties": [ - { - "name": "client_id", - "optional": false, - "description": "Unique identifier for the OAuth client", - "type": "string" - }, - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_secret", - "optional": true, - "description": "Client secret (only returned on registration and regeneration)", - "type": "string" - }, - { - "name": "client_type", - "optional": false, - "description": "Type of OAuth client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "public" - }, - { - "kind": "literal", - "value": "confidential" - } - ] - } - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "description": "Timestamp when the client was created", - "type": "string" - }, - { - "name": "grant_types", - "optional": false, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "registration_type", - "optional": false, - "description": "Registration type of the client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "dynamic" - }, - { - "kind": "literal", - "value": "manual" - } - ] - } - }, - { - "name": "response_types", - "optional": false, - "description": "Array of allowed response types", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": false, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "description": "Timestamp when the client was last updated", - "type": "string" - } - ], - "name": "OAuthClient" - } - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "lastPage", - "optional": false, - "type": "number" - }, - { - "name": "nextPage", - "optional": false, - "type": { - "kind": "union", - "types": [ - "number", - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "total", - "optional": false, - "type": "number" - } - ], - "name": "Pagination" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "clients", - "optional": false, - "type": { - "kind": "tuple", - "elements": [] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - } - }, - { - "name": "regenerateClientSecret", - "description": "Regenerates the secret for an OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "clientId", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "client_id", - "optional": false, - "description": "Unique identifier for the OAuth client", - "type": "string" - }, - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_secret", - "optional": true, - "description": "Client secret (only returned on registration and regeneration)", - "type": "string" - }, - { - "name": "client_type", - "optional": false, - "description": "Type of OAuth client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "public" - }, - { - "kind": "literal", - "value": "confidential" - } - ] - } - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "description": "Timestamp when the client was created", - "type": "string" - }, - { - "name": "grant_types", - "optional": false, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "registration_type", - "optional": false, - "description": "Registration type of the client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "dynamic" - }, - { - "kind": "literal", - "value": "manual" - } - ] - } - }, - { - "name": "response_types", - "optional": false, - "description": "Array of allowed response types", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": false, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "description": "Timestamp when the client was last updated", - "type": "string" - } - ], - "name": "OAuthClient" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "updateClient", - "description": "Updates an existing OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "clientId", - "type": "string" - }, - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "client_name", - "optional": true, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "grant_types", - "optional": true, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": true, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "token_endpoint_auth_method", - "optional": true, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - } - ], - "name": "UpdateOAuthClientParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "client_id", - "optional": false, - "description": "Unique identifier for the OAuth client", - "type": "string" - }, - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_secret", - "optional": true, - "description": "Client secret (only returned on registration and regeneration)", - "type": "string" - }, - { - "name": "client_type", - "optional": false, - "description": "Type of OAuth client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "public" - }, - { - "kind": "literal", - "value": "confidential" - } - ] - } - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "description": "Timestamp when the client was created", - "type": "string" - }, - { - "name": "grant_types", - "optional": false, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "registration_type", - "optional": false, - "description": "Registration type of the client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "dynamic" - }, - { - "kind": "literal", - "value": "manual" - } - ] - } - }, - { - "name": "response_types", - "optional": false, - "description": "Array of allowed response types", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": false, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "description": "Timestamp when the client was last updated", - "type": "string" - } - ], - "name": "OAuthClient" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "challenge", - "description": "Prepares a challenge used to verify that a user has access to a MFA factor.", - "remarks": [ - "- An [enrolled factor](/docs/reference/javascript/auth-mfa-enroll) is required before creating a challenge. - To verify a challenge, see [`mfa.verify()`](/docs/reference/javascript/auth-mfa-verify). - A phone factor sends a code to the user upon challenge. The channel defaults to `sms` unless otherwise specified." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "factorId", - "optional": false, - "description": "ID of the factor to be challenged. Returned in enroll().", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "expires_at", - "optional": false, - "description": "Timestamp in UNIX seconds when this challenge will no longer be usable.", - "type": "number" - }, - { - "name": "id", - "optional": false, - "description": "ID of the newly created challenge.", - "type": "string" - }, - { - "name": "type", - "optional": false, - "description": "Factor Type which generated the challenge", - "type": { - "kind": "literal", - "value": "totp" - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create a challenge for a factor", - "code": "const { data, error } = await supabase.auth.mfa.challenge({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225'\n})", - "response": "{\n data: {\n id: '',\n type: 'totp',\n expires_at: 1700000000\n },\n error: null\n}" - }, - { - "title": "Create a challenge for a phone factor", - "code": "const { data, error } = await supabase.auth.mfa.challenge({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n})", - "response": "{\n data: {\n id: '',\n type: 'phone',\n expires_at: 1700000000\n },\n error: null\n}" - }, - { - "title": "Create a challenge for a phone factor (WhatsApp)", - "code": "const { data, error } = await supabase.auth.mfa.challenge({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n channel: 'whatsapp',\n})", - "response": "{\n data: {\n id: '',\n expires_at: 1700000000\n },\n error: null\n}" - } - ] - }, - { - "name": "challengeAndVerify", - "description": "Helper method which creates a challenge and immediately uses the given code to verify against it thereafter. The verification code is provided by the user by entering a code seen in their authenticator app.", - "remarks": [ - "- Intended for use with only TOTP factors. - An [enrolled factor](/docs/reference/javascript/auth-mfa-enroll) is required before invoking `challengeAndVerify()`. - Executes [`mfa.challenge()`](/docs/reference/javascript/auth-mfa-challenge) and [`mfa.verify()`](/docs/reference/javascript/auth-mfa-verify) in a single step." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "code", - "optional": false, - "description": "Verification code provided by the user.", - "type": "string" - }, - { - "name": "factorId", - "optional": false, - "description": "ID of the factor being verified. Returned in enroll().", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "New access token (JWT) after successful verification.", - "type": "string" - }, - { - "name": "expires_in", - "optional": false, - "description": "Number of seconds in which the access token will expire.", - "type": "number" - }, - { - "name": "refresh_token", - "optional": false, - "description": "Refresh token you can use to obtain new access tokens when expired.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "description": "Type of token, always `bearer`.", - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "Updated user profile.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ], - "name": "AuthMFAVerifyResponseData" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create and verify a challenge for a factor", - "code": "const { data, error } = await supabase.auth.mfa.challengeAndVerify({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n code: '123456'\n})", - "response": "{\n data: {\n access_token: '',\n token_type: 'Bearer',\n expires_in: 3600,\n refresh_token: '',\n user: {\n id: '11111111-1111-1111-1111-111111111111',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com',\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {\n provider: 'email',\n providers: [\n \"email\",\n ]\n },\n user_metadata: {},\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false,\n factors: [\n \"id\": '',\n \"friendly_name\": 'Important Auth App',\n \"factor_type\": 'totp',\n \"status\": 'verified',\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n ]\n }\n }\n error: null\n}" - } - ] - }, - { - "name": "enroll", - "description": "Starts the enrollment process for a new Multi-Factor Authentication (MFA) factor. This method creates a new `unverified` factor. To verify a factor, present the QR code or secret to the user and ask them to add it to their authenticator app. The user has to enter the code from their authenticator app to verify it.\nUpon verifying a factor, all other sessions are logged out and the current session's authenticator level is promoted to `aal2`.", - "remarks": [ - "- Use `totp` or `phone` as the `factorType` and use the returned `id` to create a challenge. - To create a challenge, see [`mfa.challenge()`](/docs/reference/javascript/auth-mfa-challenge). - To verify a challenge, see [`mfa.verify()`](/docs/reference/javascript/auth-mfa-verify). - To create and verify a TOTP challenge in a single step, see [`mfa.challengeAndVerify()`](/docs/reference/javascript/auth-mfa-challengeandverify). - To generate a QR code for the `totp` secret in Next.js, you can do the following: ```html {data.totp.uri} ``` - The `challenge` and `verify` steps are separated when using Phone factors as the user will need time to receive and input the code obtained from the SMS in challenge." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "factorType", - "optional": false, - "description": "The type of factor being enrolled.", - "type": { - "kind": "literal", - "value": "totp" - } - }, - { - "name": "friendlyName", - "optional": true, - "description": "Human readable name assigned to the factor.", - "type": "string" - }, - { - "name": "issuer", - "optional": true, - "description": "Domain which the user is enrolled with.", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Enroll a time-based, one-time password (TOTP) factor", - "code": "const { data, error } = await supabase.auth.mfa.enroll({\n factorType: 'totp',\n friendlyName: 'your_friendly_name'\n})\n\n// Use the id to create a challenge.\n// The challenge can be verified by entering the code generated from the authenticator app.\n// The code will be generated upon scanning the qr_code or entering the secret into the authenticator app.\nconst { id, type, totp: { qr_code, secret, uri }, friendly_name } = data\nconst challenge = await supabase.auth.mfa.challenge({ factorId: id });", - "response": "{\n data: {\n id: '',\n type: 'totp'\n totp: {\n qr_code: '',\n secret: '',\n uri: '',\n }\n friendly_name?: 'Important app'\n },\n error: null\n}" - }, - { - "title": "Enroll a Phone Factor", - "code": "const { data, error } = await supabase.auth.mfa.enroll({\n factorType: 'phone',\n friendlyName: 'your_friendly_name',\n phone: '+12345678',\n})\n\n// Use the id to create a challenge and send an SMS with a code to the user.\nconst { id, type, friendly_name, phone } = data\n\nconst challenge = await supabase.auth.mfa.challenge({ factorId: id });", - "response": "{\n data: {\n id: '',\n type: 'phone',\n friendly_name?: 'Important app',\n phone: '+5787123456'\n },\n error: null\n}" - } - ] - }, - { - "name": "getAuthenticatorAssuranceLevel", - "description": "Returns the Authenticator Assurance Level (AAL) for the active session.\n- `aal1` (or `null`) means that the user's identity has been verified only with a conventional login (email+password, OTP, magic link, social login, etc.). - `aal2` means that the user's identity has been verified both with a conventional login and at least one MFA factor.\nWhen called without a JWT parameter, this method is fairly quick (microseconds) and rarely uses the network. When a JWT is provided (useful in server-side environments like Edge Functions where no session is stored), this method will make a network request to validate the user and fetch their MFA factors.", - "remarks": [ - "- Authenticator Assurance Level (AAL) is the measure of the strength of an authentication mechanism. - In Supabase, having an AAL of `aal1` refers to having the 1st factor of authentication such as an email and password or OAuth sign-in while `aal2` refers to the 2nd factor of authentication such as a time-based, one-time-password (TOTP) or Phone factor. - If the user has a verified factor, the `nextLevel` field will return `aal2`, else, it will return `aal1`. - An optional `jwt` parameter can be passed to check the AAL level of a specific JWT instead of the current session." - ], - "parameters": [ - { - "name": "jwt", - "optional": true, - "description": "Takes in an optional access token JWT. If no JWT is provided, the JWT from the current session is used.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "currentAuthenticationMethods", - "optional": false, - "description": "A list of all authentication methods attached to this session. Use the information here to detect the last time a user verified a factor, for example if implementing a step-up scenario.\nSupports both RFC-8176 compliant format (string[]) and detailed format (AMREntry[]). - String format: ['password', 'otp'] - RFC-8176 compliant - Object format: [{ method: 'password', timestamp: 1234567890 }] - includes timestamps", - "type": { - "kind": "union", - "types": [ - { - "kind": "array", - "elementType": { - "kind": "object", - "name": "AMREntry", - "properties": [ - { - "name": "method", - "optional": false, - "description": "Authentication method name.", - "type": { - "kind": "union", - "types": [ - { - "kind": "indexedAccess", - "objectType": { - "kind": "query" - }, - "indexType": null - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "timestamp", - "optional": false, - "description": "Timestamp when the method was successfully used. Represents number of seconds since 1st January 1970 (UNIX epoch) in UTC.", - "type": "number" - } - ] - } - }, - { - "kind": "array", - "elementType": "string" - } - ] - } - }, - { - "name": "currentLevel", - "optional": false, - "description": "Current AAL level of the session.", - "type": { - "kind": "union", - "types": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "aal1" - }, - { - "kind": "literal", - "value": "aal2" - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "nextLevel", - "optional": false, - "description": "Next possible AAL level for the session. If the next level is higher than the current one, the user should go through MFA.", - "type": { - "kind": "union", - "types": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "aal1" - }, - { - "kind": "literal", - "value": "aal2" - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get the AAL details of a session", - "code": "const { data, error } = await supabase.auth.mfa.getAuthenticatorAssuranceLevel()\nconst { currentLevel, nextLevel, currentAuthenticationMethods } = data", - "response": "{\n data: {\n currentLevel: 'aal1',\n nextLevel: 'aal2',\n currentAuthenticationMethods: [\n {\n method: 'password',\n timestamp: 1700000000\n }\n ]\n }\n error: null\n}" - }, - { - "title": "Get the AAL details for a specific JWT", - "code": "const { data, error } = await supabase.auth.mfa.getAuthenticatorAssuranceLevel(jwt)" - } - ] - }, - { - "name": "listFactors", - "description": "Returns the list of MFA factors enabled for this user.", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "intersection", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "all", - "optional": false, - "description": "All available factors (verified and unverified).", - "type": { - "kind": "array", - "elementType": { - "kind": "conditional" - } - } - } - ] - }, - { - "kind": "mapped" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "unenroll", - "description": "Unenroll removes a MFA factor. A user has to have an `aal2` authenticator level in order to unenroll a `verified` factor.", - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "factorId", - "optional": false, - "description": "ID of the factor being unenrolled.", - "type": "string" - } - ], - "name": "MFAUnenrollParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "id", - "optional": false, - "description": "ID of the factor that was successfully unenrolled.", - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Unenroll a factor", - "code": "const { data, error } = await supabase.auth.mfa.unenroll({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n})", - "response": "{\n data: {\n id: ''\n },\n error: null\n}" - } - ] - }, - { - "name": "verify", - "description": "Verifies a code against a challenge. The verification code is provided by the user by entering a code seen in their authenticator app.", - "remarks": [ - "- To verify a challenge, please [create a challenge](/docs/reference/javascript/auth-mfa-challenge) first." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "challengeId", - "optional": false, - "description": "ID of the challenge being verified. Returned in challenge().", - "type": "string" - }, - { - "name": "code", - "optional": false, - "description": "Verification code provided by the user.", - "type": "string" - }, - { - "name": "factorId", - "optional": false, - "description": "ID of the factor being verified. Returned in enroll().", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "New access token (JWT) after successful verification.", - "type": "string" - }, - { - "name": "expires_in", - "optional": false, - "description": "Number of seconds in which the access token will expire.", - "type": "number" - }, - { - "name": "refresh_token", - "optional": false, - "description": "Refresh token you can use to obtain new access tokens when expired.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "description": "Type of token, always `bearer`.", - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "Updated user profile.", - "type": { - "kind": "object", - "name": "User", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - }, - { - "kind": "literal", - "value": "webauthn" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ], - "name": "AuthMFAVerifyResponseData" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Verify a challenge for a factor", - "code": "const { data, error } = await supabase.auth.mfa.verify({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n challengeId: '4034ae6f-a8ce-4fb5-8ee5-69a5863a7c15',\n code: '123456'\n})", - "response": "{\n data: {\n access_token: '',\n token_type: 'Bearer',\n expires_in: 3600,\n refresh_token: '',\n user: {\n id: '11111111-1111-1111-1111-111111111111',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com',\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {\n provider: 'email',\n providers: [\n \"email\",\n ]\n },\n user_metadata: {},\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false,\n factors: [\n \"id\": '',\n \"friendly_name\": 'Important Auth App',\n \"factor_type\": 'totp',\n \"status\": 'verified',\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n ]\n }\n }\n error: null\n}" - } - ] - }, - { - "name": "createUser", - "description": "Creates a new user. This function should only be called on a server. Never expose your `service_role` key in the browser.", - "remarks": [ - "- To confirm the user's email address or phone number, set `email_confirm` or `phone_confirm` to true. Both arguments default to false. - `createUser()` will not send a confirmation email to the user. You can use [`inviteUserByEmail()`](/docs/reference/javascript/auth-admin-inviteuserbyemail) if you want to send them an email invite instead. - If you are sure that the created user's email or phone number is legitimate and verified, you can set the `email_confirm` or `phone_confirm` param to `true`." - ], - "parameters": [ - { - "name": "attributes", - "type": { - "kind": "object", - "name": "AdminUserAttributes", - "properties": [ - { - "name": "app_metadata", - "optional": true, - "description": "A custom data object to store the user's application specific metadata. This maps to the `auth.users.app_metadata` column.\nOnly a service role can modify.\nThe `app_metadata` should be a JSON object that includes app-specific info, such as identity providers, roles, and other access control information.", - "type": "object" - }, - { - "name": "ban_duration", - "optional": true, - "description": "Determines how long a user is banned for.\nThe format for the ban duration follows a strict sequence of decimal numbers with a unit suffix. Valid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\".\nFor example, some possible durations include: '300ms', '2h45m'.\nSetting the ban duration to 'none' lifts the ban on the user.", - "type": "string" - }, - { - "name": "current_password", - "optional": true, - "description": "The user's current password\nThis is only ever present when the user is resetting their password and GOTRUE_SECURITY_UPDATE_PASSWORD_REQUIRE_CURRENT_PASSWORD is true.", - "type": "string" - }, - { - "name": "email", - "optional": true, - "description": "The user's email.", - "type": "string" - }, - { - "name": "email_confirm", - "optional": true, - "description": "Sets the user's email as confirmed when true, or unconfirmed when false.\nOnly a service role can modify.", - "type": "boolean" - }, - { - "name": "id", - "optional": true, - "description": "The `id` for the user.\nAllows you to overwrite the default `id` set for the user.", - "type": "string" - }, - { - "name": "nonce", - "optional": true, - "description": "The nonce sent for reauthentication if the user's password is to be updated.\nCall reauthenticate() to obtain the nonce first.", - "type": "string" - }, - { - "name": "password", - "optional": true, - "description": "The user's password.", - "type": "string" - }, - { - "name": "password_hash", - "optional": true, - "description": "The `password_hash` for the user's password.\nAllows you to specify a password hash for the user. This is useful for migrating a user's password hash from another service.\nSupports bcrypt, scrypt (firebase), and argon2 password hashes.", - "type": "string" - }, - { - "name": "phone", - "optional": true, - "description": "The user's phone.", - "type": "string" - }, - { - "name": "phone_confirm", - "optional": true, - "description": "Sets the user's phone as confirmed when true, or unconfirmed when false.\nOnly a service role can modify.", - "type": "boolean" - }, - { - "name": "role", - "optional": true, - "description": "The `role` claim set in the user's access token JWT.\nWhen a user signs up, this role is set to `authenticated` by default. You should only modify the `role` if you need to provision several levels of admin access that have different permissions on individual columns in your database.\nSetting this role to `service_role` is not recommended as it grants the user admin privileges.", - "type": "string" - }, - { - "name": "user_metadata", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `user_metadata` should be a JSON object that includes user-specific info, such as their first and last name.\nNote: When using the GoTrueAdminApi and wanting to modify a user's metadata, this attribute is used instead of UserAttributes data.", - "type": "object" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "With custom user metadata", - "code": "const { data, error } = await supabase.auth.admin.createUser({\n email: 'user@email.com',\n password: 'password',\n user_metadata: { name: 'Yoda' }\n})", - "response": "{\n data: {\n user: {\n id: '1',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com',\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {},\n user_metadata: {},\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"1\",\n \"user_id\": \"1\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"phone_verified\": false,\n \"sub\": \"1\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false,\n }\n }\n error: null\n}" - }, - { - "title": "Auto-confirm the user's email", - "code": "const { data, error } = await supabase.auth.admin.createUser({\n email: 'user@email.com',\n email_confirm: true\n})" - }, - { - "title": "Auto-confirm the user's phone number", - "code": "const { data, error } = await supabase.auth.admin.createUser({\n phone: '1234567890',\n phone_confirm: true\n})" - } - ] - }, - { - "name": "deleteUser", - "description": "Delete a user. Requires a `service_role` key.", - "remarks": [ - "- The `deleteUser()` method requires the user's ID, which maps to the `auth.users.id` column." - ], - "parameters": [ - { - "name": "id", - "description": "The user id you want to remove.", - "type": "string" - }, - { - "name": "shouldSoftDelete", - "optional": true, - "description": "If true, then the user will be soft-deleted from the auth schema. Soft deletion allows user identification from the hashed user ID but is not reversible. Defaults to false for backward compatibility.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "type": "boolean" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Removes a user", - "code": "const { data, error } = await supabase.auth.admin.deleteUser(\n '715ed5db-f090-4b8c-a067-640ecee36aa0'\n)", - "response": "{\n \"data\": {\n \"user\": {}\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "generateLink", - "description": "Generates email links and OTPs to be sent via a custom email provider.", - "remarks": [ - "- 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`." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "reference", - "name": "Pick", - "typeArguments": [ - { - "kind": "object", - "name": "GenerateLinkOptions", - "properties": [ - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL which will be appended to the email link generated.", - "type": "string" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "data" - }, - { - "kind": "literal", - "value": "redirectTo" - } - ] - } - ] - } - }, - { - "name": "password", - "optional": false, - "type": "string" - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "literal", - "value": "signup" - } - } - ], - "name": "GenerateSignupLinkParams" - }, - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "description": "The user's email", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "reference", - "name": "Pick", - "typeArguments": [ - { - "kind": "object", - "name": "GenerateLinkOptions", - "properties": [ - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL which will be appended to the email link generated.", - "type": "string" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "data" - }, - { - "kind": "literal", - "value": "redirectTo" - } - ] - } - ] - } - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "invite" - }, - { - "kind": "literal", - "value": "magiclink" - } - ] - } - } - ], - "name": "GenerateInviteOrMagiclinkParams" - }, - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "description": "The user's email", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "reference", - "name": "Pick", - "typeArguments": [ - { - "kind": "object", - "name": "GenerateLinkOptions", - "properties": [ - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL which will be appended to the email link generated.", - "type": "string" - } - ] - }, - { - "kind": "literal", - "value": "redirectTo" - } - ] - } - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "literal", - "value": "recovery" - } - } - ], - "name": "GenerateRecoveryLinkParams" - }, - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "description": "The user's email", - "type": "string" - }, - { - "name": "newEmail", - "optional": false, - "description": "The user's new email. Only required if type is 'email_change_current' or 'email_change_new'.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "reference", - "name": "Pick", - "typeArguments": [ - { - "kind": "object", - "name": "GenerateLinkOptions", - "properties": [ - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL which will be appended to the email link generated.", - "type": "string" - } - ] - }, - { - "kind": "literal", - "value": "redirectTo" - } - ] - } - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "email_change_current" - }, - { - "kind": "literal", - "value": "email_change_new" - } - ] - } - } - ], - "name": "GenerateEmailChangeLinkParams" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "properties", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "action_link", - "optional": false, - "description": "The email link to send to the user. The action_link follows the following format: auth/v1/verify?type={verification_type}&token={hashed_token}&redirect_to={redirect_to}", - "type": "string" - }, - { - "name": "email_otp", - "optional": false, - "description": "The raw email OTP. You should send this in the email if you want your users to verify using an OTP instead of the action link.", - "type": "string" - }, - { - "name": "hashed_token", - "optional": false, - "description": "The hashed token appended to the action link.", - "type": "string" - }, - { - "name": "redirect_to", - "optional": false, - "description": "The URL appended to the action link.", - "type": "string" - }, - { - "name": "verification_type", - "optional": false, - "description": "The verification type that the email link is associated to.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "signup" - }, - { - "kind": "literal", - "value": "invite" - }, - { - "kind": "literal", - "value": "magiclink" - }, - { - "kind": "literal", - "value": "recovery" - }, - { - "kind": "literal", - "value": "email_change_current" - }, - { - "kind": "literal", - "value": "email_change_new" - } - ] - } - } - ], - "name": "GenerateLinkProperties" - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Generate a signup link", - "code": "const { data, error } = await supabase.auth.admin.generateLink({\n type: 'signup',\n email: 'email@example.com',\n password: 'secret'\n})", - "response": "{\n \"data\": {\n \"properties\": {\n \"action_link\": \"\",\n \"email_otp\": \"999999\",\n \"hashed_token\": \"\",\n \"verification_type\": \"signup\"\n },\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"email@example.com\",\n \"phone\": \"\",\n \"confirmation_sent_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"email@example.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}" - }, - { - "title": "Generate an invite link", - "code": "const { data, error } = await supabase.auth.admin.generateLink({\n type: 'invite',\n email: 'email@example.com'\n})" - }, - { - "title": "Generate a magic link", - "code": "const { data, error } = await supabase.auth.admin.generateLink({\n type: 'magiclink',\n email: 'email@example.com'\n})" - }, - { - "title": "Generate a recovery link", - "code": "const { data, error } = await supabase.auth.admin.generateLink({\n type: 'recovery',\n email: 'email@example.com'\n})" - }, - { - "title": "Generate links to change current email address", - "code": "// generate an email change link to be sent to the current email address\nconst { data, error } = await supabase.auth.admin.generateLink({\n type: 'email_change_current',\n email: 'current.email@example.com',\n newEmail: 'new.email@example.com'\n})\n\n// generate an email change link to be sent to the new email address\nconst { data, error } = await supabase.auth.admin.generateLink({\n type: 'email_change_new',\n email: 'current.email@example.com',\n newEmail: 'new.email@example.com'\n})" - } - ] - }, - { - "name": "getUserById", - "description": "Get user by id.", - "remarks": [ - "- Fetches the user object from the database based on the user's id. - The `getUserById()` method requires the user's id which maps to the `auth.users.id` column." - ], - "parameters": [ - { - "name": "uid", - "description": "The user's unique identifier\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Fetch the user object using the access_token jwt", - "code": "const { data, error } = await supabase.auth.admin.getUserById(1)", - "response": "{\n data: {\n user: {\n id: '1',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com',\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {},\n user_metadata: {},\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"1\",\n \"user_id\": \"1\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"phone_verified\": false,\n \"sub\": \"1\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false,\n }\n }\n error: null\n}" - } - ] - }, - { - "name": "inviteUserByEmail", - "description": "Sends an invite link to an email address.", - "remarks": [ - "- Sends an invite link to the user's email address. - The `inviteUserByEmail()` method is typically used by administrators to invite users to join the application. - Note that PKCE is not supported when using `inviteUserByEmail`. This is because the browser initiating the invite is often different from the browser accepting the invite which makes it difficult to provide the security guarantees required of the PKCE flow." - ], - "parameters": [ - { - "name": "email", - "description": "The email address of the user.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "description": "Additional options to be included when inviting.", - "type": { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": true, - "description": "A custom data object to store additional metadata about the user. This maps to the `auth.users.user_metadata` column.", - "type": "object" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL which will be appended to the email link sent to the user's email address. Once clicked the user will end up on this URL.", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Invite a user", - "code": "const { data, error } = await supabase.auth.admin.inviteUserByEmail('email@example.com')", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"invited_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmation_sent_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "listUsers", - "description": "Get a list of users.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "remarks": [ - "- Defaults to return 50 users per page." - ], - "parameters": [ - { - "name": "params", - "optional": true, - "description": "An object which supports `page` and `perPage` as numbers, to alter the paginated results.", - "type": { - "kind": "object", - "properties": [ - { - "name": "page", - "optional": true, - "description": "The page number", - "type": "number" - }, - { - "name": "perPage", - "optional": true, - "description": "Number of items returned per page", - "type": "number" - } - ], - "name": "PageParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "intersection", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "users", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "lastPage", - "optional": false, - "type": "number" - }, - { - "name": "nextPage", - "optional": false, - "type": { - "kind": "union", - "types": [ - "number", - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "total", - "optional": false, - "type": "number" - } - ], - "name": "Pagination" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "users", - "optional": false, - "type": { - "kind": "tuple", - "elements": [] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get a page of users", - "code": "const { data: { users }, error } = await supabase.auth.admin.listUsers()" - }, - { - "title": "Paginated list of users", - "code": "const { data: { users }, error } = await supabase.auth.admin.listUsers({\n page: 1,\n perPage: 1000\n})" - } - ] - }, - { - "name": "signOut", - "description": "Removes a logged-in session.", - "parameters": [ - { - "name": "jwt", - "description": "A valid, logged-in JWT.", - "type": "string" - }, - { - "name": "scope", - "optional": true, - "description": "The logout sope.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "global" - }, - { - "kind": "literal", - "value": "local" - }, - { - "kind": "literal", - "value": "others" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - ] - } - } - ] - } - ] - } - }, - { - "name": "updateUserById", - "description": "Updates the user data. Changes are applied directly without confirmation flows.", - "remarks": [ - "**Important:** This is a server-side operation and does **not** trigger client-side `onAuthStateChange` listeners. The admin API has no connection to client state.\nTo sync changes to the client after calling this method: 1. On the client, call `supabase.auth.refreshSession()` to fetch the updated user data 2. This will trigger the `TOKEN_REFRESHED` event and notify all listeners" - ], - "parameters": [ - { - "name": "uid", - "description": "The user's unique identifier", - "type": "string" - }, - { - "name": "attributes", - "description": "The data you want to update.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "type": { - "kind": "object", - "name": "AdminUserAttributes", - "properties": [ - { - "name": "app_metadata", - "optional": true, - "description": "A custom data object to store the user's application specific metadata. This maps to the `auth.users.app_metadata` column.\nOnly a service role can modify.\nThe `app_metadata` should be a JSON object that includes app-specific info, such as identity providers, roles, and other access control information.", - "type": "object" - }, - { - "name": "ban_duration", - "optional": true, - "description": "Determines how long a user is banned for.\nThe format for the ban duration follows a strict sequence of decimal numbers with a unit suffix. Valid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\".\nFor example, some possible durations include: '300ms', '2h45m'.\nSetting the ban duration to 'none' lifts the ban on the user.", - "type": "string" - }, - { - "name": "current_password", - "optional": true, - "description": "The user's current password\nThis is only ever present when the user is resetting their password and GOTRUE_SECURITY_UPDATE_PASSWORD_REQUIRE_CURRENT_PASSWORD is true.", - "type": "string" - }, - { - "name": "email", - "optional": true, - "description": "The user's email.", - "type": "string" - }, - { - "name": "email_confirm", - "optional": true, - "description": "Sets the user's email as confirmed when true, or unconfirmed when false.\nOnly a service role can modify.", - "type": "boolean" - }, - { - "name": "id", - "optional": true, - "description": "The `id` for the user.\nAllows you to overwrite the default `id` set for the user.", - "type": "string" - }, - { - "name": "nonce", - "optional": true, - "description": "The nonce sent for reauthentication if the user's password is to be updated.\nCall reauthenticate() to obtain the nonce first.", - "type": "string" - }, - { - "name": "password", - "optional": true, - "description": "The user's password.", - "type": "string" - }, - { - "name": "password_hash", - "optional": true, - "description": "The `password_hash` for the user's password.\nAllows you to specify a password hash for the user. This is useful for migrating a user's password hash from another service.\nSupports bcrypt, scrypt (firebase), and argon2 password hashes.", - "type": "string" - }, - { - "name": "phone", - "optional": true, - "description": "The user's phone.", - "type": "string" - }, - { - "name": "phone_confirm", - "optional": true, - "description": "Sets the user's phone as confirmed when true, or unconfirmed when false.\nOnly a service role can modify.", - "type": "boolean" - }, - { - "name": "role", - "optional": true, - "description": "The `role` claim set in the user's access token JWT.\nWhen a user signs up, this role is set to `authenticated` by default. You should only modify the `role` if you need to provision several levels of admin access that have different permissions on individual columns in your database.\nSetting this role to `service_role` is not recommended as it grants the user admin privileges.", - "type": "string" - }, - { - "name": "user_metadata", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `user_metadata` should be a JSON object that includes user-specific info, such as their first and last name.\nNote: When using the GoTrueAdminApi and wanting to modify a user's metadata, this attribute is used instead of UserAttributes data.", - "type": "object" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Example 1", - "code": "// Server-side (Edge Function)\nconst { data, error } = await supabase.auth.admin.updateUserById(\n userId,\n { user_metadata: { preferences: { theme: 'dark' } } }\n)\n\n// Client-side (to sync the changes)\nconst { data, error } = await supabase.auth.refreshSession()\n// onAuthStateChange listeners will now be notified with updated user", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"new@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"recovery_sent_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}" - }, - { - "title": "Updates a user's email", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '11111111-1111-1111-1111-111111111111',\n { email: 'new@email.com' }\n)", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"new@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"recovery_sent_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}" - }, - { - "title": "Updates a user's password", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { password: 'new_password' }\n)" - }, - { - "title": "Updates a user's metadata", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { user_metadata: { hello: 'world' } }\n)" - }, - { - "title": "Updates a user's app_metadata", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { app_metadata: { plan: 'trial' } }\n)" - }, - { - "title": "Confirms a user's email address", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { email_confirm: true }\n)" - }, - { - "title": "Confirms a user's phone number", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { phone_confirm: true }\n)" - }, - { - "title": "Ban a user for 100 years", - "code": "const { data: user, error } = await supabase.auth.admin.updateUserById(\n '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',\n { ban_duration: '876000h' }\n)" - } - ] - }, - { - "name": "exchangeCodeForSession", - "description": "Log in an existing user by exchanging an Auth Code issued during the PKCE flow.", - "remarks": [ - "- Used when `flowType` is set to `pkce` in client options." - ], - "parameters": [ - { - "name": "authCode", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Exchange Auth Code", - "code": "supabase.auth.exchangeCodeForSession('34e770dd-9ff9-416c-87fa-43b31d7ef225')", - "response": "{\n \"data\": {\n session: {\n access_token: '',\n token_type: 'bearer',\n expires_in: 3600,\n expires_at: 1700000000,\n refresh_token: '',\n user: {\n id: '11111111-1111-1111-1111-111111111111',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com'\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {\n \"provider\": \"email\",\n \"providers\": [\n \"email\",\n \"\"\n ]\n },\n user_metadata: {\n email: 'email@email.com',\n email_verified: true,\n full_name: 'User Name',\n iss: '',\n name: 'User Name',\n phone_verified: false,\n provider_id: '',\n sub: ''\n },\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n {\n \"identity_id\": \"33333333-3333-3333-3333-333333333333\",\n \"id\": \"\",\n \"user_id\": \"\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"full_name\": \"User Name\",\n \"iss\": \"\",\n \"name\": \"User Name\",\n \"phone_verified\": false,\n \"provider_id\": \"\",\n \"sub\": \"\"\n },\n \"provider\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false\n },\n provider_token: '',\n provider_refresh_token: ''\n },\n user: {\n id: '11111111-1111-1111-1111-111111111111',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com',\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {\n provider: 'email',\n providers: [\n \"email\",\n \"\"\n ]\n },\n user_metadata: {\n email: 'email@email.com',\n email_verified: true,\n full_name: 'User Name',\n iss: '',\n name: 'User Name',\n phone_verified: false,\n provider_id: '',\n sub: ''\n },\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n {\n \"identity_id\": \"33333333-3333-3333-3333-333333333333\",\n \"id\": \"\",\n \"user_id\": \"\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"full_name\": \"User Name\",\n \"iss\": \"\",\n \"name\": \"User Name\",\n \"phone_verified\": false,\n \"provider_id\": \"\",\n \"sub\": \"\"\n },\n \"provider\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false\n },\n redirectType: null\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "getClaims", - "description": "Extracts the JWT claims present in the access token by first verifying the JWT against the server's JSON Web Key Set endpoint `/.well-known/jwks.json` which is often cached, resulting in significantly faster responses. Prefer this method over #getUser which always sends a request to the Auth server for each JWT.\nIf the project is not using an asymmetric JWT signing key (like ECC or RSA) it always sends a request to the Auth server (similar to #getUser) to verify the JWT.", - "remarks": [ - "- Parses the user's [access token](/docs/guides/auth/sessions#access-token-jwt-claims) as a [JSON Web Token (JWT)](/docs/guides/auth/jwts) and returns its components if valid and not expired. - If your project is using asymmetric JWT signing keys, then the verification is done locally usually without a network request using the [WebCrypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API). - A network request is sent to your project's JWT signing key discovery endpoint `https://project-id.supabase.co/auth/v1/.well-known/jwks.json`, which is cached locally. If your environment is ephemeral, such as a Lambda function that is destroyed after every request, a network request will be sent for each new invocation. Supabase provides a network-edge cache providing fast responses for these situations. - If the user's access token is about to expire when calling this function, the user's session will first be refreshed before validating the JWT. - If your project is using a symmetric secret to sign the JWT, it always sends a request similar to `getUser()` to validate the JWT at the server before returning the decoded token. This is also used if the WebCrypto API is not available in the environment. Make sure you polyfill it in such situations. - The returned claims can be customized per project using the [Custom Access Token Hook](/docs/guides/auth/auth-hooks/custom-access-token-hook)." - ], - "parameters": [ - { - "name": "jwt", - "optional": true, - "description": "An optional specific JWT you wish to verify, not the one you can obtain from #getSession.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "description": "Various additional options that allow you to customize the behavior of this method.", - "type": { - "kind": "object", - "properties": [ - { - "name": "allowExpired", - "optional": true, - "description": "If set to `true` the `exp` claim will not be validated against the current time.", - "type": "boolean" - }, - { - "name": "jwks", - "optional": true, - "description": "If set, this JSON Web Key Set is going to have precedence over the cached value available on the server.", - "type": { - "kind": "object", - "properties": [ - { - "name": "keys", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "JWK", - "properties": [ - { - "name": "alg", - "optional": true, - "type": "string" - }, - { - "name": "key_ops", - "optional": false, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "kid", - "optional": true, - "type": "string" - }, - { - "name": "kty", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "RSA" - }, - { - "kind": "literal", - "value": "EC" - }, - { - "kind": "literal", - "value": "oct" - } - ] - } - } - ] - } - } - } - ] - } - }, - { - "name": "keys", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "JWK", - "properties": [ - { - "name": "alg", - "optional": true, - "type": "string" - }, - { - "name": "key_ops", - "optional": false, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "kid", - "optional": true, - "type": "string" - }, - { - "name": "kty", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "RSA" - }, - { - "kind": "literal", - "value": "EC" - }, - { - "kind": "literal", - "value": "oct" - } - ] - } - } - ] - } - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "claims", - "optional": false, - "type": { - "kind": "object", - "name": "JwtPayload", - "properties": [ - { - "name": "aal", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "aal1" - }, - { - "kind": "literal", - "value": "aal2" - } - ] - } - }, - { - "name": "amr", - "optional": true, - "description": "Authentication Method References. Supports both RFC-8176 compliant format (string[]) and detailed format (AMREntry[]). - String format: ['password', 'otp'] - RFC-8176 compliant - Object format: [{ method: 'password', timestamp: 1234567890 }] - includes timestamps", - "type": { - "kind": "union", - "types": [ - { - "kind": "array", - "elementType": "string" - }, - { - "kind": "array", - "elementType": { - "kind": "object", - "name": "AMREntry", - "properties": [ - { - "name": "method", - "optional": false, - "description": "Authentication method name.", - "type": { - "kind": "union", - "types": [ - { - "kind": "indexedAccess", - "objectType": { - "kind": "query" - }, - "indexType": null - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "timestamp", - "optional": false, - "description": "Timestamp when the method was successfully used. Represents number of seconds since 1st January 1970 (UNIX epoch) in UTC.", - "type": "number" - } - ] - } - } - ] - } - }, - { - "name": "app_metadata", - "optional": true, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": { - "kind": "union", - "types": [ - "string", - { - "kind": "array", - "elementType": "string" - } - ] - } - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "exp", - "optional": false, - "type": "number" - }, - { - "name": "iat", - "optional": false, - "type": "number" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "iss", - "optional": false, - "type": "string" - }, - { - "name": "jti", - "optional": true, - "type": "string" - }, - { - "name": "nbf", - "optional": true, - "type": "number" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "ref", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": false, - "type": "string" - }, - { - "name": "session_id", - "optional": false, - "type": "string" - }, - { - "name": "sub", - "optional": false, - "type": "string" - }, - { - "name": "user_metadata", - "optional": true, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - }, - { - "name": "header", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "alg", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "RS256" - }, - { - "kind": "literal", - "value": "ES256" - }, - { - "kind": "literal", - "value": "HS256" - } - ] - } - }, - { - "name": "kid", - "optional": false, - "type": "string" - }, - { - "name": "typ", - "optional": false, - "type": "string" - } - ], - "name": "JwtHeader" - } - }, - { - "name": "signature", - "optional": false, - "type": { - "kind": "reference", - "name": "Uint8Array" - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get JWT claims, header and signature", - "code": "const { data, error } = await supabase.auth.getClaims()", - "response": "{\n \"data\": {\n \"claims\": {\n \"aal\": \"aal1\",\n \"amr\": [{\n \"method\": \"email\",\n \"timestamp\": 1715766000\n }],\n \"app_metadata\": {},\n \"aud\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"exp\": 1715769600,\n \"iat\": 1715766000,\n \"is_anonymous\": false,\n \"iss\": \"https://project-id.supabase.co/auth/v1\",\n \"phone\": \"+13334445555\",\n \"role\": \"authenticated\",\n \"session_id\": \"11111111-1111-1111-1111-111111111111\",\n \"sub\": \"11111111-1111-1111-1111-111111111111\",\n \"user_metadata\": {}\n },\n \"header\": {\n \"alg\": \"RS256\",\n \"typ\": \"JWT\",\n \"kid\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"signature\": [/** Uint8Array */],\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "getSession", - "description": "Returns the session, refreshing it if necessary.\nThe session returned can be null if the session is not detected which can happen in the event a user is not signed-in or has logged out.\n**IMPORTANT:** This method loads values directly from the storage attached to the client. If that storage is based on request cookies for example, the values in it may not be authentic and therefore it's strongly advised against using this method and its results in such circumstances. A warning will be emitted if this is detected. Use #getUser() instead.", - "remarks": [ - "- Since the introduction of [asymmetric JWT signing keys](/docs/guides/auth/signing-keys), this method is considered low-level and we encourage you to use `getClaims()` or `getUser()` instead. - Retrieves the current [user session](/docs/guides/auth/sessions) from the storage medium (local storage, cookies). - The session contains an access token (signed JWT), a refresh token and the user object. - If the session's access token is expired or is about to expire, this method will use the refresh token to refresh the session. - When using in a browser, or you've called `startAutoRefresh()` in your environment (React Native, etc.) this function always returns a valid access token without refreshing the session itself, as this is done in the background. This function returns very fast. - **IMPORTANT SECURITY NOTICE:** If using an insecure storage medium, such as cookies or request headers, the user object returned by this function **must not be trusted**. Always verify the JWT using `getClaims()` or your own JWT verification library to securely establish the user's identity and access. You can also use `getUser()` to fetch the user object directly from the Auth server for this purpose. - When using in a browser, this function is synchronized across all tabs using the [LockManager](https://developer.mozilla.org/en-US/docs/Web/API/LockManager) API. In other environments make sure you've defined a proper `lock` property, if necessary, to make sure there are no race conditions while the session is being refreshed." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get the session data", - "code": "const { data, error } = await supabase.auth.getSession()", - "response": "{\n \"data\": {\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n }\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "getUser", - "description": "Gets the current user details if there is an existing session. This method performs a network request to the Supabase Auth server, so the returned value is authentic and can be used to base authorization rules on.", - "remarks": [ - "- This method fetches the user object from the database instead of local session. - This method is useful for checking if the user is authorized because it validates the user's access token JWT on the server. - Should always be used when checking for user authorization on the server. On the client, you can instead use `getSession().session.user` for faster results. `getSession` is insecure on the server." - ], - "parameters": [ - { - "name": "jwt", - "optional": true, - "description": "Takes in an optional access token JWT. If no JWT is provided, the JWT from the current session is used.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get the logged in user with the current existing session", - "code": "const { data: { user } } = await supabase.auth.getUser()", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}" - }, - { - "title": "Get the logged in user with a custom access token jwt", - "code": "const { data: { user } } = await supabase.auth.getUser(jwt)" - } - ] - }, - { - "name": "getUserIdentities", - "description": "Gets all the identities linked to a user.", - "remarks": [ - "- The user needs to be signed in to call `getUserIdentities()`." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "identities", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Returns a list of identities linked to the user", - "code": "const { data, error } = await supabase.auth.getUserIdentities()", - "response": "{\n \"data\": {\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"2024-01-01T00:00:00Z\",\n \"user_id\": \"2024-01-01T00:00:00Z\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ]\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "initialize", - "description": "Initializes the client session either from the url or from storage. This method is automatically called when instantiating the client, but should also be called manually when checking for an error from an auth redirect (oauth, magiclink, password recovery, etc).", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "object", - "properties": [ - { - "name": "error", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ], - "name": "InitializeResult" - } - ] - } - }, - { - "name": "reauthenticate", - "description": "Sends a reauthentication OTP to the user's email or phone number. Requires the user to be signed-in.", - "remarks": [ - "- This method is used together with `updateUser()` when a user's password needs to be updated. - If you require your user to reauthenticate before updating their password, you need to enable the **Secure password change** option in your [project's email provider settings](/dashboard/project/_/auth/providers). - A user is only require to reauthenticate before updating their password if **Secure password change** is enabled and the user **hasn't recently signed in**. A user is deemed recently signed in if the session was created in the last 24 hours. - This method will send a nonce to the user's email. If the user doesn't have a confirmed email address, the method will send the nonce to the user's confirmed phone number instead. - After receiving the OTP, include it as the `nonce` in your `updateUser()` call to finalize the password change." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Send reauthentication nonce", - "code": "const { error } = await supabase.auth.reauthenticate()", - "notes": "Sends a reauthentication nonce to the user's email or phone number." - } - ] - }, - { - "name": "refreshSession", - "description": "Returns a new session, regardless of expiry status. Takes in an optional current session. If not passed in, then refreshSession() will attempt to retrieve it from getSession(). If the current session's refresh token is invalid, an error will be thrown.", - "remarks": [ - "- This method will refresh and return a new session whether the current one is expired or not." - ], - "parameters": [ - { - "name": "currentSession", - "optional": true, - "description": "The current session. If passed in, it must contain a refresh token.", - "type": { - "kind": "object", - "properties": [ - { - "name": "refresh_token", - "optional": false, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Refresh session using the current session", - "code": "const { data, error } = await supabase.auth.refreshSession()\nconst { session, user } = data", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n }\n },\n \"error\": null\n}" - }, - { - "title": "Refresh session using a refresh token", - "code": "const { data, error } = await supabase.auth.refreshSession({ refresh_token })\nconst { session, user } = data" - } - ] - }, - { - "name": "resend", - "description": "Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP.", - "remarks": [ - "- Resends a signup confirmation, email change or phone change email to the user. - Passwordless sign-ins can be resent by calling the `signInWithOtp()` method again. - Password recovery emails can be resent by calling the `resetPasswordForEmail()` method again. - This method will only resend an email or phone OTP to the user if there was an initial signup, email change or phone change request being made(note: For existing users signing in with OTP, you should use `signInWithOtp()` again to resend the OTP). - You can specify a redirect url when you resend an email link using the `emailRedirectTo` option." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "emailRedirectTo", - "optional": true, - "description": "A URL to send the user to after they have signed-in.", - "type": "string" - } - ] - } - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "reference", - "name": "Extract", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "signup" - }, - { - "kind": "literal", - "value": "invite" - }, - { - "kind": "literal", - "value": "magiclink" - }, - { - "kind": "literal", - "value": "recovery" - }, - { - "kind": "literal", - "value": "email_change" - }, - { - "kind": "literal", - "value": "email" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "signup" - }, - { - "kind": "literal", - "value": "email_change" - } - ] - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - } - ] - } - }, - { - "name": "phone", - "optional": false, - "type": "string" - }, - { - "name": "type", - "optional": false, - "type": { - "kind": "reference", - "name": "Extract", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "sms" - }, - { - "kind": "literal", - "value": "phone_change" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "sms" - }, - { - "kind": "literal", - "value": "phone_change" - } - ] - } - ] - } - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "messageId", - "optional": true, - "type": { - "kind": "union", - "types": [ - "string", - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "session", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Resend an email signup confirmation", - "code": "const { error } = await supabase.auth.resend({\n type: 'signup',\n email: 'email@example.com',\n options: {\n emailRedirectTo: 'https://example.com/welcome'\n }\n})", - "notes": "Resends the email signup confirmation to the user" - }, - { - "title": "Resend a phone signup confirmation", - "code": "const { error } = await supabase.auth.resend({\n type: 'sms',\n phone: '1234567890'\n})", - "notes": "Resends the phone signup confirmation email to the user" - }, - { - "title": "Resend email change email", - "code": "const { error } = await supabase.auth.resend({\n type: 'email_change',\n email: 'email@example.com'\n})", - "notes": "Resends the email change email to the user" - }, - { - "title": "Resend phone change OTP", - "code": "const { error } = await supabase.auth.resend({\n type: 'phone_change',\n phone: '1234567890'\n})", - "notes": "Resends the phone change OTP to the user" - } - ] - }, - { - "name": "resetPasswordForEmail", - "description": "Sends a password reset request to an email address. This method supports the PKCE flow.", - "remarks": [ - "- The password reset flow consist of 2 broad steps: (i) Allow the user to login via the password reset link; (ii) Update the user's password. - The `resetPasswordForEmail()` only sends a password reset link to the user's email. To update the user's password, see [`updateUser()`](/docs/reference/javascript/auth-updateuser). - A `PASSWORD_RECOVERY` event will be emitted when the password recovery link is clicked. You can use [`onAuthStateChange()`](/docs/reference/javascript/auth-onauthstatechange) to listen and invoke a callback function on these events. - When the user clicks the reset link in the email they are redirected back to your application. You can configure the URL that the user is redirected to with the `redirectTo` parameter. See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project. - After the user has been redirected successfully, prompt them for a new password and call `updateUser()`: ```js const { data, error } = await supabase.auth.updateUser({ password: new_password }) ```" - ], - "parameters": [ - { - "name": "email", - "description": "The email address of the user.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "redirectTo", - "optional": true, - "description": "The URL to send the user to after they click the password reset link.", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Reset password", - "code": "const { data, error } = await supabase.auth.resetPasswordForEmail(email, {\n redirectTo: 'https://example.com/update-password',\n})", - "response": "{\n data: {}\n error: null\n}" - }, - { - "title": "Reset password (React)", - "code": "/**\n * Step 1: Send the user an email to get a password reset token.\n * This email contains a link which sends the user back to your application.\n */\nconst { data, error } = await supabase.auth\n .resetPasswordForEmail('user@email.com')\n\n/**\n * Step 2: Once the user is redirected back to your application,\n * ask the user to reset their password.\n */\n useEffect(() => {\n supabase.auth.onAuthStateChange(async (event, session) => {\n if (event == \"PASSWORD_RECOVERY\") {\n const newPassword = prompt(\"What would you like your new password to be?\");\n const { data, error } = await supabase.auth\n .updateUser({ password: newPassword })\n\n if (data) alert(\"Password updated successfully!\")\n if (error) alert(\"There was an error updating your password.\")\n }\n })\n }, [])" - } - ] - }, - { - "name": "setSession", - "description": "Sets the session data from the current session. If the current session is expired, setSession will take care of refreshing it to obtain a new session. If the refresh token or access token in the current session is invalid, an error will be thrown.", - "remarks": [ - "- This method sets the session using an `access_token` and `refresh_token`. - If successful, a `SIGNED_IN` event is emitted." - ], - "parameters": [ - { - "name": "currentSession", - "description": "The current session that minimally contains an access token and refresh token.", - "type": { - "kind": "object", - "properties": [ - { - "name": "access_token", - "optional": false, - "type": "string" - }, - { - "name": "refresh_token", - "optional": false, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Set the session", - "code": "const { data, error } = await supabase.auth.setSession({\n access_token,\n refresh_token\n })", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n },\n \"session\": {\n \"access_token\": \"\",\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"11111111-1111-1111-1111-111111111111\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"2024-01-01T00:00:00Z\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n },\n \"token_type\": \"bearer\",\n \"expires_in\": 3500,\n \"expires_at\": 1700000000\n }\n },\n \"error\": null\n}", - "notes": "Sets the session data from an access_token and refresh_token, then returns an auth response or error." - } - ] - }, - { - "name": "signInAnonymously", - "description": "Creates a new anonymous user.", - "remarks": [ - "- Returns an anonymous user - It is recommended to set up captcha for anonymous sign-ins to prevent abuse. You can pass in the captcha token in the `options` param." - ], - "parameters": [ - { - "name": "credentials", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - } - ] - } - } - ], - "name": "SignInAnonymouslyCredentials" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create an anonymous user", - "code": "const { data, error } = await supabase.auth.signInAnonymously({\n options: {\n captchaToken\n }\n});", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {},\n \"user_metadata\": {},\n \"identities\": [],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": true\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {},\n \"user_metadata\": {},\n \"identities\": [],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": true\n }\n }\n },\n \"error\": null\n}" - }, - { - "title": "Create an anonymous user with custom user metadata", - "code": "const { data, error } = await supabase.auth.signInAnonymously({\n options: {\n data\n }\n})" - } - ] - }, - { - "name": "signInWithIdToken", - "description": "Allows signing in with an OIDC ID token. The authentication provider used should be enabled and configured.", - "remarks": [ - "- Use an ID token to sign in. - Especially useful when implementing sign in using native platform dialogs in mobile or desktop apps using Sign in with Apple or Sign in with Google on iOS and Android. - You can also use Google's [One Tap](https://developers.google.com/identity/gsi/web/guides/display-google-one-tap) and [Automatic sign-in](https://developers.google.com/identity/gsi/web/guides/automatic-sign-in-sign-out) via this API." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "object", - "properties": [ - { - "name": "access_token", - "optional": true, - "description": "If the ID token contains an `at_hash` claim, then the hash of this value is compared to the value in the ID token.", - "type": "string" - }, - { - "name": "nonce", - "optional": true, - "description": "If the ID token contains a `nonce` claim, then the hash of this value is compared to the value in the ID token.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - } - ] - } - }, - { - "name": "provider", - "optional": false, - "description": "Provider name or OIDC `iss` value identifying which provider should be used to verify the provided token. Supported names: `google`, `apple`, `azure`, `facebook`, `kakao`. Use the `custom:` prefix for custom OIDC providers (e.g. `custom:my-oidc-provider`).", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "templateLiteral" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "token", - "optional": false, - "description": "OIDC ID token issued by the specified provider. The `iss` claim in the ID token must match the supplied provider. Some ID tokens contain an `at_hash` which require that you provide an `access_token` value to be accepted properly. If the token contains a `nonce` claim you must supply the nonce used to obtain the ID token.", - "type": "string" - } - ], - "name": "SignInWithIdTokenCredentials" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign In using ID Token", - "code": "const { data, error } = await supabase.auth.signInWithIdToken({\n provider: 'google',\n token: 'your-id-token'\n})", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n ...\n },\n \"user_metadata\": {\n ...\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"provider\": \"google\",\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n ...\n },\n \"user_metadata\": {\n ...\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"provider\": \"google\",\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n }\n }\n },\n \"error\": null\n}" - } - ] - }, - { - "name": "signInWithOAuth", - "description": "Log in an existing user via a third-party provider. This method supports the PKCE flow.", - "remarks": [ - "- This method is used for signing in using [Social Login (OAuth) providers](/docs/guides/auth#configure-third-party-providers). - It works by redirecting your application to the provider's authorization screen, before bringing back the user to your app." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "queryParams", - "optional": true, - "description": "An object of query params", - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they are confirmed.", - "type": "string" - }, - { - "name": "scopes", - "optional": true, - "description": "A space-separated list of scopes granted to the OAuth application.", - "type": "string" - }, - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If set to true does not immediately redirect the current browser context to visit the OAuth authorization page for the provider.", - "type": "boolean" - } - ] - } - }, - { - "name": "provider", - "optional": false, - "description": "One of the providers supported by GoTrue.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "bitbucket" - }, - { - "kind": "literal", - "value": "discord" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "figma" - }, - { - "kind": "literal", - "value": "github" - }, - { - "kind": "literal", - "value": "gitlab" - }, - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "literal", - "value": "keycloak" - }, - { - "kind": "literal", - "value": "linkedin" - }, - { - "kind": "literal", - "value": "linkedin_oidc" - }, - { - "kind": "literal", - "value": "notion" - }, - { - "kind": "literal", - "value": "slack" - }, - { - "kind": "literal", - "value": "slack_oidc" - }, - { - "kind": "literal", - "value": "spotify" - }, - { - "kind": "literal", - "value": "twitch" - }, - { - "kind": "literal", - "value": "twitter" - }, - { - "kind": "literal", - "value": "x" - }, - { - "kind": "literal", - "value": "workos" - }, - { - "kind": "literal", - "value": "zoom" - }, - { - "kind": "literal", - "value": "fly" - }, - { - "kind": "templateLiteral" - } - ] - } - } - ], - "name": "SignInWithOAuthCredentials" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "provider", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "bitbucket" - }, - { - "kind": "literal", - "value": "discord" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "figma" - }, - { - "kind": "literal", - "value": "github" - }, - { - "kind": "literal", - "value": "gitlab" - }, - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "literal", - "value": "keycloak" - }, - { - "kind": "literal", - "value": "linkedin" - }, - { - "kind": "literal", - "value": "linkedin_oidc" - }, - { - "kind": "literal", - "value": "notion" - }, - { - "kind": "literal", - "value": "slack" - }, - { - "kind": "literal", - "value": "slack_oidc" - }, - { - "kind": "literal", - "value": "spotify" - }, - { - "kind": "literal", - "value": "twitch" - }, - { - "kind": "literal", - "value": "twitter" - }, - { - "kind": "literal", - "value": "x" - }, - { - "kind": "literal", - "value": "workos" - }, - { - "kind": "literal", - "value": "zoom" - }, - { - "kind": "literal", - "value": "fly" - }, - { - "kind": "templateLiteral" - } - ] - } - }, - { - "name": "url", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "provider", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "apple" - }, - { - "kind": "literal", - "value": "azure" - }, - { - "kind": "literal", - "value": "bitbucket" - }, - { - "kind": "literal", - "value": "discord" - }, - { - "kind": "literal", - "value": "facebook" - }, - { - "kind": "literal", - "value": "figma" - }, - { - "kind": "literal", - "value": "github" - }, - { - "kind": "literal", - "value": "gitlab" - }, - { - "kind": "literal", - "value": "google" - }, - { - "kind": "literal", - "value": "kakao" - }, - { - "kind": "literal", - "value": "keycloak" - }, - { - "kind": "literal", - "value": "linkedin" - }, - { - "kind": "literal", - "value": "linkedin_oidc" - }, - { - "kind": "literal", - "value": "notion" - }, - { - "kind": "literal", - "value": "slack" - }, - { - "kind": "literal", - "value": "slack_oidc" - }, - { - "kind": "literal", - "value": "spotify" - }, - { - "kind": "literal", - "value": "twitch" - }, - { - "kind": "literal", - "value": "twitter" - }, - { - "kind": "literal", - "value": "x" - }, - { - "kind": "literal", - "value": "workos" - }, - { - "kind": "literal", - "value": "zoom" - }, - { - "kind": "literal", - "value": "fly" - }, - { - "kind": "templateLiteral" - } - ] - } - }, - { - "name": "url", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign in using a third-party provider", - "code": "const { data, error } = await supabase.auth.signInWithOAuth({\n provider: 'github'\n})", - "response": "{\n data: {\n provider: 'github',\n url: \n },\n error: null\n}", - "notes": "with redirect\n- When the OAuth provider successfully authenticates the user, they are redirected to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls). It does not redirect the user immediately after invoking this method.\n- See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project." - }, - { - "title": "Sign in using a third-party provider with redirect", - "code": "const { data, error } = await supabase.auth.signInWithOAuth({\n provider: 'github',\n options: {\n redirectTo: 'https://example.com/welcome'\n }\n})", - "notes": "- When the OAuth provider successfully authenticates the user, they are redirected to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls). It does not redirect the user immediately after invoking this method.\n- See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project." - }, - { - "title": "Sign in with scopes and access provider tokens", - "code": "// Register this immediately after calling createClient!\n// Because signInWithOAuth causes a redirect, you need to fetch the\n// provider tokens from the callback.\nsupabase.auth.onAuthStateChange((event, session) => {\n if (session && session.provider_token) {\n window.localStorage.setItem('oauth_provider_token', session.provider_token)\n }\n\n if (session && session.provider_refresh_token) {\n window.localStorage.setItem('oauth_provider_refresh_token', session.provider_refresh_token)\n }\n\n if (event === 'SIGNED_OUT') {\n window.localStorage.removeItem('oauth_provider_token')\n window.localStorage.removeItem('oauth_provider_refresh_token')\n }\n})\n\n// Call this on your Sign in with GitHub button to initiate OAuth\n// with GitHub with the requested elevated scopes.\nawait supabase.auth.signInWithOAuth({\n provider: 'github',\n options: {\n scopes: 'repo gist notifications'\n }\n})", - "notes": "If you need additional access from an OAuth provider, in order to access provider specific APIs in the name of the user, you can do this by passing in the scopes the user should authorize for your application. Note that the `scopes` option takes in **a space-separated list** of scopes.\n\nBecause OAuth sign-in often includes redirects, you should register an `onAuthStateChange` callback immediately after you create the Supabase client. This callback will listen for the presence of `provider_token` and `provider_refresh_token` properties on the `session` object and store them in local storage. The client library will emit these values **only once** immediately after the user signs in. You can then access them by looking them up in local storage, or send them to your backend servers for further processing.\n\nFinally, make sure you remove them from local storage on the `SIGNED_OUT` event. If the OAuth provider supports token revocation, make sure you call those APIs either from the frontend or schedule them to be called on the backend." - } - ] - }, - { - "name": "signInWithOtp", - "description": "Log in a user using magiclink or a one-time password (OTP).\nIf the `{{ .ConfirmationURL }}` variable is specified in the email template, a magiclink will be sent. If the `{{ .Token }}` variable is specified in the email template, an OTP will be sent. If you're using phone sign-ins, only an OTP will be sent. You won't be able to send a magiclink for phone sign-ins.\nBe aware that you may get back an error message that will not distinguish between the cases where the account does not exist or, that the account can only be accessed via social login.\nDo note that you will need to configure a Whatsapp sender on Twilio if you are using phone sign in with the 'whatsapp' channel. The whatsapp channel is not supported on other providers at this time. This method supports PKCE when an email is passed.", - "remarks": [ - "- 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. - If the user doesn't exist, `signInWithOtp()` will signup the user instead. To restrict this behavior, you can set `shouldCreateUser` in `SignInWithPasswordlessCredentials.options` to `false`. - If you're using an email, you can configure whether you want the user to receive a magiclink or a OTP. - If you're using phone, you can configure whether you want the user to receive a OTP. - The magic link's destination URL is determined by the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls). - See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project. - Magic links and OTPs share the same implementation. To send users a one-time code instead of a magic link, [modify the magic link email template](/dashboard/project/_/auth/templates) to include `{{ .Token }}` instead of `{{ .ConfirmationURL }}`. - See our [Twilio Phone Auth Guide](/docs/guides/auth/phone-login?showSMSProvider=Twilio) for details about configuring WhatsApp sign in." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "description": "The user's email address.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "emailRedirectTo", - "optional": true, - "description": "The redirect url embedded in the email link", - "type": "string" - }, - { - "name": "shouldCreateUser", - "optional": true, - "description": "If set to false, this method will not create a new user. Defaults to true.", - "type": "boolean" - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "channel", - "optional": true, - "description": "Messaging channel to use (e.g. whatsapp or sms)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "sms" - }, - { - "kind": "literal", - "value": "whatsapp" - } - ] - } - }, - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "shouldCreateUser", - "optional": true, - "description": "If set to false, this method will not create a new user. Defaults to true.", - "type": "boolean" - } - ] - } - }, - { - "name": "phone", - "optional": false, - "description": "The user's phone number.", - "type": "string" - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "messageId", - "optional": true, - "type": { - "kind": "union", - "types": [ - "string", - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "session", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign in with email", - "code": "const { data, error } = await supabase.auth.signInWithOtp({\n email: 'example@email.com',\n options: {\n emailRedirectTo: 'https://example.com/welcome'\n }\n})", - "response": "{\n \"data\": {\n \"user\": null,\n \"session\": null\n },\n \"error\": null\n}", - "notes": "The user will be sent an email which contains either a magiclink or a OTP or both. By default, a given user can only request a OTP once every 60 seconds." - }, - { - "title": "Sign in with SMS OTP", - "code": "const { data, error } = await supabase.auth.signInWithOtp({\n phone: '+13334445555',\n})", - "notes": "The user will be sent a SMS which contains a OTP. By default, a given user can only request a OTP once every 60 seconds." - }, - { - "title": "Sign in with WhatsApp OTP", - "code": "const { data, error } = await supabase.auth.signInWithOtp({\n phone: '+13334445555',\n options: {\n channel:'whatsapp',\n }\n})", - "notes": "The user will be sent a WhatsApp message which contains a OTP. By default, a given user can only request a OTP once every 60 seconds. Note that a user will need to have a valid WhatsApp account that is linked to Twilio in order to use this feature." - } - ] - }, - { - "name": "signInWithPassword", - "description": "Log in an existing user with an email and password or phone and password.\nBe aware that you may get back an error message that will not distinguish between the cases where the account does not exist or that the email/phone and password combination is wrong or that the account can only be accessed via social login.", - "remarks": [ - "- Requires either an email and password or a phone number and password." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "intersection", - "types": [ - { - "kind": "reference", - "name": "PasswordCredentialsBase" - }, - { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "type": "string" - } - ] - } - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - }, - { - "name": "weakPassword", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "message", - "optional": false, - "type": "string" - }, - { - "name": "reasons", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "indexedAccess", - "objectType": { - "kind": "query" - }, - "indexType": null - } - } - } - ], - "name": "WeakPassword" - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign in with email and password", - "code": "const { data, error } = await supabase.auth.signInWithPassword({\n email: 'example@email.com',\n password: 'example-password',\n})", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n }\n }\n },\n \"error\": null\n}" - }, - { - "title": "Sign in with phone and password", - "code": "const { data, error } = await supabase.auth.signInWithPassword({\n phone: '+13334445555',\n password: 'some-password',\n})" - } - ] - }, - { - "name": "signInWithSSO", - "description": "Attempts a single-sign on using an enterprise Identity Provider. A successful SSO attempt will redirect the current page to the identity provider authorization page. The redirect URL is implementation and SSO protocol specific.\nYou can use it by providing a SSO domain. Typically you can extract this domain by asking users for their email address. If this domain is registered on the Auth instance the redirect will use that organization's currently active SSO Identity Provider for the login.\nIf you have built an organization-specific login page, you can use the organization's SSO Identity Provider UUID directly instead.", - "remarks": [ - "- 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. - In case you need to use a different way to start the authentication flow with an identity provider, you can use the `providerId` property. For example: - Mapping specific user email addresses with an identity provider. - Using different hints to identity the identity provider to be used by the user, like a company-specific page, IP address or other tracking information." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they have signed-in.", - "type": "string" - }, - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If set to true, the redirect will not happen on the client side. This parameter is used when you wish to handle the redirect yourself. Defaults to false.", - "type": "boolean" - } - ] - } - }, - { - "name": "providerId", - "optional": false, - "description": "UUID of the SSO provider to invoke single-sign on to.", - "type": "string" - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "domain", - "optional": false, - "description": "Domain name of the organization for which to invoke single-sign on.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they have signed-in.", - "type": "string" - }, - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If set to true, the redirect will not happen on the client side. This parameter is used when you wish to handle the redirect yourself. Defaults to false.", - "type": "boolean" - } - ] - } - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "url", - "optional": false, - "description": "URL to open in a browser which will complete the sign-in flow by taking the user to the identity provider's authentication flow.\nOn browsers you can set the URL to `window.location.href` to take the user to the authentication flow.", - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign in with email domain", - "code": "// You can extract the user's email domain and use it to trigger the\n // authentication flow with the correct identity provider.\n\n const { data, error } = await supabase.auth.signInWithSSO({\n domain: 'company.com'\n })\n\n if (data?.url) {\n // redirect the user to the identity provider's authentication flow\n window.location.href = data.url\n }" - }, - { - "title": "Sign in with provider UUID", - "code": "// Useful when you need to map a user's sign in request according\n // to different rules that can't use email domains.\n\n const { data, error } = await supabase.auth.signInWithSSO({\n providerId: '21648a9d-8d5a-4555-a9d1-d6375dc14e92'\n })\n\n if (data?.url) {\n // redirect the user to the identity provider's authentication flow\n window.location.href = data.url\n }" - } - ] - }, - { - "name": "signInWithWeb3", - "description": "Signs in a user by verifying a message signed by the user's private key. Supports Ethereum (via Sign-In-With-Ethereum) & Solana (Sign-In-With-Solana) standards, both of which derive from the EIP-4361 standard With slight variation on Solana's side.", - "remarks": [ - "- Uses a Web3 (Ethereum, Solana) wallet to sign a user in. - Read up on the [potential for abuse](/docs/guides/auth/auth-web3#potential-for-abuse) before using it." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "union", - "types": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "chain", - "optional": false, - "type": { - "kind": "literal", - "value": "solana" - } - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "signInWithSolana", - "optional": true, - "type": { - "kind": "reference", - "name": "Partial", - "typeArguments": [ - { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "reference", - "name": "SolanaSignInInput" - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "version" - }, - { - "kind": "literal", - "value": "chain" - }, - { - "kind": "literal", - "value": "domain" - }, - { - "kind": "literal", - "value": "uri" - }, - { - "kind": "literal", - "value": "statement" - } - ] - } - ] - } - ] - } - }, - { - "name": "url", - "optional": true, - "description": "URL to use with the wallet interface. Some wallets do not allow signing a message for URLs different from the current page.", - "type": "string" - } - ] - } - }, - { - "name": "statement", - "optional": true, - "description": "Optional statement to include in the Sign in with Solana message. Must not include new line characters. Most wallets like Phantom **require specifying a statement!**", - "type": "string" - }, - { - "name": "wallet", - "optional": true, - "description": "Wallet interface to use. If not specified will default to `window.solana`.", - "type": { - "kind": "object", - "properties": [ - { - "name": "publicKey", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "toBase58", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "signIn", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "signMessage", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - } - ], - "name": "SolanaWallet" - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "chain", - "optional": false, - "type": { - "kind": "literal", - "value": "solana" - } - }, - { - "name": "message", - "optional": false, - "description": "Sign in with Solana compatible message. Must include `Issued At`, `URI` and `Version`.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - } - ] - } - }, - { - "name": "signature", - "optional": false, - "description": "Ed25519 signature of the message.", - "type": { - "kind": "reference", - "name": "Uint8Array" - } - } - ] - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "chain", - "optional": false, - "type": { - "kind": "literal", - "value": "ethereum" - } - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "signInWithEthereum", - "optional": true, - "type": { - "kind": "reference", - "name": "Partial", - "typeArguments": [ - { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "reference", - "name": "EthereumSignInInput" - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "version" - }, - { - "kind": "literal", - "value": "domain" - }, - { - "kind": "literal", - "value": "uri" - }, - { - "kind": "literal", - "value": "statement" - } - ] - } - ] - } - ] - } - }, - { - "name": "url", - "optional": true, - "description": "URL to use with the wallet interface. Some wallets do not allow signing a message for URLs different from the current page.", - "type": "string" - } - ] - } - }, - { - "name": "statement", - "optional": true, - "description": "Optional statement to include in the Sign in with Ethereum message. Must not include new line characters. Most wallets like Phantom **require specifying a statement!**", - "type": "string" - }, - { - "name": "wallet", - "optional": true, - "description": "Wallet interface to use. If not specified will default to `window.ethereum`.", - "type": { - "kind": "reference", - "name": "EIP1193Provider" - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "chain", - "optional": false, - "type": { - "kind": "literal", - "value": "ethereum" - } - }, - { - "name": "message", - "optional": false, - "description": "Sign in with Ethereum compatible message. Must include `Issued At`, `URI` and `Version`.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - } - ] - } - }, - { - "name": "signature", - "optional": false, - "description": "Ethereum curve (secp256k1) signature of the message.", - "type": { - "kind": "reference", - "name": "Hex" - } - } - ] - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign in with Solana or Ethereum (Window API)", - "code": "// uses window.ethereum for the wallet\n const { data, error } = await supabase.auth.signInWithWeb3({\n chain: 'ethereum',\n statement: 'I accept the Terms of Service at https://example.com/tos'\n })\n\n // uses window.solana for the wallet\n const { data, error } = await supabase.auth.signInWithWeb3({\n chain: 'solana',\n statement: 'I accept the Terms of Service at https://example.com/tos'\n })" - }, - { - "title": "Sign in with Ethereum (Message and Signature)", - "code": "const { data, error } = await supabase.auth.signInWithWeb3({\n chain: 'ethereum',\n message: '',\n signature: '',\n })" - }, - { - "title": "Sign in with Solana (Brave)", - "code": "const { data, error } = await supabase.auth.signInWithWeb3({\n chain: 'solana',\n statement: 'I accept the Terms of Service at https://example.com/tos',\n wallet: window.braveSolana\n })" - }, - { - "title": "Sign in with Solana (Wallet Adapter)", - "code": "function SignInButton() {\n const wallet = useWallet()\n\n return (\n <>\n {wallet.connected ? (\n {\n supabase.auth.signInWithWeb3({\n chain: 'solana',\n statement: 'I accept the Terms of Service at https://example.com/tos',\n wallet,\n })\n }}\n >\n Sign in with Solana\n \n ) : (\n \n )}\n \n )\n}\n\nfunction App() {\n const endpoint = clusterApiUrl('devnet')\n const wallets = useMemo(() => [], [])\n\n return (\n \n \n \n \n \n \n \n )\n}" - } - ] - }, - { - "name": "signOut", - "description": "Inside a browser context, `signOut()` will remove the logged in user from the browser session and log them out - removing all items from localstorage and then trigger a `\"SIGNED_OUT\"` event.\nFor server-side management, you can revoke all refresh tokens for a user by passing a user's JWT through to `auth.api.signOut(JWT: string)`. There is no way to revoke a user's access token jwt until it expires. It is recommended to set a shorter expiry on the jwt for this reason.\nIf using `others` scope, no `SIGNED_OUT` event is fired!", - "remarks": [ - "- In order to use the `signOut()` method, the user needs to be signed in first. - By default, `signOut()` uses the global scope, which signs out all other sessions that the user is logged into as well. Customize this behavior by passing a scope parameter. - Since Supabase Auth uses JWTs for authentication, the access token JWT will be valid until it's expired. When the user signs out, Supabase revokes the refresh token and deletes the JWT from the client-side. This does not revoke the JWT and it will still be valid until it expires." - ], - "parameters": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "scope", - "optional": true, - "description": "Determines which sessions should be logged out. Global means all sessions by this account. Local means only this session. Others means all other sessions except the current one. When using others, there is no sign-out event fired on the current session!", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "global" - }, - { - "kind": "literal", - "value": "local" - }, - { - "kind": "literal", - "value": "others" - } - ] - } - } - ], - "name": "SignOut" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "object", - "properties": [ - { - "name": "error", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - ] - } - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign out (all sessions)", - "code": "const { error } = await supabase.auth.signOut()" - }, - { - "title": "Sign out (current session)", - "code": "const { error } = await supabase.auth.signOut({ scope: 'local' })" - }, - { - "title": "Sign out (other sessions)", - "code": "const { error } = await supabase.auth.signOut({ scope: 'others' })" - } - ] - }, - { - "name": "signUp", - "description": "Creates a new user.\nBe aware that if a user account exists in the system you may get back an error message that attempts to hide this information from the user. This method has support for PKCE via email signups. The PKCE flow cannot be used when autoconfirm is enabled.", - "remarks": [ - "- By default, the user needs to verify their email address before logging in. To turn this off, disable **Confirm email** in [your project](/dashboard/project/_/auth/providers). - **Confirm email** determines if users need to confirm their email address after signing up. - If **Confirm email** is enabled, a `user` is returned but `session` is null. - If **Confirm email** is disabled, both a `user` and a `session` are returned. - When the user confirms their email address, they are redirected to the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) by default. You can modify your `SITE_URL` or add additional redirect URLs in [your project](/dashboard/project/_/auth/url-configuration). - If signUp() is called for an existing confirmed user: - 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)." - ], - "parameters": [ - { - "name": "credentials", - "type": { - "kind": "conditional" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Sign up with an email and password", - "code": "const { data, error } = await supabase.auth.signUp({\n email: 'example@email.com',\n password: 'example-password',\n})", - "response": "// Some fields may be null if \"confirm email\" is enabled.\n{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {},\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n }\n }\n },\n \"error\": null\n}", - "notes": "Sign up with a phone number and password (whatsapp)\nThe user will be sent a WhatsApp message which contains a OTP. By default, a given user can only request a OTP once every 60 seconds. Note that a user will need to have a valid WhatsApp account that is linked to Twilio in order to use this feature." - }, - { - "title": "Sign up with a phone number and password (SMS)", - "code": "const { data, error } = await supabase.auth.signUp({\n phone: '123456789',\n password: 'example-password',\n options: {\n channel: 'sms'\n }\n})", - "notes": "Sign up with a redirect URL\n- See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project." - }, - { - "title": "Sign up with a phone number and password (whatsapp)", - "code": "const { data, error } = await supabase.auth.signUp({\n phone: '123456789',\n password: 'example-password',\n options: {\n channel: 'whatsapp'\n }\n})", - "notes": "The user will be sent a WhatsApp message which contains a OTP. By default, a given user can only request a OTP once every 60 seconds. Note that a user will need to have a valid WhatsApp account that is linked to Twilio in order to use this feature." - }, - { - "title": "Sign up with additional user metadata", - "code": "const { data, error } = await supabase.auth.signUp(\n {\n email: 'example@email.com',\n password: 'example-password',\n options: {\n data: {\n first_name: 'John',\n age: 27,\n }\n }\n }\n)" - }, - { - "title": "Sign up with a redirect URL", - "code": "const { data, error } = await supabase.auth.signUp(\n {\n email: 'example@email.com',\n password: 'example-password',\n options: {\n emailRedirectTo: 'https://example.com/welcome'\n }\n }\n)", - "notes": "- See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project." - } - ] - }, - { - "name": "startAutoRefresh", - "description": "Starts an auto-refresh process in the background. The session is checked every few seconds. Close to the time of expiration a process is started to refresh the session. If refreshing fails it will be retried for as long as necessary.\nIf you set the GoTrueClientOptions#autoRefreshToken you don't need to call this function, it will be called for you.\nOn browsers the refresh process works only when the tab/window is in the foreground to conserve resources as well as prevent race conditions and flooding auth with requests. If you call this method any managed visibility change callback will be removed and you must manage visibility changes on your own.\nOn non-browser platforms the refresh process works *continuously* in the background, which may not be desirable. You should hook into your platform's foreground indication mechanism and call these methods appropriately to conserve resources.\n#stopAutoRefresh", - "remarks": [ - "- Only useful in non-browser environments such as React Native or Electron. - The Supabase Auth library automatically starts and stops proactively refreshing the session when a tab is focused or not. - On non-browser platforms, such as mobile or desktop apps built with web technologies, the library is not able to effectively determine whether the application is _focused_ or not. - To give this hint to the application, you should be calling this method when the app is in focus and calling `supabase.auth.stopAutoRefresh()` when it's out of focus." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - "void" - ] - }, - "examples": [ - { - "title": "Start and stop auto refresh in React Native", - "code": "import { AppState } from 'react-native'\n\n// make sure you register this only once!\nAppState.addEventListener('change', (state) => {\n if (state === 'active') {\n supabase.auth.startAutoRefresh()\n } else {\n supabase.auth.stopAutoRefresh()\n }\n})" - } - ] - }, - { - "name": "stopAutoRefresh", - "description": "Stops an active auto refresh process running in the background (if any).\nIf you call this method any managed visibility change callback will be removed and you must manage visibility changes on your own.\nSee #startAutoRefresh for more details.", - "remarks": [ - "- Only useful in non-browser environments such as React Native or Electron. - The Supabase Auth library automatically starts and stops proactively refreshing the session when a tab is focused or not. - On non-browser platforms, such as mobile or desktop apps built with web technologies, the library is not able to effectively determine whether the application is _focused_ or not. - When your application goes in the background or out of focus, call this method to stop the proactive refreshing of the session." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - "void" - ] - }, - "examples": [ - { - "title": "Start and stop auto refresh in React Native", - "code": "import { AppState } from 'react-native'\n\n// make sure you register this only once!\nAppState.addEventListener('change', (state) => {\n if (state === 'active') {\n supabase.auth.startAutoRefresh()\n } else {\n supabase.auth.stopAutoRefresh()\n }\n})" - } - ] - }, - { - "name": "unlinkIdentity", - "description": "Unlinks an identity from a user by deleting it. The user will no longer be able to sign in with that identity once it's unlinked.", - "remarks": [ - "- The **Enable Manual Linking** option must be enabled from your [project's authentication settings](/dashboard/project/_/auth/providers). - The user needs to be signed in to call `unlinkIdentity()`. - The user must have at least 2 identities in order to unlink an identity. - The identity to be unlinked must belong to the user." - ], - "parameters": [ - { - "name": "identity", - "type": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Unlink an identity", - "code": "// retrieve all identities linked to a user\nconst identities = await supabase.auth.getUserIdentities()\n\n// find the google identity\nconst googleIdentity = identities.find(\n identity => identity.provider === 'google'\n)\n\n// unlink the google identity\nconst { error } = await supabase.auth.unlinkIdentity(googleIdentity)" - } - ] - }, - { - "name": "updateUser", - "description": "Updates user data for a logged in user.", - "remarks": [ - "- In order to use the `updateUser()` method, the user needs to be signed in first. - By default, email updates sends a confirmation link to both the user's current and new email. To only send a confirmation link to the user's new email, disable **Secure email change** in your project's [email auth provider settings](/dashboard/project/_/auth/providers)." - ], - "parameters": [ - { - "name": "attributes", - "type": { - "kind": "object", - "name": "UserAttributes", - "properties": [ - { - "name": "current_password", - "optional": true, - "description": "The user's current password\nThis is only ever present when the user is resetting their password and GOTRUE_SECURITY_UPDATE_PASSWORD_REQUIRE_CURRENT_PASSWORD is true.", - "type": "string" - }, - { - "name": "data", - "optional": true, - "description": "A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.\nThe `data` should be a JSON object that includes user-specific info, such as their first and last name.", - "type": "object" - }, - { - "name": "email", - "optional": true, - "description": "The user's email.", - "type": "string" - }, - { - "name": "nonce", - "optional": true, - "description": "The nonce sent for reauthentication if the user's password is to be updated.\nCall reauthenticate() to obtain the nonce first.", - "type": "string" - }, - { - "name": "password", - "optional": true, - "description": "The user's password.", - "type": "string" - }, - { - "name": "phone", - "optional": true, - "description": "The user's phone.", - "type": "string" - } - ] - } - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "emailRedirectTo", - "optional": true, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "user", - "optional": false, - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Update the email for an authenticated user", - "code": "const { data, error } = await supabase.auth.updateUser({\n email: 'new@email.com'\n})", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"new_email\": \"new@email.com\",\n \"email_change_sent_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n },\n \"error\": null\n}", - "notes": "Sends a \"Confirm Email Change\" email to the new address. If **Secure Email Change** is enabled (default), confirmation is also required from the **old email** before the change is applied. To skip dual confirmation and apply the change after only the new email is verified, disable **Secure Email Change** in the [Email Auth Provider settings](/dashboard/project/_/auth/providers?provider=Email)." - }, - { - "title": "Update the phone number for an authenticated user", - "code": "const { data, error } = await supabase.auth.updateUser({\n phone: '123456789'\n})", - "notes": "Sends a one-time password (OTP) to the new phone number." - }, - { - "title": "Update the password for an authenticated user", - "code": "const { data, error } = await supabase.auth.updateUser({\n password: 'new password'\n})", - "notes": "Update the user's metadata\nUpdates the user's custom metadata.\n\n**Note**: The `data` field maps to the `auth.users.raw_user_meta_data` column in your Supabase database. When calling `getUser()`, the data will be available as `user.user_metadata`." - }, - { - "title": "Update the user's metadata", - "code": "const { data, error } = await supabase.auth.updateUser({\n data: { hello: 'world' }\n})", - "notes": "Updates the user's custom metadata.\n\n**Note**: The `data` field maps to the `auth.users.raw_user_meta_data` column in your Supabase database. When calling `getUser()`, the data will be available as `user.user_metadata`." - }, - { - "title": "Update the user's password with a nonce", - "code": "const { data, error } = await supabase.auth.updateUser({\n password: 'new password',\n nonce: '123456'\n})", - "notes": "If **Secure password change** is enabled in your [project's email provider settings](/dashboard/project/_/auth/providers), updating the user's password would require a nonce if the user **hasn't recently signed in**. The nonce is sent to the user's email or phone number. A user is deemed recently signed in if the session was created in the last 24 hours." - } - ] - }, - { - "name": "verifyOtp", - "description": "Log in a user given a User supplied OTP or TokenHash received through mobile or email.", - "remarks": [ - "- The `verifyOtp` method takes in different verification types. - If a phone number is used, the type can either be: 1. `sms` – Used when verifying a one-time password (OTP) sent via SMS during sign-up or sign-in. 2. `phone_change` – Used when verifying an OTP sent to a new phone number during a phone number update process. - If an email address is used, the type can be one of the following (note: `signup` and `magiclink` types are deprecated): 1. `email` – Used when verifying an OTP sent to the user's email during sign-up or sign-in. 2. `recovery` – Used when verifying an OTP sent for account recovery, typically after a password reset request. 3. `invite` – Used when verifying an OTP sent as part of an invitation to join a project or organization. 4. `email_change` – Used when verifying an OTP sent to a new email address during an email update process. - 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 for the PKCE flow for Server Side Auth. Read [the Password-based Auth guide](/docs/guides/auth/passwords) for more details." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "VerifyMobileOtpParams", - "properties": [ - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they are confirmed.", - "type": "string" - } - ] - } - }, - { - "name": "phone", - "optional": false, - "description": "The user's phone number.", - "type": "string" - }, - { - "name": "token", - "optional": false, - "description": "The otp sent to the user's phone number.", - "type": "string" - }, - { - "name": "type", - "optional": false, - "description": "The user's verification type.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "sms" - }, - { - "kind": "literal", - "value": "phone_change" - } - ] - } - } - ] - }, - { - "kind": "object", - "name": "VerifyEmailOtpParams", - "properties": [ - { - "name": "email", - "optional": false, - "description": "The user's email address.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "captchaToken", - "optional": true, - "description": "Verification token received when the user completes the captcha on the site.", - "type": "string" - }, - { - "name": "redirectTo", - "optional": true, - "description": "A URL to send the user to after they are confirmed.", - "type": "string" - } - ] - } - }, - { - "name": "token", - "optional": false, - "description": "The otp sent to the user's email address.", - "type": "string" - }, - { - "name": "type", - "optional": false, - "description": "The user's verification type.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "signup" - }, - { - "kind": "literal", - "value": "invite" - }, - { - "kind": "literal", - "value": "magiclink" - }, - { - "kind": "literal", - "value": "recovery" - }, - { - "kind": "literal", - "value": "email_change" - }, - { - "kind": "literal", - "value": "email" - } - ] - } - } - ] - }, - { - "kind": "object", - "name": "VerifyTokenHashParams", - "properties": [ - { - "name": "token_hash", - "optional": false, - "description": "The token hash used in an email link", - "type": "string" - }, - { - "name": "type", - "optional": false, - "description": "The user's verification type.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "signup" - }, - { - "kind": "literal", - "value": "invite" - }, - { - "kind": "literal", - "value": "magiclink" - }, - { - "kind": "literal", - "value": "recovery" - }, - { - "kind": "literal", - "value": "email_change" - }, - { - "kind": "literal", - "value": "email" - } - ] - } - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "session", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthSession", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.", - "type": "string" - }, - { - "name": "expires_at", - "optional": true, - "description": "A timestamp of when the token will expire. Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "expires_in", - "optional": false, - "description": "The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.", - "type": "number" - }, - { - "name": "provider_refresh_token", - "optional": true, - "description": "The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API. Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "provider_token", - "optional": true, - "description": "The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "refresh_token", - "optional": false, - "description": "A one-time used refresh token that never expires.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "When using a separate user storage, accessing properties of this object will throw an error.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "user", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Verify Signup One-Time Password (OTP)", - "code": "const { data, error } = await supabase.auth.verifyOtp({ email, token, type: 'email'})", - "response": "{\n \"data\": {\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"recovery_sent_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n },\n \"session\": {\n \"access_token\": \"\",\n \"token_type\": \"bearer\",\n \"expires_in\": 3600,\n \"expires_at\": 1700000000,\n \"refresh_token\": \"\",\n \"user\": {\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"aud\": \"authenticated\",\n \"role\": \"authenticated\",\n \"email\": \"example@email.com\",\n \"email_confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"phone\": \"\",\n \"confirmed_at\": \"2024-01-01T00:00:00Z\",\n \"recovery_sent_at\": \"2024-01-01T00:00:00Z\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"app_metadata\": {\n \"provider\": \"email\",\n \"providers\": [\n \"email\"\n ]\n },\n \"user_metadata\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"identities\": [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": false,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"example@email.com\"\n }\n ],\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"is_anonymous\": false\n }\n }\n },\n \"error\": null\n}" - }, - { - "title": "Verify SMS One-Time Password (OTP)", - "code": "const { data, error } = await supabase.auth.verifyOtp({ phone, token, type: 'sms'})" - }, - { - "title": "Verify Email Auth (Token Hash)", - "code": "const { data, error } = await supabase.auth.verifyOtp({ token_hash: tokenHash, type: 'email'})" - } - ] - }, - { - "name": "approveAuthorization", - "description": "Approves an OAuth authorization request. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nAfter approval, the user's consent is stored and an authorization code is generated. The response contains a complete redirect URL with the authorization code and state.", - "parameters": [ - { - "name": "authorizationId", - "description": "The authorization ID to approve", - "type": "string" - }, - { - "name": "options", - "optional": true, - "description": "Optional parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If false (default), automatically redirects the browser to the OAuth client. If true, returns the redirect_url without automatic redirect (useful for custom handling).", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "redirect_url", - "optional": false, - "description": "Complete redirect URL with authorization code and state parameters (e.g., \"https://app.com/callback?code=xxx&state=yyy\")", - "type": "string" - } - ], - "name": "OAuthRedirect" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "denyAuthorization", - "description": "Denies an OAuth authorization request. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nAfter denial, the response contains a redirect URL with an OAuth error (access_denied) to inform the OAuth client that the user rejected the request.", - "parameters": [ - { - "name": "authorizationId", - "description": "The authorization ID to deny", - "type": "string" - }, - { - "name": "options", - "optional": true, - "description": "Optional parameters", - "type": { - "kind": "object", - "properties": [ - { - "name": "skipBrowserRedirect", - "optional": true, - "description": "If false (default), automatically redirects the browser to the OAuth client. If true, returns the redirect_url without automatic redirect (useful for custom handling).", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "redirect_url", - "optional": false, - "description": "Complete redirect URL with authorization code and state parameters (e.g., \"https://app.com/callback?code=xxx&state=yyy\")", - "type": "string" - } - ], - "name": "OAuthRedirect" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "getAuthorizationDetails", - "description": "Retrieves details about an OAuth authorization request. Used to display consent information to the user. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis method returns one of two response types: - `OAuthAuthorizationDetails`: User needs to consent - show consent page with client info - `OAuthRedirect`: User already consented - redirect immediately to the OAuth client\nUse type narrowing to distinguish between the responses: ```typescript if ('authorization_id' in data) { // Show consent page } else { // Redirect to data.redirect_url } ```", - "parameters": [ - { - "name": "authorizationId", - "description": "The authorization ID from the authorization request", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "authorization_id", - "optional": false, - "description": "The authorization ID used to approve or deny the request", - "type": "string" - }, - { - "name": "client", - "optional": false, - "description": "OAuth client requesting authorization", - "type": { - "kind": "object", - "properties": [ - { - "name": "id", - "optional": false, - "description": "Unique identifier for the OAuth client (UUID)", - "type": "string" - }, - { - "name": "logo_uri", - "optional": false, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "uri", - "optional": false, - "description": "URI of the OAuth client's website", - "type": "string" - } - ], - "name": "OAuthAuthorizationClient" - } - }, - { - "name": "redirect_uri", - "optional": false, - "description": "The OAuth client's registered redirect URI (base URI without query parameters)", - "type": "string" - }, - { - "name": "scope", - "optional": false, - "description": "Space-separated list of requested scopes (e.g., \"openid profile email\")", - "type": "string" - }, - { - "name": "user", - "optional": false, - "description": "User object associated with the authorization", - "type": { - "kind": "object", - "properties": [ - { - "name": "email", - "optional": false, - "description": "User email", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "User ID (UUID)", - "type": "string" - } - ] - } - } - ], - "name": "OAuthAuthorizationDetails" - }, - { - "kind": "object", - "properties": [ - { - "name": "redirect_url", - "optional": false, - "description": "Complete redirect URL with authorization code and state parameters (e.g., \"https://app.com/callback?code=xxx&state=yyy\")", - "type": "string" - } - ], - "name": "OAuthRedirect" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "listGrants", - "description": "Lists all OAuth grants that the authenticated user has authorized. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "properties": [ - { - "name": "client", - "optional": false, - "description": "OAuth client information", - "type": { - "kind": "object", - "properties": [ - { - "name": "id", - "optional": false, - "description": "Unique identifier for the OAuth client (UUID)", - "type": "string" - }, - { - "name": "logo_uri", - "optional": false, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "uri", - "optional": false, - "description": "URI of the OAuth client's website", - "type": "string" - } - ], - "name": "OAuthAuthorizationClient" - } - }, - { - "name": "granted_at", - "optional": false, - "description": "Timestamp when the grant was created (ISO 8601 date-time)", - "type": "string" - }, - { - "name": "scopes", - "optional": false, - "description": "Array of scopes granted to this client", - "type": { - "kind": "array", - "elementType": "string" - } - } - ], - "name": "OAuthGrant" - } - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "revokeGrant", - "description": "Revokes a user's OAuth grant for a specific client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nRevocation marks consent as revoked, deletes active sessions for that OAuth client, and invalidates associated refresh tokens.", - "parameters": [ - { - "name": "options", - "description": "Revocation options", - "type": { - "kind": "object", - "properties": [ - { - "name": "clientId", - "optional": false, - "description": "The OAuth client identifier (UUID) to revoke access for", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "deleteFactor", - "description": "Deletes a factor on a user. This will log the user out of all active sessions if the deleted factor was verified.", - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "id", - "optional": false, - "description": "ID of the MFA factor to delete.", - "type": "string" - }, - { - "name": "userId", - "optional": false, - "description": "ID of the user whose factor is being deleted.", - "type": "string" - } - ], - "name": "AuthMFAAdminDeleteFactorParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "id", - "optional": false, - "description": "ID of the factor that was successfully deleted.", - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Delete a factor for a user", - "code": "const { data, error } = await supabase.auth.admin.mfa.deleteFactor({\n id: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n userId: 'a89baba7-b1b7-440f-b4bb-91026967f66b',\n})", - "response": "{\n data: {\n id: '34e770dd-9ff9-416c-87fa-43b31d7ef225'\n },\n error: null\n}" - } - ] - }, - { - "name": "listFactors", - "description": "Lists all factors associated to a user.", - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "userId", - "optional": false, - "description": "ID of the user.", - "type": "string" - } - ], - "name": "AuthMFAAdminListFactorsParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "factors", - "optional": false, - "description": "All factors attached to the user.", - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "typeParam", - "name": "Type" - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "typeParam", - "name": "Status" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "List all factors for a user", - "code": "const { data, error } = await supabase.auth.admin.mfa.listFactors()", - "response": "{\n data: {\n factors: Factor[\n {\n id: '',\n friendly_name: 'Auth App Factor',\n factor_type: 'totp',\n status: 'verified',\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z'\n }\n ]\n },\n error: null\n}" - } - ] - }, - { - "name": "createClient", - "description": "Creates a new OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "grant_types", - "optional": true, - "description": "Array of allowed grant types (optional, defaults to authorization_code and refresh_token)", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "response_types", - "optional": true, - "description": "Array of allowed response types (optional, defaults to code)", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": true, - "description": "Token endpoint authentication method (defaults to server default if not specified)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - } - ], - "name": "CreateOAuthClientParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "client_id", - "optional": false, - "description": "Unique identifier for the OAuth client", - "type": "string" - }, - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_secret", - "optional": true, - "description": "Client secret (only returned on registration and regeneration)", - "type": "string" - }, - { - "name": "client_type", - "optional": false, - "description": "Type of OAuth client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "public" - }, - { - "kind": "literal", - "value": "confidential" - } - ] - } - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "description": "Timestamp when the client was created", - "type": "string" - }, - { - "name": "grant_types", - "optional": false, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "registration_type", - "optional": false, - "description": "Registration type of the client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "dynamic" - }, - { - "kind": "literal", - "value": "manual" - } - ] - } - }, - { - "name": "response_types", - "optional": false, - "description": "Array of allowed response types", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": false, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "description": "Timestamp when the client was last updated", - "type": "string" - } - ], - "name": "OAuthClient" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "deleteClient", - "description": "Deletes an OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "clientId", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - ] - } - } - ] - } - ] - } - }, - { - "name": "getClient", - "description": "Gets details of a specific OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "clientId", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "client_id", - "optional": false, - "description": "Unique identifier for the OAuth client", - "type": "string" - }, - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_secret", - "optional": true, - "description": "Client secret (only returned on registration and regeneration)", - "type": "string" - }, - { - "name": "client_type", - "optional": false, - "description": "Type of OAuth client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "public" - }, - { - "kind": "literal", - "value": "confidential" - } - ] - } - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "description": "Timestamp when the client was created", - "type": "string" - }, - { - "name": "grant_types", - "optional": false, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "registration_type", - "optional": false, - "description": "Registration type of the client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "dynamic" - }, - { - "kind": "literal", - "value": "manual" - } - ] - } - }, - { - "name": "response_types", - "optional": false, - "description": "Array of allowed response types", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": false, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "description": "Timestamp when the client was last updated", - "type": "string" - } - ], - "name": "OAuthClient" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "listClients", - "description": "Lists all OAuth clients with optional pagination. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "page", - "optional": true, - "description": "The page number", - "type": "number" - }, - { - "name": "perPage", - "optional": true, - "description": "Number of items returned per page", - "type": "number" - } - ], - "name": "PageParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "intersection", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "clients", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "properties": [ - { - "name": "client_id", - "optional": false, - "description": "Unique identifier for the OAuth client", - "type": "string" - }, - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_secret", - "optional": true, - "description": "Client secret (only returned on registration and regeneration)", - "type": "string" - }, - { - "name": "client_type", - "optional": false, - "description": "Type of OAuth client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "public" - }, - { - "kind": "literal", - "value": "confidential" - } - ] - } - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "description": "Timestamp when the client was created", - "type": "string" - }, - { - "name": "grant_types", - "optional": false, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "registration_type", - "optional": false, - "description": "Registration type of the client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "dynamic" - }, - { - "kind": "literal", - "value": "manual" - } - ] - } - }, - { - "name": "response_types", - "optional": false, - "description": "Array of allowed response types", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": false, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "description": "Timestamp when the client was last updated", - "type": "string" - } - ], - "name": "OAuthClient" - } - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "lastPage", - "optional": false, - "type": "number" - }, - { - "name": "nextPage", - "optional": false, - "type": { - "kind": "union", - "types": [ - "number", - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "total", - "optional": false, - "type": "number" - } - ], - "name": "Pagination" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "clients", - "optional": false, - "type": { - "kind": "tuple", - "elements": [] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - } - ] - } - ] - } - }, - { - "name": "regenerateClientSecret", - "description": "Regenerates the secret for an OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "clientId", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "client_id", - "optional": false, - "description": "Unique identifier for the OAuth client", - "type": "string" - }, - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_secret", - "optional": true, - "description": "Client secret (only returned on registration and regeneration)", - "type": "string" - }, - { - "name": "client_type", - "optional": false, - "description": "Type of OAuth client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "public" - }, - { - "kind": "literal", - "value": "confidential" - } - ] - } - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "description": "Timestamp when the client was created", - "type": "string" - }, - { - "name": "grant_types", - "optional": false, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "registration_type", - "optional": false, - "description": "Registration type of the client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "dynamic" - }, - { - "kind": "literal", - "value": "manual" - } - ] - } - }, - { - "name": "response_types", - "optional": false, - "description": "Array of allowed response types", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": false, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "description": "Timestamp when the client was last updated", - "type": "string" - } - ], - "name": "OAuthClient" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "updateClient", - "description": "Updates an existing OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.\nThis function should only be called on a server. Never expose your `service_role` key in the browser.", - "parameters": [ - { - "name": "clientId", - "type": "string" - }, - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "client_name", - "optional": true, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "grant_types", - "optional": true, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": true, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "token_endpoint_auth_method", - "optional": true, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - } - ], - "name": "UpdateOAuthClientParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "client_id", - "optional": false, - "description": "Unique identifier for the OAuth client", - "type": "string" - }, - { - "name": "client_name", - "optional": false, - "description": "Human-readable name of the OAuth client", - "type": "string" - }, - { - "name": "client_secret", - "optional": true, - "description": "Client secret (only returned on registration and regeneration)", - "type": "string" - }, - { - "name": "client_type", - "optional": false, - "description": "Type of OAuth client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "public" - }, - { - "kind": "literal", - "value": "confidential" - } - ] - } - }, - { - "name": "client_uri", - "optional": true, - "description": "URI of the OAuth client", - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "description": "Timestamp when the client was created", - "type": "string" - }, - { - "name": "grant_types", - "optional": false, - "description": "Array of allowed grant types", - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "authorization_code" - }, - { - "kind": "literal", - "value": "refresh_token" - } - ] - } - } - }, - { - "name": "logo_uri", - "optional": true, - "description": "URI of the OAuth client's logo", - "type": "string" - }, - { - "name": "redirect_uris", - "optional": false, - "description": "Array of allowed redirect URIs", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "registration_type", - "optional": false, - "description": "Registration type of the client", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "dynamic" - }, - { - "kind": "literal", - "value": "manual" - } - ] - } - }, - { - "name": "response_types", - "optional": false, - "description": "Array of allowed response types", - "type": { - "kind": "array", - "elementType": { - "kind": "literal", - "value": "code" - } - } - }, - { - "name": "scope", - "optional": true, - "description": "Scope of the OAuth client", - "type": "string" - }, - { - "name": "token_endpoint_auth_method", - "optional": false, - "description": "Token endpoint authentication method", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "none" - }, - { - "kind": "literal", - "value": "client_secret_basic" - }, - { - "kind": "literal", - "value": "client_secret_post" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "description": "Timestamp when the client was last updated", - "type": "string" - } - ], - "name": "OAuthClient" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "challenge", - "description": "Prepares a challenge used to verify that a user has access to a MFA factor.", - "remarks": [ - "- An [enrolled factor](/docs/reference/javascript/auth-mfa-enroll) is required before creating a challenge. - To verify a challenge, see [`mfa.verify()`](/docs/reference/javascript/auth-mfa-verify). - A phone factor sends a code to the user upon challenge. The channel defaults to `sms` unless otherwise specified." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "factorId", - "optional": false, - "description": "ID of the factor to be challenged. Returned in enroll().", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "AuthError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "__isAuthError", - "optional": false, - "type": "boolean" - }, - { - "name": "code", - "optional": false, - "description": "Error code associated with the error. Most errors coming from HTTP responses will have a code, though some errors that occur before a response is received will not have one present. In that case #status will also be undefined.", - "type": { - "kind": "union", - "types": [ - "undefined", - { - "kind": "reference", - "name": "ErrorCode" - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "status", - "optional": false, - "description": "HTTP status code that caused the error.", - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "expires_at", - "optional": false, - "description": "Timestamp in UNIX seconds when this challenge will no longer be usable.", - "type": "number" - }, - { - "name": "id", - "optional": false, - "description": "ID of the newly created challenge.", - "type": "string" - }, - { - "name": "type", - "optional": false, - "description": "Factor Type which generated the challenge", - "type": { - "kind": "literal", - "value": "totp" - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create a challenge for a factor", - "code": "const { data, error } = await supabase.auth.mfa.challenge({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225'\n})", - "response": "{\n data: {\n id: '',\n type: 'totp',\n expires_at: 1700000000\n },\n error: null\n}" - }, - { - "title": "Create a challenge for a phone factor", - "code": "const { data, error } = await supabase.auth.mfa.challenge({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n})", - "response": "{\n data: {\n id: '',\n type: 'phone',\n expires_at: 1700000000\n },\n error: null\n}" - }, - { - "title": "Create a challenge for a phone factor (WhatsApp)", - "code": "const { data, error } = await supabase.auth.mfa.challenge({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n channel: 'whatsapp',\n})", - "response": "{\n data: {\n id: '',\n expires_at: 1700000000\n },\n error: null\n}" - } - ] - }, - { - "name": "challengeAndVerify", - "description": "Helper method which creates a challenge and immediately uses the given code to verify against it thereafter. The verification code is provided by the user by entering a code seen in their authenticator app.", - "remarks": [ - "- Intended for use with only TOTP factors. - An [enrolled factor](/docs/reference/javascript/auth-mfa-enroll) is required before invoking `challengeAndVerify()`. - Executes [`mfa.challenge()`](/docs/reference/javascript/auth-mfa-challenge) and [`mfa.verify()`](/docs/reference/javascript/auth-mfa-verify) in a single step." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "code", - "optional": false, - "description": "Verification code provided by the user.", - "type": "string" - }, - { - "name": "factorId", - "optional": false, - "description": "ID of the factor being verified. Returned in enroll().", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "New access token (JWT) after successful verification.", - "type": "string" - }, - { - "name": "expires_in", - "optional": false, - "description": "Number of seconds in which the access token will expire.", - "type": "number" - }, - { - "name": "refresh_token", - "optional": false, - "description": "Refresh token you can use to obtain new access tokens when expired.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "description": "Type of token, always `bearer`.", - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "Updated user profile.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ], - "name": "AuthMFAVerifyResponseData" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create and verify a challenge for a factor", - "code": "const { data, error } = await supabase.auth.mfa.challengeAndVerify({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n code: '123456'\n})", - "response": "{\n data: {\n access_token: '',\n token_type: 'Bearer',\n expires_in: 3600,\n refresh_token: '',\n user: {\n id: '11111111-1111-1111-1111-111111111111',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com',\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {\n provider: 'email',\n providers: [\n \"email\",\n ]\n },\n user_metadata: {},\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false,\n factors: [\n \"id\": '',\n \"friendly_name\": 'Important Auth App',\n \"factor_type\": 'totp',\n \"status\": 'verified',\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n ]\n }\n }\n error: null\n}" - } - ] - }, - { - "name": "enroll", - "description": "Starts the enrollment process for a new Multi-Factor Authentication (MFA) factor. This method creates a new `unverified` factor. To verify a factor, present the QR code or secret to the user and ask them to add it to their authenticator app. The user has to enter the code from their authenticator app to verify it.\nUpon verifying a factor, all other sessions are logged out and the current session's authenticator level is promoted to `aal2`.", - "remarks": [ - "- Use `totp` or `phone` as the `factorType` and use the returned `id` to create a challenge. - To create a challenge, see [`mfa.challenge()`](/docs/reference/javascript/auth-mfa-challenge). - To verify a challenge, see [`mfa.verify()`](/docs/reference/javascript/auth-mfa-verify). - To create and verify a TOTP challenge in a single step, see [`mfa.challengeAndVerify()`](/docs/reference/javascript/auth-mfa-challengeandverify). - To generate a QR code for the `totp` secret in Next.js, you can do the following: ```html {data.totp.uri} ``` - The `challenge` and `verify` steps are separated when using Phone factors as the user will need time to receive and input the code obtained from the SMS in challenge." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "factorType", - "optional": false, - "description": "The type of factor being enrolled.", - "type": { - "kind": "literal", - "value": "totp" - } - }, - { - "name": "friendlyName", - "optional": true, - "description": "Human readable name assigned to the factor.", - "type": "string" - }, - { - "name": "issuer", - "optional": true, - "description": "Domain which the user is enrolled with.", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "conditional" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Enroll a time-based, one-time password (TOTP) factor", - "code": "const { data, error } = await supabase.auth.mfa.enroll({\n factorType: 'totp',\n friendlyName: 'your_friendly_name'\n})\n\n// Use the id to create a challenge.\n// The challenge can be verified by entering the code generated from the authenticator app.\n// The code will be generated upon scanning the qr_code or entering the secret into the authenticator app.\nconst { id, type, totp: { qr_code, secret, uri }, friendly_name } = data\nconst challenge = await supabase.auth.mfa.challenge({ factorId: id });", - "response": "{\n data: {\n id: '',\n type: 'totp'\n totp: {\n qr_code: '',\n secret: '',\n uri: '',\n }\n friendly_name?: 'Important app'\n },\n error: null\n}" - }, - { - "title": "Enroll a Phone Factor", - "code": "const { data, error } = await supabase.auth.mfa.enroll({\n factorType: 'phone',\n friendlyName: 'your_friendly_name',\n phone: '+12345678',\n})\n\n// Use the id to create a challenge and send an SMS with a code to the user.\nconst { id, type, friendly_name, phone } = data\n\nconst challenge = await supabase.auth.mfa.challenge({ factorId: id });", - "response": "{\n data: {\n id: '',\n type: 'phone',\n friendly_name?: 'Important app',\n phone: '+5787123456'\n },\n error: null\n}" - } - ] - }, - { - "name": "getAuthenticatorAssuranceLevel", - "description": "Returns the Authenticator Assurance Level (AAL) for the active session.\n- `aal1` (or `null`) means that the user's identity has been verified only with a conventional login (email+password, OTP, magic link, social login, etc.). - `aal2` means that the user's identity has been verified both with a conventional login and at least one MFA factor.\nWhen called without a JWT parameter, this method is fairly quick (microseconds) and rarely uses the network. When a JWT is provided (useful in server-side environments like Edge Functions where no session is stored), this method will make a network request to validate the user and fetch their MFA factors.", - "remarks": [ - "- Authenticator Assurance Level (AAL) is the measure of the strength of an authentication mechanism. - In Supabase, having an AAL of `aal1` refers to having the 1st factor of authentication such as an email and password or OAuth sign-in while `aal2` refers to the 2nd factor of authentication such as a time-based, one-time-password (TOTP) or Phone factor. - If the user has a verified factor, the `nextLevel` field will return `aal2`, else, it will return `aal1`. - An optional `jwt` parameter can be passed to check the AAL level of a specific JWT instead of the current session." - ], - "parameters": [ - { - "name": "jwt", - "optional": true, - "description": "Takes in an optional access token JWT. If no JWT is provided, the JWT from the current session is used.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "currentAuthenticationMethods", - "optional": false, - "description": "A list of all authentication methods attached to this session. Use the information here to detect the last time a user verified a factor, for example if implementing a step-up scenario.\nSupports both RFC-8176 compliant format (string[]) and detailed format (AMREntry[]). - String format: ['password', 'otp'] - RFC-8176 compliant - Object format: [{ method: 'password', timestamp: 1234567890 }] - includes timestamps", - "type": { - "kind": "union", - "types": [ - { - "kind": "array", - "elementType": { - "kind": "object", - "name": "AMREntry", - "properties": [ - { - "name": "method", - "optional": false, - "description": "Authentication method name.", - "type": { - "kind": "union", - "types": [ - { - "kind": "indexedAccess", - "objectType": { - "kind": "query" - }, - "indexType": null - }, - { - "kind": "intersection", - "types": [ - "string", - { - "kind": "object", - "properties": [] - } - ] - } - ] - } - }, - { - "name": "timestamp", - "optional": false, - "description": "Timestamp when the method was successfully used. Represents number of seconds since 1st January 1970 (UNIX epoch) in UTC.", - "type": "number" - } - ] - } - }, - { - "kind": "array", - "elementType": "string" - } - ] - } - }, - { - "name": "currentLevel", - "optional": false, - "description": "Current AAL level of the session.", - "type": { - "kind": "union", - "types": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "aal1" - }, - { - "kind": "literal", - "value": "aal2" - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - }, - { - "name": "nextLevel", - "optional": false, - "description": "Next possible AAL level for the session. If the next level is higher than the current one, the user should go through MFA.", - "type": { - "kind": "union", - "types": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "aal1" - }, - { - "kind": "literal", - "value": "aal2" - } - ] - }, - { - "kind": "literal", - "value": null - } - ] - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get the AAL details of a session", - "code": "const { data, error } = await supabase.auth.mfa.getAuthenticatorAssuranceLevel()\nconst { currentLevel, nextLevel, currentAuthenticationMethods } = data", - "response": "{\n data: {\n currentLevel: 'aal1',\n nextLevel: 'aal2',\n currentAuthenticationMethods: [\n {\n method: 'password',\n timestamp: 1700000000\n }\n ]\n }\n error: null\n}" - }, - { - "title": "Get the AAL details for a specific JWT", - "code": "const { data, error } = await supabase.auth.mfa.getAuthenticatorAssuranceLevel(jwt)" - } - ] - }, - { - "name": "listFactors", - "description": "Returns the list of MFA factors enabled for this user.", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "intersection", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "all", - "optional": false, - "description": "All available factors (verified and unverified).", - "type": { - "kind": "array", - "elementType": { - "kind": "conditional" - } - } - } - ] - }, - { - "kind": "mapped" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - } - }, - { - "name": "unenroll", - "description": "Unenroll removes a MFA factor. A user has to have an `aal2` authenticator level in order to unenroll a `verified` factor.", - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "factorId", - "optional": false, - "description": "ID of the factor being unenrolled.", - "type": "string" - } - ], - "name": "MFAUnenrollParams" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "id", - "optional": false, - "description": "ID of the factor that was successfully unenrolled.", - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Unenroll a factor", - "code": "const { data, error } = await supabase.auth.mfa.unenroll({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n})", - "response": "{\n data: {\n id: ''\n },\n error: null\n}" - } - ] - }, - { - "name": "verify", - "description": "Verifies a code against a challenge. The verification code is provided by the user by entering a code seen in their authenticator app.", - "remarks": [ - "- To verify a challenge, please [create a challenge](/docs/reference/javascript/auth-mfa-challenge) first." - ], - "parameters": [ - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "challengeId", - "optional": false, - "description": "ID of the challenge being verified. Returned in challenge().", - "type": "string" - }, - { - "name": "code", - "optional": false, - "description": "Verification code provided by the user.", - "type": "string" - }, - { - "name": "factorId", - "optional": false, - "description": "ID of the factor being verified. Returned in enroll().", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "access_token", - "optional": false, - "description": "New access token (JWT) after successful verification.", - "type": "string" - }, - { - "name": "expires_in", - "optional": false, - "description": "Number of seconds in which the access token will expire.", - "type": "number" - }, - { - "name": "refresh_token", - "optional": false, - "description": "Refresh token you can use to obtain new access tokens when expired.", - "type": "string" - }, - { - "name": "token_type", - "optional": false, - "description": "Type of token, always `bearer`.", - "type": { - "kind": "literal", - "value": "bearer" - } - }, - { - "name": "user", - "optional": false, - "description": "Updated user profile.", - "type": { - "kind": "object", - "name": "AuthUser", - "properties": [ - { - "name": "action_link", - "optional": true, - "type": "string" - }, - { - "name": "app_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserAppMetadata", - "properties": [ - { - "name": "provider", - "optional": true, - "description": "The first provider that the user used to sign up with.", - "type": "string" - }, - { - "name": "providers", - "optional": true, - "description": "A list of all providers that the user has linked to their account.", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "aud", - "optional": false, - "type": "string" - }, - { - "name": "banned_until", - "optional": true, - "type": "string" - }, - { - "name": "confirmation_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "deleted_at", - "optional": true, - "type": "string" - }, - { - "name": "email", - "optional": true, - "type": "string" - }, - { - "name": "email_change_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "email_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "factors", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "verified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - }, - { - "kind": "object", - "properties": [ - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "factor_type", - "optional": false, - "description": "Type of factor. `totp` and `phone` supported with this version", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "webauthn" - }, - { - "kind": "literal", - "value": "totp" - }, - { - "kind": "literal", - "value": "phone" - } - ] - } - }, - { - "name": "friendly_name", - "optional": true, - "description": "Friendly name of the factor, useful to disambiguate between multiple factors.", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "ID of the factor.", - "type": "string" - }, - { - "name": "last_challenged_at", - "optional": true, - "type": "string" - }, - { - "name": "status", - "optional": false, - "description": "The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`", - "type": { - "kind": "literal", - "value": "unverified" - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ], - "name": "Factor" - } - ] - } - } - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identities", - "optional": true, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "UserIdentity", - "properties": [ - { - "name": "created_at", - "optional": true, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "identity_data", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "identity_id", - "optional": false, - "type": "string" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "provider", - "optional": false, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_id", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "invited_at", - "optional": true, - "type": "string" - }, - { - "name": "is_anonymous", - "optional": true, - "type": "boolean" - }, - { - "name": "is_sso_user", - "optional": true, - "type": "boolean" - }, - { - "name": "last_sign_in_at", - "optional": true, - "type": "string" - }, - { - "name": "new_email", - "optional": true, - "type": "string" - }, - { - "name": "new_phone", - "optional": true, - "type": "string" - }, - { - "name": "phone", - "optional": true, - "type": "string" - }, - { - "name": "phone_confirmed_at", - "optional": true, - "type": "string" - }, - { - "name": "recovery_sent_at", - "optional": true, - "type": "string" - }, - { - "name": "role", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": true, - "type": "string" - }, - { - "name": "user_metadata", - "optional": false, - "type": { - "kind": "object", - "name": "UserMetadata", - "properties": [] - } - } - ] - } - } - ], - "name": "AuthMFAVerifyResponseData" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "conditional" - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Verify a challenge for a factor", - "code": "const { data, error } = await supabase.auth.mfa.verify({\n factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',\n challengeId: '4034ae6f-a8ce-4fb5-8ee5-69a5863a7c15',\n code: '123456'\n})", - "response": "{\n data: {\n access_token: '',\n token_type: 'Bearer',\n expires_in: 3600,\n refresh_token: '',\n user: {\n id: '11111111-1111-1111-1111-111111111111',\n aud: 'authenticated',\n role: 'authenticated',\n email: 'example@email.com',\n email_confirmed_at: '2024-01-01T00:00:00Z',\n phone: '',\n confirmation_sent_at: '2024-01-01T00:00:00Z',\n confirmed_at: '2024-01-01T00:00:00Z',\n last_sign_in_at: '2024-01-01T00:00:00Z',\n app_metadata: {\n provider: 'email',\n providers: [\n \"email\",\n ]\n },\n user_metadata: {},\n identities: [\n {\n \"identity_id\": \"22222222-2222-2222-2222-222222222222\",\n \"id\": \"11111111-1111-1111-1111-111111111111\",\n \"user_id\": \"11111111-1111-1111-1111-111111111111\",\n \"identity_data\": {\n \"email\": \"example@email.com\",\n \"email_verified\": true,\n \"phone_verified\": false,\n \"sub\": \"11111111-1111-1111-1111-111111111111\"\n },\n \"provider\": \"email\",\n \"last_sign_in_at\": \"2024-01-01T00:00:00Z\",\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\",\n \"email\": \"email@example.com\"\n },\n ],\n created_at: '2024-01-01T00:00:00Z',\n updated_at: '2024-01-01T00:00:00Z',\n is_anonymous: false,\n factors: [\n \"id\": '',\n \"friendly_name\": 'Important Auth App',\n \"factor_type\": 'totp',\n \"status\": 'verified',\n \"created_at\": \"2024-01-01T00:00:00Z\",\n \"updated_at\": \"2024-01-01T00:00:00Z\"\n ]\n }\n }\n error: null\n}" - } - ] - } - ] - }, - { - "category": "Functions", - "definitions": [ - { - "name": "invoke", - "description": "Invokes a function", - "remarks": [ - "- Requires an Authorization header. - Invoke params generally match the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) spec. - When you pass in a body to your function, we automatically attach the Content-Type header for `Blob`, `ArrayBuffer`, `File`, `FormData` and `String`. If it doesn't match any of these types we assume the payload is `json`, serialize it and attach the `Content-Type` header as `application/json`. You can override this behavior by passing in a `Content-Type` header of your own. - Responses are automatically parsed as `json`, `blob` and `form-data` depending on the `Content-Type` header sent by your function. Responses are parsed as `text` by default." - ], - "parameters": [ - { - "name": "functionName", - "description": "The name of the Function to invoke.", - "type": "string" - }, - { - "name": "options", - "description": "Options for invoking the Function.", - "type": { - "kind": "object", - "properties": [ - { - "name": "body", - "optional": true, - "description": "The body of the request.", - "type": { - "kind": "union", - "types": [ - { - "kind": "reference", - "name": "File" - }, - { - "kind": "reference", - "name": "Blob" - }, - { - "kind": "reference", - "name": "ArrayBuffer" - }, - { - "kind": "reference", - "name": "FormData" - }, - { - "kind": "reference", - "name": "ReadableStream", - "typeArguments": [ - { - "kind": "reference", - "name": "Uint8Array" - } - ] - }, - { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "any" - ] - }, - "string" - ] - } - }, - { - "name": "headers", - "optional": true, - "description": "Object representing the headers to send with the request.", - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "method", - "optional": true, - "description": "The HTTP verb of the request", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "POST" - }, - { - "kind": "literal", - "value": "GET" - }, - { - "kind": "literal", - "value": "PUT" - }, - { - "kind": "literal", - "value": "PATCH" - }, - { - "kind": "literal", - "value": "DELETE" - } - ] - } - }, - { - "name": "region", - "optional": true, - "description": "The Region to invoke the function in.", - "type": { - "kind": "reference", - "name": "FunctionRegion" - } - }, - { - "name": "signal", - "optional": true, - "description": "The AbortSignal to use for the request.", - "type": { - "kind": "reference", - "name": "AbortSignal" - } - }, - { - "name": "timeout", - "optional": true, - "description": "The timeout for the request in milliseconds. If the function takes longer than this, the request will be aborted.", - "type": "number" - } - ], - "name": "FunctionInvokeOptions" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "reference", - "name": "FunctionsResponseSuccess", - "typeArguments": [ - { - "kind": "typeParam", - "name": "T" - } - ] - }, - { - "kind": "reference", - "name": "FunctionsResponseFailure" - } - ] - } - ] - }, - "examples": [ - { - "title": "Example 1", - "code": "const { data, error } = await functions.invoke('hello-world', {\n body: { name: 'Ada' },\n})", - "notes": "Error handling\nA `FunctionsHttpError` error is returned if your function throws an error, `FunctionsRelayError` if the Supabase Relay has an error processing your function and `FunctionsFetchError` if there is a network error in calling your function." - }, - { - "title": "Basic invocation", - "code": "const { data, error } = await supabase.functions.invoke('hello', {\n body: { foo: 'bar' }\n})", - "notes": "Passing custom headers\nYou can pass custom headers to your function. Note: supabase-js automatically passes the `Authorization` header with the signed in user's JWT." - }, - { - "title": "Error handling", - "code": "import { FunctionsHttpError, FunctionsRelayError, FunctionsFetchError } from \"@supabase/supabase-js\";\n\nconst { data, error } = await supabase.functions.invoke('hello', {\n headers: {\n \"my-custom-header\": 'my-custom-header-value'\n },\n body: { foo: 'bar' }\n})\n\nif (error instanceof FunctionsHttpError) {\n const errorMessage = await error.context.json()\n console.log('Function returned an error', errorMessage)\n} else if (error instanceof FunctionsRelayError) {\n console.log('Relay error:', error.message)\n} else if (error instanceof FunctionsFetchError) {\n console.log('Fetch error:', error.message)\n}", - "notes": "A `FunctionsHttpError` error is returned if your function throws an error, `FunctionsRelayError` if the Supabase Relay has an error processing your function and `FunctionsFetchError` if there is a network error in calling your function." - }, - { - "title": "Passing custom headers", - "code": "const { data, error } = await supabase.functions.invoke('hello', {\n headers: {\n \"my-custom-header\": 'my-custom-header-value'\n },\n body: { foo: 'bar' }\n})", - "notes": "You can pass custom headers to your function. Note: supabase-js automatically passes the `Authorization` header with the signed in user's JWT." - }, - { - "title": "Calling with DELETE HTTP verb", - "code": "const { data, error } = await supabase.functions.invoke('hello', {\n headers: {\n \"my-custom-header\": 'my-custom-header-value'\n },\n body: { foo: 'bar' },\n method: 'DELETE'\n})", - "notes": "You can also set the HTTP verb to `DELETE` when calling your Edge Function." - }, - { - "title": "Invoking a Function in the UsEast1 region", - "code": "import { createClient, FunctionRegion } from '@supabase/supabase-js'\n\nconst { data, error } = await supabase.functions.invoke('hello', {\n body: { foo: 'bar' },\n region: FunctionRegion.UsEast1\n})", - "notes": "Here are the available regions:\n- `FunctionRegion.Any`\n- `FunctionRegion.ApNortheast1`\n- `FunctionRegion.ApNortheast2`\n- `FunctionRegion.ApSouth1`\n- `FunctionRegion.ApSoutheast1`\n- `FunctionRegion.ApSoutheast2`\n- `FunctionRegion.CaCentral1`\n- `FunctionRegion.EuCentral1`\n- `FunctionRegion.EuWest1`\n- `FunctionRegion.EuWest2`\n- `FunctionRegion.EuWest3`\n- `FunctionRegion.SaEast1`\n- `FunctionRegion.UsEast1`\n- `FunctionRegion.UsWest1`\n- `FunctionRegion.UsWest2`" - }, - { - "title": "Calling with GET HTTP verb", - "code": "const { data, error } = await supabase.functions.invoke('hello', {\n headers: {\n \"my-custom-header\": 'my-custom-header-value'\n },\n method: 'GET'\n})", - "notes": "You can also set the HTTP verb to `GET` when calling your Edge Function." - }, - { - "title": "Example 7", - "code": "const { data, error } = await functions.invoke('hello-world', {\n body: { name: 'Ada' },\n})" - } - ] - }, - { - "name": "setAuth", - "description": "Updates the authorization header", - "parameters": [ - { - "name": "token", - "description": "the new jwt token sent in the authorisation header", - "type": "string" - } - ], - "returnType": "void", - "examples": [ - { - "title": "Setting the authorization header", - "code": "functions.setAuth(session.access_token)" - } - ] - } - ] - }, - { - "category": "Realtime", - "definitions": [ - { - "name": "httpSend", - "description": "Sends a broadcast message explicitly via REST API.\nThis method always uses the REST API endpoint regardless of WebSocket connection state. Useful when you want to guarantee REST delivery or when gradually migrating from implicit REST fallback.", - "parameters": [ - { - "name": "event", - "description": "The name of the broadcast event", - "type": "string" - }, - { - "name": "payload", - "description": "Payload to be sent (required)", - "type": "any" - }, - { - "name": "opts", - "description": "Options including timeout", - "type": { - "kind": "object", - "properties": [ - { - "name": "timeout", - "optional": true, - "type": "number" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "success", - "optional": false, - "type": { - "kind": "literal", - "value": true - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "error", - "optional": false, - "type": "string" - }, - { - "name": "status", - "optional": false, - "type": "number" - }, - { - "name": "success", - "optional": false, - "type": { - "kind": "literal", - "value": false - } - } - ] - } - ] - } - ] - } - }, - { - "name": "on", - "description": "Listen to realtime events on this channel.", - "remarks": [ - "- By default, Broadcast and Presence are enabled for all projects. - By default, listening to database changes is disabled for new projects due to database performance and security concerns. You can turn it on by managing Realtime's [replication](/docs/guides/api#realtime-api-overview). - You can receive the \"previous\" data for updates and deletes by setting the table's `REPLICA IDENTITY` to `FULL` (e.g., `ALTER TABLE your_table REPLICA IDENTITY FULL;`). - Row level security is not applied to delete statements. When RLS is enabled and replica identity is set to full, only the primary key is sent to clients." - ], - "parameters": [ - { - "name": "type", - "type": { - "kind": "literal", - "value": "presence" - } - }, - { - "name": "filter", - "type": { - "kind": "object", - "properties": [ - { - "name": "event", - "optional": false, - "type": { - "kind": "literal", - "value": "sync" - } - } - ] - } - }, - { - "name": "callback", - "type": { - "kind": "object", - "properties": [] - } - } - ], - "returnType": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "description": "The realtime channel to bind to.", - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "description": "Listen to realtime events on this channel.", - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Listen to broadcast messages", - "code": "const channel = supabase.channel(\"room1\")\n\nchannel.on(\"broadcast\", { event: \"cursor-pos\" }, (payload) => {\n console.log(\"Cursor position received!\", payload);\n}).subscribe((status) => {\n if (status === \"SUBSCRIBED\") {\n channel.send({\n type: \"broadcast\",\n event: \"cursor-pos\",\n payload: { x: Math.random(), y: Math.random() },\n });\n }\n});", - "notes": "Listen to updates\nBy default, Supabase will send only the updated record. If you want to receive the previous values as well you can\nenable full replication for the table you are listening to:\n\n```sql\nalter table \"your_table\" replica identity full;\n```" - }, - { - "title": "Listen to presence sync", - "code": "const channel = supabase.channel('room1')\nchannel\n .on('presence', { event: 'sync' }, () => {\n console.log('Synced presence state: ', channel.presenceState())\n })\n .subscribe(async (status) => {\n if (status === 'SUBSCRIBED') {\n await channel.track({ online_at: new Date().toISOString() })\n }\n })", - "notes": "Listen to deletes\nBy default, Supabase does not send deleted records. If you want to receive the deleted record you can\nenable full replication for the table you are listening to:\n\n```sql\nalter table \"your_table\" replica identity full;\n```" - }, - { - "title": "Listen to presence join", - "code": "const channel = supabase.channel('room1')\nchannel\n .on('presence', { event: 'join' }, ({ newPresences }) => {\n console.log('Newly joined presences: ', newPresences)\n })\n .subscribe(async (status) => {\n if (status === 'SUBSCRIBED') {\n await channel.track({ online_at: new Date().toISOString() })\n }\n })", - "notes": "Listen to multiple events\nYou can chain listeners if you want to listen to multiple events for each table." - }, - { - "title": "Listen to presence leave", - "code": "const channel = supabase.channel('room1')\nchannel\n .on('presence', { event: 'leave' }, ({ leftPresences }) => {\n console.log('Newly left presences: ', leftPresences)\n })\n .subscribe(async (status) => {\n if (status === 'SUBSCRIBED') {\n await channel.track({ online_at: new Date().toISOString() })\n await channel.untrack()\n }\n })", - "notes": "Listen to row level changes\nYou can listen to individual rows using the format `{table}:{col}=eq.{val}` - where `{col}` is the column name, and `{val}` is the value which you want to match." - }, - { - "title": "Listen to all database changes", - "code": "supabase\n .channel('room1')\n .on('postgres_changes', { event: '*', schema: '*' }, payload => {\n console.log('Change received!', payload)\n })\n .subscribe()" - }, - { - "title": "Listen to a specific table", - "code": "supabase\n .channel('room1')\n .on('postgres_changes', { event: '*', schema: 'public', table: 'countries' }, payload => {\n console.log('Change received!', payload)\n })\n .subscribe()" - }, - { - "title": "Listen to inserts", - "code": "supabase\n .channel('room1')\n .on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'countries' }, payload => {\n console.log('Change received!', payload)\n })\n .subscribe()" - }, - { - "title": "Listen to updates", - "code": "supabase\n .channel('room1')\n .on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'countries' }, payload => {\n console.log('Change received!', payload)\n })\n .subscribe()", - "notes": "By default, Supabase will send only the updated record. If you want to receive the previous values as well you can\nenable full replication for the table you are listening to:\n\n```sql\nalter table \"your_table\" replica identity full;\n```" - }, - { - "title": "Listen to deletes", - "code": "supabase\n .channel('room1')\n .on('postgres_changes', { event: 'DELETE', schema: 'public', table: 'countries' }, payload => {\n console.log('Change received!', payload)\n })\n .subscribe()", - "notes": "By default, Supabase does not send deleted records. If you want to receive the deleted record you can\nenable full replication for the table you are listening to:\n\n```sql\nalter table \"your_table\" replica identity full;\n```" - }, - { - "title": "Listen to multiple events", - "code": "supabase\n .channel('room1')\n .on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'countries' }, handleRecordInserted)\n .on('postgres_changes', { event: 'DELETE', schema: 'public', table: 'countries' }, handleRecordDeleted)\n .subscribe()", - "notes": "You can chain listeners if you want to listen to multiple events for each table." - }, - { - "title": "Listen to row level changes", - "code": "supabase\n .channel('room1')\n .on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'countries', filter: 'id=eq.200' }, handleRecordUpdated)\n .subscribe()", - "notes": "You can listen to individual rows using the format `{table}:{col}=eq.{val}` - where `{col}` is the column name, and `{val}` is the value which you want to match." - } - ] - }, - { - "name": "presenceState", - "description": "Returns the current presence state for this channel.\nThe shape is a map keyed by presence key (for example a user id) where each entry contains the tracked metadata for that user.", - "parameters": [], - "returnType": { - "kind": "object", - "properties": [], - "name": "RealtimePresenceState" - } - }, - { - "name": "send", - "description": "Sends a message into the channel.", - "remarks": [ - "- When using REST you don't need to subscribe to the channel - REST calls are only available from 2.37.0 onwards" - ], - "parameters": [ - { - "name": "args", - "description": "Arguments to send to channel", - "type": { - "kind": "object", - "properties": [ - { - "name": "event", - "optional": false, - "description": "The name of the event being sent", - "type": "string" - }, - { - "name": "payload", - "optional": true, - "description": "Payload to be sent", - "type": "any" - }, - { - "name": "type", - "optional": false, - "description": "The type of event to send", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "broadcast" - }, - { - "kind": "literal", - "value": "presence" - }, - { - "kind": "literal", - "value": "postgres_changes" - } - ] - } - } - ] - } - }, - { - "name": "opts", - "description": "Options to be used during the send process", - "type": { - "kind": "object", - "properties": [] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - ] - }, - "examples": [ - { - "title": "Send a message via websocket", - "code": "const channel = supabase.channel('room1')\n\nchannel.subscribe((status) => {\n if (status === 'SUBSCRIBED') {\n channel.send({\n type: 'broadcast',\n event: 'cursor-pos',\n payload: { x: Math.random(), y: Math.random() },\n })\n }\n})", - "response": "ok | timed out | error" - }, - { - "title": "Send a message via REST", - "code": "supabase\n .channel('room1')\n .httpSend('cursor-pos', { x: Math.random(), y: Math.random() })" - } - ] - }, - { - "name": "subscribe", - "description": "Subscribe registers your client with the server", - "parameters": [ - { - "name": "callback", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "timeout", - "type": "number" - } - ], - "returnType": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "description": "The realtime channel to bind to.", - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "description": "Listen to realtime events on this channel.", - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "teardown", - "description": "Destroys and stops related timers.", - "parameters": [], - "returnType": "void" - }, - { - "name": "track", - "description": "Sends the supplied payload to the presence tracker so other subscribers can see that this client is online. Use `untrack` to stop broadcasting presence for the same key.", - "parameters": [ - { - "name": "payload", - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "opts", - "type": { - "kind": "object", - "properties": [] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - ] - } - }, - { - "name": "unsubscribe", - "description": "Leaves the channel.\nUnsubscribes from server events, and instructs channel to terminate on server. Triggers onClose() hooks.\nTo receive leave acknowledgements, use the a `receive` hook to bind to the server ack, ie: channel.unsubscribe().receive(\"ok\", () => alert(\"left!\") )", - "parameters": [ - { - "name": "timeout", - "type": "number" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - ] - } - }, - { - "name": "untrack", - "description": "Removes the current presence state for this client.", - "parameters": [ - { - "name": "opts", - "type": { - "kind": "object", - "properties": [] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - ] - } - }, - { - "name": "updateJoinPayload", - "description": "Updates the payload that will be sent the next time the channel joins (reconnects). Useful for rotating access tokens or updating config without re-creating the channel.", - "parameters": [ - { - "name": "payload", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "any" - ] - } - } - ], - "returnType": "void" - }, - { - "name": "channel", - "description": "Creates (or reuses) a RealtimeChannel for the provided topic.\nTopics are automatically prefixed with `realtime:` to match the Realtime service. If a channel with the same topic already exists it will be returned instead of creating a duplicate connection.", - "parameters": [ - { - "name": "topic", - "type": "string" - }, - { - "name": "params", - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - } - ], - "returnType": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "description": "The realtime channel to bind to.", - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "description": "Listen to realtime events on this channel.", - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "connect", - "description": "Connects the socket, unless already connected.", - "parameters": [], - "returnType": "void" - }, - { - "name": "connectionState", - "description": "Returns the current state of the socket.", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "ConnectionState" - } - }, - { - "name": "disconnect", - "description": "Disconnects the socket.", - "parameters": [ - { - "name": "code", - "optional": true, - "description": "A numeric status code to send on disconnect.", - "type": "number" - }, - { - "name": "reason", - "optional": true, - "description": "A custom reason for the disconnect.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timeout" - } - ] - } - ] - } - }, - { - "name": "endpointURL", - "description": "Returns the URL of the websocket.", - "parameters": [], - "returnType": "string" - }, - { - "name": "getChannels", - "description": "Returns all created channels", - "parameters": [], - "returnType": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "description": "The realtime channel to bind to.", - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "description": "Listen to realtime events on this channel.", - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - } - } - }, - { - "name": "isConnected", - "description": "Returns `true` is the connection is open.", - "parameters": [], - "returnType": "boolean" - }, - { - "name": "isConnecting", - "description": "Returns `true` if the connection is currently connecting.", - "parameters": [], - "returnType": "boolean" - }, - { - "name": "isDisconnecting", - "description": "Returns `true` if the connection is currently disconnecting.", - "parameters": [], - "returnType": "boolean" - }, - { - "name": "log", - "description": "Logs the message.\nFor customized logging, `this.logger` can be overridden in Client constructor.", - "parameters": [ - { - "name": "kind", - "type": "string" - }, - { - "name": "msg", - "type": "string" - }, - { - "name": "data", - "optional": true, - "type": "any" - } - ], - "returnType": "void" - }, - { - "name": "onHeartbeat", - "description": "Sets a callback that receives lifecycle events for internal heartbeat messages. Useful for instrumenting connection health (e.g. sent/ok/timeout/disconnected).", - "parameters": [ - { - "name": "callback", - "type": { - "kind": "reference", - "name": "HeartbeatCallback" - } - } - ], - "returnType": "void" - }, - { - "name": "push", - "description": "Push out a message if the socket is connected.\nIf the socket is not connected, the message gets enqueued within a local buffer, and sent out when a connection is next established.", - "parameters": [ - { - "name": "data", - "type": { - "kind": "object", - "properties": [ - { - "name": "event", - "optional": false, - "type": "string" - }, - { - "name": "join_ref", - "optional": true, - "type": "string" - }, - { - "name": "payload", - "optional": false, - "type": "any" - }, - { - "name": "ref", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "type": "string" - } - ], - "name": "RealtimeMessage" - } - } - ], - "returnType": "void" - }, - { - "name": "removeAllChannels", - "description": "Unsubscribes, removes and tears down all channels", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - } - ] - } - }, - { - "name": "removeChannel", - "description": "Unsubscribes, removes and tears down a single channel", - "parameters": [ - { - "name": "channel", - "description": "A RealtimeChannel instance", - "type": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "description": "The realtime channel to bind to.", - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "description": "Listen to realtime events on this channel.", - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - ] - } - }, - { - "name": "sendHeartbeat", - "description": "Sends a heartbeat message if the socket is connected.", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - "void" - ] - } - }, - { - "name": "setAuth", - "description": "Sets the JWT access token used for channel subscription authorization and Realtime RLS.\nIf param is null it will use the `accessToken` callback function or the token set on the client.\nOn callback used, it will set the value of the token internal to the client.\nWhen a token is explicitly provided, it will be preserved across channel operations (including removeChannel and resubscribe). The `accessToken` callback will not be invoked until `setAuth()` is called without arguments.", - "parameters": [ - { - "name": "token", - "description": "A JWT string to override the token set on the client.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - "void" - ] - }, - "examples": [ - { - "title": "Example 1", - "code": "Setting the authorization header\n// Use a manual token (preserved across resubscribes, ignores accessToken callback)\nclient.realtime.setAuth('my-custom-jwt')\n\n// Switch back to using the accessToken callback\nclient.realtime.setAuth()" - } - ] - }, - { - "name": "getWebSocketConstructor", - "description": "Returns the best available WebSocket constructor for the current runtime.", - "parameters": [], - "returnType": { - "kind": "object", - "properties": [] - }, - "examples": [ - { - "title": "Example with error handling", - "code": "try {\n const WS = WebSocketFactory.getWebSocketConstructor()\n const socket = new WS('wss://example.com/socket')\n} catch (error) {\n console.error('WebSocket not available in this environment.', error)\n}" - } - ] - }, - { - "name": "isWebSocketSupported", - "description": "Detects whether the runtime can establish WebSocket connections.", - "parameters": [], - "returnType": "boolean", - "examples": [ - { - "title": "Example in a Node.js script", - "code": "if (!WebSocketFactory.isWebSocketSupported()) {\n console.error('WebSockets are required for this script.')\n process.exitCode = 1\n}" - } - ] - }, - { - "name": "httpSend", - "description": "Sends a broadcast message explicitly via REST API.\nThis method always uses the REST API endpoint regardless of WebSocket connection state. Useful when you want to guarantee REST delivery or when gradually migrating from implicit REST fallback.", - "parameters": [ - { - "name": "event", - "description": "The name of the broadcast event", - "type": "string" - }, - { - "name": "payload", - "description": "Payload to be sent (required)", - "type": "any" - }, - { - "name": "opts", - "optional": true, - "description": "Options including timeout", - "type": { - "kind": "object", - "properties": [ - { - "name": "timeout", - "optional": true, - "type": "number" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "success", - "optional": false, - "type": { - "kind": "literal", - "value": true - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "error", - "optional": false, - "type": "string" - }, - { - "name": "status", - "optional": false, - "type": "number" - }, - { - "name": "success", - "optional": false, - "type": { - "kind": "literal", - "value": false - } - } - ] - } - ] - } - ] - } - }, - { - "name": "presenceState", - "description": "Returns the current presence state for this channel.\nThe shape is a map keyed by presence key (for example a user id) where each entry contains the tracked metadata for that user.", - "parameters": [], - "returnType": { - "kind": "object", - "properties": [], - "name": "RealtimePresenceState" - } - }, - { - "name": "send", - "description": "Sends a message into the channel.", - "remarks": [ - "- When using REST you don't need to subscribe to the channel - REST calls are only available from 2.37.0 onwards" - ], - "parameters": [ - { - "name": "args", - "description": "Arguments to send to channel", - "type": { - "kind": "object", - "properties": [ - { - "name": "event", - "optional": false, - "description": "The name of the event being sent", - "type": "string" - }, - { - "name": "payload", - "optional": true, - "description": "Payload to be sent", - "type": "any" - }, - { - "name": "type", - "optional": false, - "description": "The type of event to send", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "broadcast" - }, - { - "kind": "literal", - "value": "presence" - }, - { - "kind": "literal", - "value": "postgres_changes" - } - ] - } - } - ] - } - }, - { - "name": "opts", - "optional": true, - "description": "Options to be used during the send process", - "type": { - "kind": "object", - "properties": [] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - ] - }, - "examples": [ - { - "title": "Send a message via websocket", - "code": "const channel = supabase.channel('room1')\n\nchannel.subscribe((status) => {\n if (status === 'SUBSCRIBED') {\n channel.send({\n type: 'broadcast',\n event: 'cursor-pos',\n payload: { x: Math.random(), y: Math.random() },\n })\n }\n})", - "response": "ok | timed out | error" - }, - { - "title": "Send a message via REST", - "code": "supabase\n .channel('room1')\n .httpSend('cursor-pos', { x: Math.random(), y: Math.random() })" - } - ] - }, - { - "name": "subscribe", - "description": "Subscribe registers your client with the server", - "parameters": [ - { - "name": "callback", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "timeout", - "optional": true, - "type": "number" - } - ], - "returnType": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "teardown", - "description": "Destroys and stops related timers.", - "parameters": [], - "returnType": "void" - }, - { - "name": "track", - "description": "Sends the supplied payload to the presence tracker so other subscribers can see that this client is online. Use `untrack` to stop broadcasting presence for the same key.", - "parameters": [ - { - "name": "payload", - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "opts", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - ] - } - }, - { - "name": "unsubscribe", - "description": "Leaves the channel.\nUnsubscribes from server events, and instructs channel to terminate on server. Triggers onClose() hooks.\nTo receive leave acknowledgements, use the a `receive` hook to bind to the server ack, ie: channel.unsubscribe().receive(\"ok\", () => alert(\"left!\") )", - "parameters": [ - { - "name": "timeout", - "optional": true, - "type": "number" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - ] - } - }, - { - "name": "untrack", - "description": "Removes the current presence state for this client.", - "parameters": [ - { - "name": "opts", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - ] - } - }, - { - "name": "updateJoinPayload", - "description": "Updates the payload that will be sent the next time the channel joins (reconnects). Useful for rotating access tokens or updating config without re-creating the channel.", - "parameters": [ - { - "name": "payload", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "any" - ] - } - } - ], - "returnType": "void" - }, - { - "name": "channel", - "description": "Creates (or reuses) a RealtimeChannel for the provided topic.\nTopics are automatically prefixed with `realtime:` to match the Realtime service. If a channel with the same topic already exists it will be returned instead of creating a duplicate connection.", - "parameters": [ - { - "name": "topic", - "type": "string" - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - } - ], - "returnType": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "connect", - "description": "Connects the socket, unless already connected.", - "parameters": [], - "returnType": "void" - }, - { - "name": "connectionState", - "description": "Returns the current state of the socket.", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "ConnectionState" - } - }, - { - "name": "disconnect", - "description": "Disconnects the socket.", - "parameters": [ - { - "name": "code", - "optional": true, - "description": "A numeric status code to send on disconnect.", - "type": "number" - }, - { - "name": "reason", - "optional": true, - "description": "A custom reason for the disconnect.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "timeout" - }, - { - "kind": "literal", - "value": "ok" - } - ] - } - ] - } - }, - { - "name": "endpointURL", - "description": "Returns the URL of the websocket.", - "parameters": [], - "returnType": "string" - }, - { - "name": "getChannels", - "description": "Returns all created channels", - "parameters": [], - "returnType": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - } - } - }, - { - "name": "isConnected", - "description": "Returns `true` is the connection is open.", - "parameters": [], - "returnType": "boolean" - }, - { - "name": "isConnecting", - "description": "Returns `true` if the connection is currently connecting.", - "parameters": [], - "returnType": "boolean" - }, - { - "name": "isDisconnecting", - "description": "Returns `true` if the connection is currently disconnecting.", - "parameters": [], - "returnType": "boolean" - }, - { - "name": "log", - "description": "Logs the message.\nFor customized logging, `this.logger` can be overridden in Client constructor.", - "parameters": [ - { - "name": "kind", - "type": "string" - }, - { - "name": "msg", - "type": "string" - }, - { - "name": "data", - "optional": true, - "type": "any" - } - ], - "returnType": "void" - }, - { - "name": "onHeartbeat", - "description": "Sets a callback that receives lifecycle events for internal heartbeat messages. Useful for instrumenting connection health (e.g. sent/ok/timeout/disconnected).", - "parameters": [ - { - "name": "callback", - "type": { - "kind": "reference", - "name": "HeartbeatCallback" - } - } - ], - "returnType": "void" - }, - { - "name": "push", - "description": "Push out a message if the socket is connected.\nIf the socket is not connected, the message gets enqueued within a local buffer, and sent out when a connection is next established.", - "parameters": [ - { - "name": "data", - "type": { - "kind": "object", - "properties": [ - { - "name": "event", - "optional": false, - "type": "string" - }, - { - "name": "join_ref", - "optional": true, - "type": "string" - }, - { - "name": "payload", - "optional": false, - "type": "any" - }, - { - "name": "ref", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "type": "string" - } - ], - "name": "RealtimeMessage" - } - } - ], - "returnType": "void" - }, - { - "name": "removeAllChannels", - "description": "Unsubscribes, removes and tears down all channels", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - } - ] - } - }, - { - "name": "removeChannel", - "description": "Unsubscribes, removes and tears down a single channel", - "parameters": [ - { - "name": "channel", - "description": "A RealtimeChannel instance", - "type": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - }, - { - "kind": "literal", - "value": "error" - } - ] - } - ] - } - }, - { - "name": "sendHeartbeat", - "description": "Sends a heartbeat message if the socket is connected.", - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - "void" - ] - } - }, - { - "name": "setAuth", - "description": "Sets the JWT access token used for channel subscription authorization and Realtime RLS.\nIf param is null it will use the `accessToken` callback function or the token set on the client.\nOn callback used, it will set the value of the token internal to the client.\nWhen a token is explicitly provided, it will be preserved across channel operations (including removeChannel and resubscribe). The `accessToken` callback will not be invoked until `setAuth()` is called without arguments.", - "parameters": [ - { - "name": "token", - "optional": true, - "description": "A JWT string to override the token set on the client.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - "void" - ] - }, - "examples": [ - { - "title": "Example 1", - "code": "Setting the authorization header\n// Use a manual token (preserved across resubscribes, ignores accessToken callback)\nclient.realtime.setAuth('my-custom-jwt')\n\n// Switch back to using the accessToken callback\nclient.realtime.setAuth()" - } - ] - }, - { - "name": "getWebSocketConstructor", - "description": "Returns the best available WebSocket constructor for the current runtime.", - "parameters": [], - "returnType": { - "kind": "object", - "properties": [] - }, - "examples": [ - { - "title": "Example with error handling", - "code": "try {\n const WS = WebSocketFactory.getWebSocketConstructor()\n const socket = new WS('wss://example.com/socket')\n} catch (error) {\n console.error('WebSocket not available in this environment.', error)\n}" - } - ] - }, - { - "name": "isWebSocketSupported", - "description": "Detects whether the runtime can establish WebSocket connections.", - "parameters": [], - "returnType": "boolean", - "examples": [ - { - "title": "Example in a Node.js script", - "code": "if (!WebSocketFactory.isWebSocketSupported()) {\n console.error('WebSockets are required for this script.')\n process.exitCode = 1\n}" - } - ] - } - ] - }, - { - "category": "File Buckets", - "definitions": [ - { - "name": "createBucket", - "description": "Creates a new Storage bucket", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `insert` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "id", - "description": "A unique identifier for the bucket you are creating.", - "type": "string" - }, - { - "name": "options", - "type": { - "kind": "object", - "properties": [ - { - "name": "allowedMimeTypes", - "optional": true, - "description": "specifies the allowed mime types that this bucket can accept during upload. The default value is null, which allows files with all mime types to be uploaded. Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "array", - "elementType": "string" - } - ] - } - }, - { - "name": "fileSizeLimit", - "optional": true, - "description": "specifies the max file size in bytes that can be uploaded to this bucket. The global file size limit takes precedence over this value. The default value is null, which doesn't set a per bucket file size limit.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string", - "number" - ] - } - }, - { - "name": "public", - "optional": false, - "description": "The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations. By default, buckets are private.", - "type": "boolean" - }, - { - "name": "type", - "optional": true, - "description": "(private-beta) specifies the bucket type. see `BucketType` for more details. - default bucket type is `STANDARD`", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "STANDARD" - }, - { - "kind": "literal", - "value": "ANALYTICS" - } - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "reference", - "name": "Pick", - "typeArguments": [ - { - "kind": "object", - "name": "Bucket", - "properties": [ - { - "name": "allowed_mime_types", - "optional": true, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "file_size_limit", - "optional": true, - "type": "number" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "name", - "optional": false, - "type": "string" - }, - { - "name": "owner", - "optional": false, - "type": "string" - }, - { - "name": "public", - "optional": false, - "type": "boolean" - }, - { - "name": "type", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "STANDARD" - }, - { - "kind": "literal", - "value": "ANALYTICS" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ] - }, - { - "kind": "literal", - "value": "name" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create bucket", - "code": "const { data, error } = await supabase\n .storage\n .createBucket('avatars', {\n public: false,\n allowedMimeTypes: ['image/png'],\n fileSizeLimit: 1024\n })" - } - ] - }, - { - "name": "deleteBucket", - "description": "Deletes an existing bucket. A bucket can't be deleted with existing objects inside it. You must first `empty()` the bucket.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `select` and `delete` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "id", - "description": "The unique identifier of the bucket you would like to delete.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "message", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Delete bucket", - "code": "const { data, error } = await supabase\n .storage\n .deleteBucket('avatars')" - } - ] - }, - { - "name": "emptyBucket", - "description": "Removes all objects inside a single bucket.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `select` - `objects` table permissions: `select` and `delete` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "id", - "description": "The unique identifier of the bucket you would like to empty.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "message", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Empty bucket", - "code": "const { data, error } = await supabase\n .storage\n .emptyBucket('avatars')" - } - ] - }, - { - "name": "from", - "description": "Perform file operation in a bucket.", - "parameters": [ - { - "name": "id", - "description": "The bucket id to operate on.", - "type": "string" - } - ], - "returnType": { - "kind": "object", - "name": "default", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "copy", - "optional": false, - "type": null - }, - { - "name": "createSignedUploadUrl", - "optional": false, - "type": null - }, - { - "name": "createSignedUrl", - "optional": false, - "type": null - }, - { - "name": "createSignedUrls", - "optional": false, - "type": null - }, - { - "name": "download", - "optional": false, - "type": null - }, - { - "name": "exists", - "optional": false, - "type": null - }, - { - "name": "getPublicUrl", - "optional": false, - "type": null - }, - { - "name": "info", - "optional": false, - "type": null - }, - { - "name": "list", - "optional": false, - "type": null - }, - { - "name": "listV2", - "optional": false, - "type": null - }, - { - "name": "move", - "optional": false, - "type": null - }, - { - "name": "remove", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - }, - { - "name": "toBase64", - "optional": false, - "type": null - }, - { - "name": "update", - "optional": false, - "type": null - }, - { - "name": "upload", - "optional": false, - "type": null - }, - { - "name": "uploadToSignedUrl", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Accessing a bucket", - "code": "const avatars = supabase.storage.from('avatars')" - } - ] - }, - { - "name": "getBucket", - "description": "Retrieves the details of an existing Storage bucket.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `select` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "id", - "description": "The unique identifier of the bucket you would like to retrieve.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "name": "Bucket", - "properties": [ - { - "name": "allowed_mime_types", - "optional": true, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "file_size_limit", - "optional": true, - "type": "number" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "name", - "optional": false, - "type": "string" - }, - { - "name": "owner", - "optional": false, - "type": "string" - }, - { - "name": "public", - "optional": false, - "type": "boolean" - }, - { - "name": "type", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "STANDARD" - }, - { - "kind": "literal", - "value": "ANALYTICS" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get bucket", - "code": "const { data, error } = await supabase\n .storage\n .getBucket('avatars')" - } - ] - }, - { - "name": "listBuckets", - "description": "Retrieves the details of all Storage buckets within an existing project.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `select` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "options", - "optional": true, - "description": "Query parameters for listing buckets", - "type": { - "kind": "object", - "name": "ListBucketOptions", - "properties": [ - { - "name": "limit", - "optional": true, - "type": "number" - }, - { - "name": "offset", - "optional": true, - "type": "number" - }, - { - "name": "search", - "optional": true, - "type": "string" - }, - { - "name": "sortColumn", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "id" - }, - { - "kind": "literal", - "value": "name" - }, - { - "kind": "literal", - "value": "created_at" - }, - { - "kind": "literal", - "value": "updated_at" - } - ] - } - }, - { - "name": "sortOrder", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "asc" - }, - { - "kind": "literal", - "value": "desc" - } - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "Bucket", - "properties": [ - { - "name": "allowed_mime_types", - "optional": true, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "file_size_limit", - "optional": true, - "type": "number" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "name", - "optional": false, - "type": "string" - }, - { - "name": "owner", - "optional": false, - "type": "string" - }, - { - "name": "public", - "optional": false, - "type": "boolean" - }, - { - "name": "type", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "STANDARD" - }, - { - "kind": "literal", - "value": "ANALYTICS" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "List buckets", - "code": "const { data, error } = await supabase\n .storage\n .listBuckets()" - }, - { - "title": "List buckets with options", - "code": "const { data, error } = await supabase\n .storage\n .listBuckets({\n limit: 10,\n offset: 0,\n sortColumn: 'created_at',\n sortOrder: 'desc',\n search: 'prod'\n })" - } - ] - }, - { - "name": "updateBucket", - "description": "Updates a Storage bucket", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `select` and `update` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "id", - "description": "A unique identifier for the bucket you are updating.", - "type": "string" - }, - { - "name": "options", - "type": { - "kind": "object", - "properties": [ - { - "name": "allowedMimeTypes", - "optional": true, - "description": "specifies the allowed mime types that this bucket can accept during upload. The default value is null, which allows files with all mime types to be uploaded. Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "array", - "elementType": "string" - } - ] - } - }, - { - "name": "fileSizeLimit", - "optional": true, - "description": "specifies the max file size in bytes that can be uploaded to this bucket. The global file size limit takes precedence over this value. The default value is null, which doesn't set a per bucket file size limit.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string", - "number" - ] - } - }, - { - "name": "public", - "optional": false, - "description": "The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations.", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "message", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Update bucket", - "code": "const { data, error } = await supabase\n .storage\n .updateBucket('avatars', {\n public: false,\n allowedMimeTypes: ['image/png'],\n fileSizeLimit: 1024\n })" - } - ] - }, - { - "name": "createBucket", - "description": "Creates a new Storage bucket", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `insert` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "id", - "description": "A unique identifier for the bucket you are creating.", - "type": "string" - }, - { - "name": "options", - "type": { - "kind": "object", - "properties": [ - { - "name": "allowedMimeTypes", - "optional": true, - "description": "specifies the allowed mime types that this bucket can accept during upload. The default value is null, which allows files with all mime types to be uploaded. Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "array", - "elementType": "string" - } - ] - } - }, - { - "name": "fileSizeLimit", - "optional": true, - "description": "specifies the max file size in bytes that can be uploaded to this bucket. The global file size limit takes precedence over this value. The default value is null, which doesn't set a per bucket file size limit.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string", - "number" - ] - } - }, - { - "name": "public", - "optional": false, - "description": "The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations. By default, buckets are private.", - "type": "boolean" - }, - { - "name": "type", - "optional": true, - "description": "(private-beta) specifies the bucket type. see `BucketType` for more details. - default bucket type is `STANDARD`", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "STANDARD" - }, - { - "kind": "literal", - "value": "ANALYTICS" - } - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "reference", - "name": "Pick", - "typeArguments": [ - { - "kind": "object", - "name": "Bucket", - "properties": [ - { - "name": "allowed_mime_types", - "optional": true, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "file_size_limit", - "optional": true, - "type": "number" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "name", - "optional": false, - "type": "string" - }, - { - "name": "owner", - "optional": false, - "type": "string" - }, - { - "name": "public", - "optional": false, - "type": "boolean" - }, - { - "name": "type", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "STANDARD" - }, - { - "kind": "literal", - "value": "ANALYTICS" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ] - }, - { - "kind": "literal", - "value": "name" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create bucket", - "code": "const { data, error } = await supabase\n .storage\n .createBucket('avatars', {\n public: false,\n allowedMimeTypes: ['image/png'],\n fileSizeLimit: 1024\n })" - } - ] - }, - { - "name": "deleteBucket", - "description": "Deletes an existing bucket. A bucket can't be deleted with existing objects inside it. You must first `empty()` the bucket.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `select` and `delete` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "id", - "description": "The unique identifier of the bucket you would like to delete.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "message", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Delete bucket", - "code": "const { data, error } = await supabase\n .storage\n .deleteBucket('avatars')" - } - ] - }, - { - "name": "emptyBucket", - "description": "Removes all objects inside a single bucket.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `select` - `objects` table permissions: `select` and `delete` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "id", - "description": "The unique identifier of the bucket you would like to empty.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "message", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Empty bucket", - "code": "const { data, error } = await supabase\n .storage\n .emptyBucket('avatars')" - } - ] - }, - { - "name": "getBucket", - "description": "Retrieves the details of an existing Storage bucket.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `select` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "id", - "description": "The unique identifier of the bucket you would like to retrieve.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "name": "Bucket", - "properties": [ - { - "name": "allowed_mime_types", - "optional": true, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "file_size_limit", - "optional": true, - "type": "number" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "name", - "optional": false, - "type": "string" - }, - { - "name": "owner", - "optional": false, - "type": "string" - }, - { - "name": "public", - "optional": false, - "type": "boolean" - }, - { - "name": "type", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "STANDARD" - }, - { - "kind": "literal", - "value": "ANALYTICS" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get bucket", - "code": "const { data, error } = await supabase\n .storage\n .getBucket('avatars')" - } - ] - }, - { - "name": "listBuckets", - "description": "Retrieves the details of all Storage buckets within an existing project.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `select` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "options", - "optional": true, - "description": "Query parameters for listing buckets", - "type": { - "kind": "object", - "name": "ListBucketOptions", - "properties": [ - { - "name": "limit", - "optional": true, - "type": "number" - }, - { - "name": "offset", - "optional": true, - "type": "number" - }, - { - "name": "search", - "optional": true, - "type": "string" - }, - { - "name": "sortColumn", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "id" - }, - { - "kind": "literal", - "value": "name" - }, - { - "kind": "literal", - "value": "created_at" - }, - { - "kind": "literal", - "value": "updated_at" - } - ] - } - }, - { - "name": "sortOrder", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "asc" - }, - { - "kind": "literal", - "value": "desc" - } - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "Bucket", - "properties": [ - { - "name": "allowed_mime_types", - "optional": true, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "file_size_limit", - "optional": true, - "type": "number" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "name", - "optional": false, - "type": "string" - }, - { - "name": "owner", - "optional": false, - "type": "string" - }, - { - "name": "public", - "optional": false, - "type": "boolean" - }, - { - "name": "type", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "STANDARD" - }, - { - "kind": "literal", - "value": "ANALYTICS" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "List buckets", - "code": "const { data, error } = await supabase\n .storage\n .listBuckets()" - }, - { - "title": "List buckets with options", - "code": "const { data, error } = await supabase\n .storage\n .listBuckets({\n limit: 10,\n offset: 0,\n sortColumn: 'created_at',\n sortOrder: 'desc',\n search: 'prod'\n })" - } - ] - }, - { - "name": "updateBucket", - "description": "Updates a Storage bucket", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: `select` and `update` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "id", - "description": "A unique identifier for the bucket you are updating.", - "type": "string" - }, - { - "name": "options", - "type": { - "kind": "object", - "properties": [ - { - "name": "allowedMimeTypes", - "optional": true, - "description": "specifies the allowed mime types that this bucket can accept during upload. The default value is null, which allows files with all mime types to be uploaded. Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "array", - "elementType": "string" - } - ] - } - }, - { - "name": "fileSizeLimit", - "optional": true, - "description": "specifies the max file size in bytes that can be uploaded to this bucket. The global file size limit takes precedence over this value. The default value is null, which doesn't set a per bucket file size limit.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string", - "number" - ] - } - }, - { - "name": "public", - "optional": false, - "description": "The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations.", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "message", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Update bucket", - "code": "const { data, error } = await supabase\n .storage\n .updateBucket('avatars', {\n public: false,\n allowedMimeTypes: ['image/png'],\n fileSizeLimit: 1024\n })" - } - ] - }, - { - "name": "copy", - "description": "Copies an existing file to a new path in the same bucket.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: `insert` and `select` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "fromPath", - "description": "The original file path, including the current file name. For example `folder/image.png`.", - "type": "string" - }, - { - "name": "toPath", - "description": "The new file path, including the new file name. For example `folder/image-copy.png`.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "description": "The destination options.", - "type": { - "kind": "object", - "name": "DestinationOptions", - "properties": [ - { - "name": "destinationBucket", - "optional": true, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "path", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Copy file", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .copy('public/avatar1.png', 'private/avatar2.png')" - } - ] - }, - { - "name": "createSignedUploadUrl", - "description": "Creates a signed upload URL. Signed upload URLs can be used to upload files to the bucket without further authentication. They are valid for 2 hours.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: `insert` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "path", - "description": "The file path, including the current file name. For example `folder/image.png`.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "upsert", - "optional": false, - "description": "If set to true, allows the file to be overwritten if it already exists.", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "path", - "optional": false, - "type": "string" - }, - { - "name": "signedUrl", - "optional": false, - "type": "string" - }, - { - "name": "token", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create Signed Upload URL", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .createSignedUploadUrl('folder/cat.jpg')" - } - ] - }, - { - "name": "createSignedUrl", - "description": "Creates a signed URL. Use a signed URL to share a file for a fixed amount of time.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: `select` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "path", - "description": "The file path, including the current file name. For example `folder/image.png`.", - "type": "string" - }, - { - "name": "expiresIn", - "description": "The number of seconds until the signed URL expires. For example, `60` for a URL which is valid for one minute.", - "type": "number" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "download", - "optional": true, - "description": "triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.", - "type": { - "kind": "union", - "types": [ - "string", - "boolean" - ] - } - }, - { - "name": "transform", - "optional": true, - "description": "Transform the asset before serving it to the client.", - "type": { - "kind": "object", - "name": "TransformOptions", - "properties": [ - { - "name": "format", - "optional": true, - "description": "Specify the format of the image requested.\nWhen using 'origin' we force the format to be the same as the original image. When this option is not passed in, images are optimized to modern image formats like Webp.", - "type": { - "kind": "literal", - "value": "origin" - } - }, - { - "name": "height", - "optional": true, - "description": "The height of the image in pixels.", - "type": "number" - }, - { - "name": "quality", - "optional": true, - "description": "Set the quality of the returned image. A number from 20 to 100, with 100 being the highest quality. Defaults to 80", - "type": "number" - }, - { - "name": "resize", - "optional": true, - "description": "The resize mode can be cover, contain or fill. Defaults to cover. Cover resizes the image to maintain it's aspect ratio while filling the entire width and height. Contain resizes the image to maintain it's aspect ratio while fitting the entire image within the width and height. Fill resizes the image to fill the entire width and height. If the object's aspect ratio does not match the width and height, the image will be stretched to fit.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "cover" - }, - { - "kind": "literal", - "value": "contain" - }, - { - "kind": "literal", - "value": "fill" - } - ] - } - }, - { - "name": "width", - "optional": true, - "description": "The width of the image in pixels.", - "type": "number" - } - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "signedUrl", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create Signed URL", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .createSignedUrl('folder/avatar1.png', 60)" - }, - { - "title": "Create a signed URL for an asset with transformations", - "code": "const { data } = await supabase\n .storage\n .from('avatars')\n .createSignedUrl('folder/avatar1.png', 60, {\n transform: {\n width: 100,\n height: 100,\n }\n })" - }, - { - "title": "Create a signed URL which triggers the download of the asset", - "code": "const { data } = await supabase\n .storage\n .from('avatars')\n .createSignedUrl('folder/avatar1.png', 60, {\n download: true,\n })" - } - ] - }, - { - "name": "createSignedUrls", - "description": "Creates multiple signed URLs. Use a signed URL to share a file for a fixed amount of time.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: `select` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "paths", - "description": "The file paths to be downloaded, including the current file names. For example `['folder/image.png', 'folder2/image2.png']`.", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "expiresIn", - "description": "The number of seconds until the signed URLs expire. For example, `60` for URLs which are valid for one minute.", - "type": "number" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "download", - "optional": false, - "description": "triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.", - "type": { - "kind": "union", - "types": [ - "string", - "boolean" - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "properties": [ - { - "name": "error", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "path", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "signedUrl", - "optional": false, - "type": "string" - } - ] - } - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create Signed URLs", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .createSignedUrls(['folder/avatar1.png', 'folder/avatar2.png'], 60)" - } - ] - }, - { - "name": "download", - "description": "Downloads a file from a private bucket. For public buckets, make a request to the URL returned from `getPublicUrl` instead.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: `select` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "path", - "description": "The full path and file name of the file to be downloaded. For example `folder/image.png`.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "typeParam", - "name": "Options" - } - }, - { - "name": "parameters", - "optional": true, - "description": "Additional fetch parameters like signal for cancellation. Supports standard fetch options including cache control.", - "type": { - "kind": "object", - "name": "FetchParameters", - "properties": [ - { - "name": "cache", - "optional": true, - "description": "Controls how the request interacts with the browser's HTTP cache. - 'default': Use standard cache behavior - 'no-store': Bypass cache entirely (useful in Edge Functions) - 'reload': Bypass cache but update it with response - 'no-cache': Validate with server before using cached response - 'force-cache': Use cache even if stale - 'only-if-cached': Only use cache, fail if not cached", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "default" - }, - { - "kind": "literal", - "value": "no-store" - }, - { - "kind": "literal", - "value": "reload" - }, - { - "kind": "literal", - "value": "no-cache" - }, - { - "kind": "literal", - "value": "force-cache" - }, - { - "kind": "literal", - "value": "only-if-cached" - } - ] - } - }, - { - "name": "signal", - "optional": true, - "description": "Pass in an AbortController's signal to cancel the request.", - "type": { - "kind": "reference", - "name": "AbortSignal" - } - } - ] - } - } - ], - "returnType": { - "kind": "object", - "name": "default", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "[toStringTag]", - "optional": false, - "type": "string" - }, - { - "name": "asStream", - "optional": false, - "type": null - }, - { - "name": "catch", - "optional": false, - "type": null - }, - { - "name": "finally", - "optional": false, - "type": null - }, - { - "name": "then", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Download file", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .download('folder/avatar1.png')" - }, - { - "title": "Download file with transformations", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .download('folder/avatar1.png', {\n transform: {\n width: 100,\n height: 100,\n quality: 80\n }\n })" - }, - { - "title": "Download with cache control (useful in Edge Functions)", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .download('folder/avatar1.png', {}, { cache: 'no-store' })" - }, - { - "title": "Download with abort signal", - "code": "const controller = new AbortController()\nsetTimeout(() => controller.abort(), 5000)\n\nconst { data, error } = await supabase\n .storage\n .from('avatars')\n .download('folder/avatar1.png', {}, { signal: controller.signal })" - } - ] - }, - { - "name": "exists", - "description": "Checks the existence of a file.", - "parameters": [ - { - "name": "path", - "description": "The file path, including the file name. For example `folder/image.png`.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": "boolean" - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": "boolean" - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Check file existence", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .exists('folder/avatar1.png')" - } - ] - }, - { - "name": "getPublicUrl", - "description": "A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset. This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.", - "remarks": [ - "- The bucket needs to be set to public, either via [updateBucket()](/docs/reference/javascript/storage-updatebucket) or by going to Storage on [supabase.com/dashboard](https://supabase.com/dashboard), clicking the overflow menu on a bucket and choosing \"Make public\" - RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "path", - "description": "The path and name of the file to generate the public URL for. For example `folder/image.png`.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "type": { - "kind": "object", - "properties": [ - { - "name": "download", - "optional": true, - "description": "Triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.", - "type": { - "kind": "union", - "types": [ - "string", - "boolean" - ] - } - }, - { - "name": "transform", - "optional": true, - "description": "Transform the asset before serving it to the client.", - "type": { - "kind": "object", - "name": "TransformOptions", - "properties": [ - { - "name": "format", - "optional": true, - "description": "Specify the format of the image requested.\nWhen using 'origin' we force the format to be the same as the original image. When this option is not passed in, images are optimized to modern image formats like Webp.", - "type": { - "kind": "literal", - "value": "origin" - } - }, - { - "name": "height", - "optional": true, - "description": "The height of the image in pixels.", - "type": "number" - }, - { - "name": "quality", - "optional": true, - "description": "Set the quality of the returned image. A number from 20 to 100, with 100 being the highest quality. Defaults to 80", - "type": "number" - }, - { - "name": "resize", - "optional": true, - "description": "The resize mode can be cover, contain or fill. Defaults to cover. Cover resizes the image to maintain it's aspect ratio while filling the entire width and height. Contain resizes the image to maintain it's aspect ratio while fitting the entire image within the width and height. Fill resizes the image to fill the entire width and height. If the object's aspect ratio does not match the width and height, the image will be stretched to fit.", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "cover" - }, - { - "kind": "literal", - "value": "contain" - }, - { - "kind": "literal", - "value": "fill" - } - ] - } - }, - { - "name": "width", - "optional": true, - "description": "The width of the image in pixels.", - "type": "number" - } - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "publicUrl", - "optional": false, - "type": "string" - } - ] - } - } - ] - }, - "examples": [ - { - "title": "Returns the URL for an asset in a public bucket", - "code": "const { data } = supabase\n .storage\n .from('public-bucket')\n .getPublicUrl('folder/avatar1.png')" - }, - { - "title": "Returns the URL for an asset in a public bucket with transformations", - "code": "const { data } = supabase\n .storage\n .from('public-bucket')\n .getPublicUrl('folder/avatar1.png', {\n transform: {\n width: 100,\n height: 100,\n }\n })" - }, - { - "title": "Returns the URL which triggers the download of an asset in a public bucket", - "code": "const { data } = supabase\n .storage\n .from('public-bucket')\n .getPublicUrl('folder/avatar1.png', {\n download: true,\n })" - } - ] - }, - { - "name": "info", - "description": "Retrieves the details of an existing file.\nReturns detailed file metadata including size, content type, and timestamps. Note: The API returns `last_modified` field, not `updated_at`.", - "parameters": [ - { - "name": "path", - "description": "The file path, including the file name. For example `folder/image.png`.", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "mapped" - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get file info", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .info('folder/avatar1.png')\n\nif (data) {\n console.log('Last modified:', data.lastModified)\n console.log('Size:', data.size)\n}" - } - ] - }, - { - "name": "list", - "description": "Lists all the files and folders within a path of the bucket.\n**Important:** For folder entries, fields like `id`, `updated_at`, `created_at`, `last_accessed_at`, and `metadata` will be `null`. Only files have these fields populated. Additionally, deprecated fields like `bucket_id`, `owner`, and `buckets` are NOT returned by this method.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: `select` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "path", - "optional": true, - "description": "The folder path.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "description": "Search options including limit (defaults to 100), offset, sortBy, and search", - "type": { - "kind": "object", - "name": "SearchOptions", - "properties": [ - { - "name": "limit", - "optional": true, - "description": "The number of files you want to be returned.", - "type": "number" - }, - { - "name": "offset", - "optional": true, - "description": "The starting position.", - "type": "number" - }, - { - "name": "search", - "optional": true, - "description": "The search string to filter files by.", - "type": "string" - }, - { - "name": "sortBy", - "optional": true, - "description": "The column to sort by. Can be any column inside a FileObject.", - "type": { - "kind": "object", - "name": "SortBy", - "properties": [ - { - "name": "column", - "optional": true, - "type": "string" - }, - { - "name": "order", - "optional": true, - "type": "string" - } - ] - } - } - ] - } - }, - { - "name": "parameters", - "optional": true, - "description": "Optional fetch parameters including signal for cancellation", - "type": { - "kind": "object", - "name": "FetchParameters", - "properties": [ - { - "name": "cache", - "optional": true, - "description": "Controls how the request interacts with the browser's HTTP cache. - 'default': Use standard cache behavior - 'no-store': Bypass cache entirely (useful in Edge Functions) - 'reload': Bypass cache but update it with response - 'no-cache': Validate with server before using cached response - 'force-cache': Use cache even if stale - 'only-if-cached': Only use cache, fail if not cached", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "default" - }, - { - "kind": "literal", - "value": "no-store" - }, - { - "kind": "literal", - "value": "reload" - }, - { - "kind": "literal", - "value": "no-cache" - }, - { - "kind": "literal", - "value": "force-cache" - }, - { - "kind": "literal", - "value": "only-if-cached" - } - ] - } - }, - { - "name": "signal", - "optional": true, - "description": "Pass in an AbortController's signal to cancel the request.", - "type": { - "kind": "reference", - "name": "AbortSignal" - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "FileObject", - "properties": [ - { - "name": "bucket_id", - "optional": true, - "type": "string" - }, - { - "name": "buckets", - "optional": true, - "type": { - "kind": "object", - "name": "Bucket", - "properties": [ - { - "name": "allowed_mime_types", - "optional": true, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "file_size_limit", - "optional": true, - "type": "number" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "name", - "optional": false, - "type": "string" - }, - { - "name": "owner", - "optional": false, - "type": "string" - }, - { - "name": "public", - "optional": false, - "type": "boolean" - }, - { - "name": "type", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "STANDARD" - }, - { - "kind": "literal", - "value": "ANALYTICS" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "created_at", - "optional": false, - "description": "Creation timestamp (null for folders)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "id", - "optional": false, - "description": "Unique identifier for the file (null for folders)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "last_accessed_at", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "metadata", - "optional": false, - "description": "File metadata including size, mimetype, etc. (null for folders)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "name": "FileMetadata", - "properties": [ - { - "name": "cacheControl", - "optional": false, - "description": "Cache control directive (e.g., \"max-age=3600\")", - "type": "string" - }, - { - "name": "contentLength", - "optional": false, - "description": "Content length in bytes (usually same as size)", - "type": "number" - }, - { - "name": "eTag", - "optional": false, - "description": "Entity tag for caching and conditional requests", - "type": "string" - }, - { - "name": "httpStatusCode", - "optional": false, - "description": "HTTP status code from the storage backend", - "type": "number" - }, - { - "name": "lastModified", - "optional": false, - "description": "Last modification timestamp (ISO 8601)", - "type": "string" - }, - { - "name": "mimetype", - "optional": false, - "description": "MIME type of the file", - "type": "string" - }, - { - "name": "size", - "optional": false, - "description": "File size in bytes", - "type": "number" - } - ] - } - ] - } - }, - { - "name": "name", - "optional": false, - "description": "File or folder name (relative to the prefix) - always present", - "type": "string" - }, - { - "name": "owner", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": false, - "description": "Last update timestamp (null for folders)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - } - ] - } - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "List files in a bucket", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .list('folder', {\n limit: 100,\n offset: 0,\n sortBy: { column: 'name', order: 'asc' },\n })\n\n// Handle files vs folders\ndata?.forEach(item => {\n if (item.id !== null) {\n // It's a file\n console.log('File:', item.name, 'Size:', item.metadata?.size)\n } else {\n // It's a folder\n console.log('Folder:', item.name)\n }\n})" - }, - { - "title": "Search files in a bucket", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .list('folder', {\n limit: 100,\n offset: 0,\n sortBy: { column: 'name', order: 'asc' },\n search: 'jon'\n })" - } - ] - }, - { - "name": "listV2", - "description": "Lists all the files and folders within a bucket using the V2 API with pagination support.\n**Important:** Folder entries in the `folders` array only contain `name` and optionally `key` — they have no `id`, timestamps, or `metadata` fields. Full file metadata is only available on entries in the `objects` array.\n this method signature might change in the future", - "parameters": [ - { - "name": "options", - "optional": true, - "description": "Search options including prefix, cursor for pagination, limit, with_delimiter", - "type": { - "kind": "object", - "name": "SearchV2Options", - "properties": [ - { - "name": "cursor", - "optional": true, - "description": "The cursor used for pagination. Pass the value received from nextCursor of the previous request.", - "type": "string" - }, - { - "name": "limit", - "optional": true, - "description": "The number of files you want to be returned.", - "type": "number" - }, - { - "name": "prefix", - "optional": true, - "description": "The prefix search string to filter files by.", - "type": "string" - }, - { - "name": "sortBy", - "optional": true, - "description": "The column and order to sort by", - "type": { - "kind": "object", - "name": "SortByV2", - "properties": [ - { - "name": "column", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "name" - }, - { - "kind": "literal", - "value": "created_at" - }, - { - "kind": "literal", - "value": "updated_at" - } - ] - } - }, - { - "name": "order", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "asc" - }, - { - "kind": "literal", - "value": "desc" - } - ] - } - } - ] - } - }, - { - "name": "with_delimiter", - "optional": true, - "description": "Whether to emulate a hierarchical listing of objects using delimiters.\n- When `false` (default), all objects are listed as flat key/value pairs. - When `true`, the response groups objects by delimiter, making it appear like a file/folder hierarchy.", - "type": "boolean" - } - ] - } - }, - { - "name": "parameters", - "optional": true, - "description": "Optional fetch parameters including signal for cancellation", - "type": { - "kind": "object", - "name": "FetchParameters", - "properties": [ - { - "name": "cache", - "optional": true, - "description": "Controls how the request interacts with the browser's HTTP cache. - 'default': Use standard cache behavior - 'no-store': Bypass cache entirely (useful in Edge Functions) - 'reload': Bypass cache but update it with response - 'no-cache': Validate with server before using cached response - 'force-cache': Use cache even if stale - 'only-if-cached': Only use cache, fail if not cached", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "default" - }, - { - "kind": "literal", - "value": "no-store" - }, - { - "kind": "literal", - "value": "reload" - }, - { - "kind": "literal", - "value": "no-cache" - }, - { - "kind": "literal", - "value": "force-cache" - }, - { - "kind": "literal", - "value": "only-if-cached" - } - ] - } - }, - { - "name": "signal", - "optional": true, - "description": "Pass in an AbortController's signal to cancel the request.", - "type": { - "kind": "reference", - "name": "AbortSignal" - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "name": "SearchV2Result", - "properties": [ - { - "name": "folders", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "SearchV2Folder", - "properties": [ - { - "name": "key", - "optional": true, - "description": "Full folder key/path", - "type": "string" - }, - { - "name": "name", - "optional": false, - "description": "Folder name/prefix", - "type": "string" - } - ] - } - } - }, - { - "name": "hasNext", - "optional": false, - "type": "boolean" - }, - { - "name": "nextCursor", - "optional": true, - "type": "string" - }, - { - "name": "objects", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "SearchV2Object", - "properties": [ - { - "name": "created_at", - "optional": false, - "description": "Creation timestamp", - "type": "string" - }, - { - "name": "id", - "optional": false, - "description": "Unique identifier for the file", - "type": "string" - }, - { - "name": "key", - "optional": true, - "description": "Full object key/path", - "type": "string" - }, - { - "name": "last_accessed_at", - "optional": false, - "type": "string" - }, - { - "name": "metadata", - "optional": false, - "description": "File metadata including size, mimetype, etc. (null if not yet set)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "name": "FileMetadata", - "properties": [ - { - "name": "cacheControl", - "optional": false, - "description": "Cache control directive (e.g., \"max-age=3600\")", - "type": "string" - }, - { - "name": "contentLength", - "optional": false, - "description": "Content length in bytes (usually same as size)", - "type": "number" - }, - { - "name": "eTag", - "optional": false, - "description": "Entity tag for caching and conditional requests", - "type": "string" - }, - { - "name": "httpStatusCode", - "optional": false, - "description": "HTTP status code from the storage backend", - "type": "number" - }, - { - "name": "lastModified", - "optional": false, - "description": "Last modification timestamp (ISO 8601)", - "type": "string" - }, - { - "name": "mimetype", - "optional": false, - "description": "MIME type of the file", - "type": "string" - }, - { - "name": "size", - "optional": false, - "description": "File size in bytes", - "type": "number" - } - ] - } - ] - } - }, - { - "name": "name", - "optional": false, - "description": "File name", - "type": "string" - }, - { - "name": "updated_at", - "optional": false, - "description": "Last update timestamp", - "type": "string" - } - ] - } - } - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "List files with pagination", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .listV2({\n prefix: 'folder/',\n limit: 100,\n })\n\n// Handle pagination\nif (data?.hasNext) {\n const nextPage = await supabase\n .storage\n .from('avatars')\n .listV2({\n prefix: 'folder/',\n cursor: data.nextCursor,\n })\n}\n\n// Handle files vs folders\ndata?.objects.forEach(file => {\n if (file.id !== null) {\n console.log('File:', file.name, 'Size:', file.metadata?.size)\n }\n})\ndata?.folders.forEach(folder => {\n console.log('Folder:', folder.name)\n})" - } - ] - }, - { - "name": "move", - "description": "Moves an existing file to a new path in the same bucket.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: `update` and `select` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "fromPath", - "description": "The original file path, including the current file name. For example `folder/image.png`.", - "type": "string" - }, - { - "name": "toPath", - "description": "The new file path, including the new file name. For example `folder/image-new.png`.", - "type": "string" - }, - { - "name": "options", - "optional": true, - "description": "The destination options.", - "type": { - "kind": "object", - "name": "DestinationOptions", - "properties": [ - { - "name": "destinationBucket", - "optional": true, - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "message", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Move file", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .move('public/avatar1.png', 'private/avatar2.png')" - } - ] - }, - { - "name": "remove", - "description": "Deletes files within the same bucket\nReturns an array of FileObject entries for the deleted files. Note that deprecated fields like `bucket_id` may or may not be present in the response - do not rely on them.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: `delete` and `select` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "paths", - "description": "An array of files to delete, including the path and file name. For example [`'folder/image.png'`].", - "type": { - "kind": "array", - "elementType": "string" - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "FileObject", - "properties": [ - { - "name": "bucket_id", - "optional": true, - "type": "string" - }, - { - "name": "buckets", - "optional": true, - "type": { - "kind": "object", - "name": "Bucket", - "properties": [ - { - "name": "allowed_mime_types", - "optional": true, - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "created_at", - "optional": false, - "type": "string" - }, - { - "name": "file_size_limit", - "optional": true, - "type": "number" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "name", - "optional": false, - "type": "string" - }, - { - "name": "owner", - "optional": false, - "type": "string" - }, - { - "name": "public", - "optional": false, - "type": "boolean" - }, - { - "name": "type", - "optional": true, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "STANDARD" - }, - { - "kind": "literal", - "value": "ANALYTICS" - } - ] - } - }, - { - "name": "updated_at", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "created_at", - "optional": false, - "description": "Creation timestamp (null for folders)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "id", - "optional": false, - "description": "Unique identifier for the file (null for folders)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "last_accessed_at", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "metadata", - "optional": false, - "description": "File metadata including size, mimetype, etc. (null for folders)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "name": "FileMetadata", - "properties": [ - { - "name": "cacheControl", - "optional": false, - "description": "Cache control directive (e.g., \"max-age=3600\")", - "type": "string" - }, - { - "name": "contentLength", - "optional": false, - "description": "Content length in bytes (usually same as size)", - "type": "number" - }, - { - "name": "eTag", - "optional": false, - "description": "Entity tag for caching and conditional requests", - "type": "string" - }, - { - "name": "httpStatusCode", - "optional": false, - "description": "HTTP status code from the storage backend", - "type": "number" - }, - { - "name": "lastModified", - "optional": false, - "description": "Last modification timestamp (ISO 8601)", - "type": "string" - }, - { - "name": "mimetype", - "optional": false, - "description": "MIME type of the file", - "type": "string" - }, - { - "name": "size", - "optional": false, - "description": "File size in bytes", - "type": "number" - } - ] - } - ] - } - }, - { - "name": "name", - "optional": false, - "description": "File or folder name (relative to the prefix) - always present", - "type": "string" - }, - { - "name": "owner", - "optional": true, - "type": "string" - }, - { - "name": "updated_at", - "optional": false, - "description": "Last update timestamp (null for folders)", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - } - ] - } - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Delete file", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .remove(['folder/avatar1.png'])" - } - ] - }, - { - "name": "update", - "description": "Replaces an existing file at the specified path with a new one.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: `update` and `select` - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works - For React Native, using either `Blob`, `File` or `FormData` does not work as intended. Update file using `ArrayBuffer` from base64 file data instead, see example below." - ], - "parameters": [ - { - "name": "path", - "description": "The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to update.", - "type": "string" - }, - { - "name": "fileBody", - "description": "The body of the file to be stored in the bucket.", - "type": { - "kind": "union", - "types": [ - "string", - { - "kind": "reference", - "name": "ArrayBuffer" - }, - { - "kind": "reference", - "name": "ReadableStream", - "typeArguments": [ - { - "kind": "reference", - "name": "Uint8Array", - "typeArguments": [ - { - "kind": "reference", - "name": "ArrayBufferLike" - } - ] - } - ] - }, - { - "kind": "reference", - "name": "Blob" - }, - { - "kind": "reference", - "name": "File" - }, - { - "kind": "reference", - "name": "FormData" - }, - { - "kind": "reference", - "name": "ReadableStream" - }, - { - "kind": "reference", - "name": "URLSearchParams" - }, - { - "kind": "reference", - "name": "ArrayBufferView", - "typeArguments": [ - { - "kind": "reference", - "name": "ArrayBufferLike" - } - ] - }, - { - "kind": "reference", - "name": "Buffer", - "typeArguments": [ - { - "kind": "reference", - "name": "ArrayBufferLike" - } - ] - } - ] - } - }, - { - "name": "fileOptions", - "optional": true, - "description": "Optional file upload options including cacheControl, contentType, upsert, and metadata.", - "type": { - "kind": "object", - "name": "FileOptions", - "properties": [ - { - "name": "cacheControl", - "optional": true, - "description": "The number of seconds the asset is cached in the browser and in the Supabase CDN. This is set in the `Cache-Control: max-age=` header. Defaults to 3600 seconds.", - "type": "string" - }, - { - "name": "contentType", - "optional": true, - "description": "the `Content-Type` header value. Should be specified if using a `fileBody` that is neither `Blob` nor `File` nor `FormData`, otherwise will default to `text/plain;charset=UTF-8`.", - "type": "string" - }, - { - "name": "duplex", - "optional": true, - "description": "The duplex option is a string parameter that enables or disables duplex streaming, allowing for both reading and writing data in the same stream. It can be passed as an option to the fetch() method.", - "type": "string" - }, - { - "name": "headers", - "optional": true, - "description": "Optionally add extra headers", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "string" - ] - } - }, - { - "name": "metadata", - "optional": true, - "description": "The metadata option is an object that allows you to store additional information about the file. This information can be used to filter and search for files. The metadata object can contain any key-value pairs you want to store.", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "any" - ] - } - }, - { - "name": "upsert", - "optional": true, - "description": "When upsert is set to true, the file is overwritten if it exists. When set to false, an error is thrown if the object already exists. Defaults to false.", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "fullPath", - "optional": false, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "path", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Update file", - "code": "const avatarFile = event.target.files[0]\nconst { data, error } = await supabase\n .storage\n .from('avatars')\n .update('public/avatar1.png', avatarFile, {\n cacheControl: '3600',\n upsert: true\n })" - }, - { - "title": "Update file using `ArrayBuffer` from base64 file data", - "code": "import {decode} from 'base64-arraybuffer'\n\nconst { data, error } = await supabase\n .storage\n .from('avatars')\n .update('public/avatar1.png', decode('base64FileData'), {\n contentType: 'image/png'\n })" - } - ] - }, - { - "name": "upload", - "description": "Uploads a file to an existing bucket.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: only `insert` when you are uploading new files and `select`, `insert` and `update` when you are upserting files - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works - For React Native, using either `Blob`, `File` or `FormData` does not work as intended. Upload file using `ArrayBuffer` from base64 file data instead, see example below." - ], - "parameters": [ - { - "name": "path", - "description": "The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.", - "type": "string" - }, - { - "name": "fileBody", - "description": "The body of the file to be stored in the bucket.", - "type": { - "kind": "reference", - "name": "FileBody" - } - }, - { - "name": "fileOptions", - "optional": true, - "description": "Optional file upload options including cacheControl, contentType, upsert, and metadata.", - "type": { - "kind": "object", - "name": "FileOptions", - "properties": [ - { - "name": "cacheControl", - "optional": true, - "description": "The number of seconds the asset is cached in the browser and in the Supabase CDN. This is set in the `Cache-Control: max-age=` header. Defaults to 3600 seconds.", - "type": "string" - }, - { - "name": "contentType", - "optional": true, - "description": "the `Content-Type` header value. Should be specified if using a `fileBody` that is neither `Blob` nor `File` nor `FormData`, otherwise will default to `text/plain;charset=UTF-8`.", - "type": "string" - }, - { - "name": "duplex", - "optional": true, - "description": "The duplex option is a string parameter that enables or disables duplex streaming, allowing for both reading and writing data in the same stream. It can be passed as an option to the fetch() method.", - "type": "string" - }, - { - "name": "headers", - "optional": true, - "description": "Optionally add extra headers", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "string" - ] - } - }, - { - "name": "metadata", - "optional": true, - "description": "The metadata option is an object that allows you to store additional information about the file. This information can be used to filter and search for files. The metadata object can contain any key-value pairs you want to store.", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "any" - ] - } - }, - { - "name": "upsert", - "optional": true, - "description": "When upsert is set to true, the file is overwritten if it exists. When set to false, an error is thrown if the object already exists. Defaults to false.", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "fullPath", - "optional": false, - "type": "string" - }, - { - "name": "id", - "optional": false, - "type": "string" - }, - { - "name": "path", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Upload file", - "code": "const avatarFile = event.target.files[0]\nconst { data, error } = await supabase\n .storage\n .from('avatars')\n .upload('public/avatar1.png', avatarFile, {\n cacheControl: '3600',\n upsert: false\n })" - }, - { - "title": "Upload file using `ArrayBuffer` from base64 file data", - "code": "import { decode } from 'base64-arraybuffer'\n\nconst { data, error } = await supabase\n .storage\n .from('avatars')\n .upload('public/avatar1.png', decode('base64FileData'), {\n contentType: 'image/png'\n })" - } - ] - }, - { - "name": "uploadToSignedUrl", - "description": "Upload a file with a token generated from `createSignedUploadUrl`.", - "remarks": [ - "- RLS policy permissions required: - `buckets` table permissions: none - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works" - ], - "parameters": [ - { - "name": "path", - "description": "The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.", - "type": "string" - }, - { - "name": "token", - "description": "The token generated from `createSignedUploadUrl`", - "type": "string" - }, - { - "name": "fileBody", - "description": "The body of the file to be stored in the bucket.", - "type": { - "kind": "reference", - "name": "FileBody" - } - }, - { - "name": "fileOptions", - "optional": true, - "description": "HTTP headers (cacheControl, contentType, etc.). **Note:** The `upsert` option has no effect here. To enable upsert behavior, pass `{ upsert: true }` when calling `createSignedUploadUrl()` instead.", - "type": { - "kind": "object", - "name": "FileOptions", - "properties": [ - { - "name": "cacheControl", - "optional": true, - "description": "The number of seconds the asset is cached in the browser and in the Supabase CDN. This is set in the `Cache-Control: max-age=` header. Defaults to 3600 seconds.", - "type": "string" - }, - { - "name": "contentType", - "optional": true, - "description": "the `Content-Type` header value. Should be specified if using a `fileBody` that is neither `Blob` nor `File` nor `FormData`, otherwise will default to `text/plain;charset=UTF-8`.", - "type": "string" - }, - { - "name": "duplex", - "optional": true, - "description": "The duplex option is a string parameter that enables or disables duplex streaming, allowing for both reading and writing data in the same stream. It can be passed as an option to the fetch() method.", - "type": "string" - }, - { - "name": "headers", - "optional": true, - "description": "Optionally add extra headers", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "string" - ] - } - }, - { - "name": "metadata", - "optional": true, - "description": "The metadata option is an object that allows you to store additional information about the file. This information can be used to filter and search for files. The metadata object can contain any key-value pairs you want to store.", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "any" - ] - } - }, - { - "name": "upsert", - "optional": true, - "description": "When upsert is set to true, the file is overwritten if it exists. When set to false, an error is thrown if the object already exists. Defaults to false.", - "type": "boolean" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "fullPath", - "optional": false, - "type": "any" - }, - { - "name": "path", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Upload to a signed URL", - "code": "const { data, error } = await supabase\n .storage\n .from('avatars')\n .uploadToSignedUrl('folder/cat.jpg', 'token-from-createSignedUploadUrl', file)" - } - ] - } - ] - }, - { - "category": "Analytics Buckets", - "definitions": [ - { - "name": "createBucket", - "description": "Creates a new analytics bucket using Iceberg tables Analytics buckets are optimized for analytical queries and data processing\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "remarks": [ - "- Creates a new analytics bucket using Iceberg tables - Analytics buckets are optimized for analytical queries and data processing" - ], - "parameters": [ - { - "name": "name", - "description": "A unique name for the bucket you are creating", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "name": "AnalyticBucket", - "properties": [ - { - "name": "created_at", - "optional": false, - "description": "ISO 8601 timestamp of bucket creation", - "type": "string" - }, - { - "name": "format", - "optional": false, - "description": "Storage format used (e.g., 'iceberg')", - "type": "string" - }, - { - "name": "name", - "optional": false, - "description": "Unique identifier for the bucket", - "type": "string" - }, - { - "name": "type", - "optional": false, - "description": "Bucket type - always 'ANALYTICS' for analytics buckets", - "type": { - "kind": "literal", - "value": "ANALYTICS" - } - }, - { - "name": "updated_at", - "optional": false, - "description": "ISO 8601 timestamp of last update", - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Create analytics bucket", - "code": "const { data, error } = await supabase\n .storage\n .analytics\n .createBucket('analytics-data')" - } - ] - }, - { - "name": "deleteBucket", - "description": "Deletes an existing analytics bucket A bucket can't be deleted with existing objects inside it You must first empty the bucket before deletion\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "remarks": [ - "- Deletes an analytics bucket" - ], - "parameters": [ - { - "name": "bucketName", - "description": "The unique identifier of the bucket you would like to delete", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "message", - "optional": false, - "type": "string" - } - ] - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Delete analytics bucket", - "code": "const { data, error } = await supabase\n .storage\n .analytics\n .deleteBucket('analytics-data')" - } - ] - }, - { - "name": "from", - "description": "Get an Iceberg REST Catalog client configured for a specific analytics bucket Use this to perform advanced table and namespace operations within the bucket The returned client provides full access to the Apache Iceberg REST Catalog API with the Supabase `{ data, error }` pattern for consistent error handling on all operations.\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "remarks": [ - "This method provides a bridge between Supabase's bucket management and the standard Apache Iceberg REST Catalog API. The bucket name maps to the Iceberg warehouse parameter. All authentication and configuration is handled automatically using your Supabase credentials.\n**Error Handling**: Invalid bucket names throw immediately. All catalog operations return `{ data, error }` where errors are `IcebergError` instances from iceberg-js. Use helper methods like `error.isNotFound()` or check `error.status` for specific error handling. Use `.throwOnError()` on the analytics client if you prefer exceptions for catalog operations.\n**Cleanup Operations**: When using `dropTable`, the `purge: true` option permanently deletes all table data. Without it, the table is marked as deleted but data remains.\n**Library Dependency**: The returned catalog wraps `IcebergRestCatalog` from iceberg-js. For complete API documentation and advanced usage, refer to the [iceberg-js documentation](https://supabase.github.io/iceberg-js/)." - ], - "parameters": [ - { - "name": "bucketName", - "description": "The name of the analytics bucket (warehouse) to connect to", - "type": "string" - } - ], - "returnType": { - "kind": "mapped" - }, - "examples": [ - { - "title": "Get catalog and create table", - "code": "// First, create an analytics bucket\nconst { data: bucket, error: bucketError } = await supabase\n .storage\n .analytics\n .createBucket('analytics-data')\n\n// Get the Iceberg catalog for that bucket\nconst catalog = supabase.storage.analytics.from('analytics-data')\n\n// Create a namespace\nconst { error: nsError } = await catalog.createNamespace({ namespace: ['default'] })\n\n// Create a table with schema\nconst { data: tableMetadata, error: tableError } = await catalog.createTable(\n { namespace: ['default'] },\n {\n name: 'events',\n schema: {\n type: 'struct',\n fields: [\n { id: 1, name: 'id', type: 'long', required: true },\n { id: 2, name: 'timestamp', type: 'timestamp', required: true },\n { id: 3, name: 'user_id', type: 'string', required: false }\n ],\n 'schema-id': 0,\n 'identifier-field-ids': [1]\n },\n 'partition-spec': {\n 'spec-id': 0,\n fields: []\n },\n 'write-order': {\n 'order-id': 0,\n fields: []\n },\n properties: {\n 'write.format.default': 'parquet'\n }\n }\n)" - }, - { - "title": "List tables in namespace", - "code": "const catalog = supabase.storage.analytics.from('analytics-data')\n\n// List all tables in the default namespace\nconst { data: tables, error: listError } = await catalog.listTables({ namespace: ['default'] })\nif (listError) {\n if (listError.isNotFound()) {\n console.log('Namespace not found')\n }\n return\n}\nconsole.log(tables) // [{ namespace: ['default'], name: 'events' }]" - }, - { - "title": "Working with namespaces", - "code": "const catalog = supabase.storage.analytics.from('analytics-data')\n\n// List all namespaces\nconst { data: namespaces } = await catalog.listNamespaces()\n\n// Create namespace with properties\nawait catalog.createNamespace(\n { namespace: ['production'] },\n { properties: { owner: 'data-team', env: 'prod' } }\n)" - }, - { - "title": "Cleanup operations", - "code": "const catalog = supabase.storage.analytics.from('analytics-data')\n\n// Drop table with purge option (removes all data)\nconst { error: dropError } = await catalog.dropTable(\n { namespace: ['default'], name: 'events' },\n { purge: true }\n)\n\nif (dropError?.isNotFound()) {\n console.log('Table does not exist')\n}\n\n// Drop namespace (must be empty)\nawait catalog.dropNamespace({ namespace: ['default'] })" - } - ] - }, - { - "name": "listBuckets", - "description": "Retrieves the details of all Analytics Storage buckets within an existing project Only returns buckets of type 'ANALYTICS'\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "remarks": [ - "- Retrieves the details of all Analytics Storage buckets within an existing project - Only returns buckets of type 'ANALYTICS'" - ], - "parameters": [ - { - "name": "options", - "optional": true, - "description": "Query parameters for listing buckets", - "type": { - "kind": "object", - "properties": [ - { - "name": "limit", - "optional": true, - "description": "Maximum number of buckets to return", - "type": "number" - }, - { - "name": "offset", - "optional": true, - "description": "Number of buckets to skip", - "type": "number" - }, - { - "name": "search", - "optional": true, - "description": "Search term to filter bucket names", - "type": "string" - }, - { - "name": "sortColumn", - "optional": true, - "description": "Column to sort by ('name', 'created_at', 'updated_at')", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "name" - }, - { - "kind": "literal", - "value": "created_at" - }, - { - "kind": "literal", - "value": "updated_at" - } - ] - } - }, - { - "name": "sortOrder", - "optional": true, - "description": "Sort order ('asc' or 'desc')", - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "asc" - }, - { - "kind": "literal", - "value": "desc" - } - ] - } - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "AnalyticBucket", - "properties": [ - { - "name": "created_at", - "optional": false, - "description": "ISO 8601 timestamp of bucket creation", - "type": "string" - }, - { - "name": "format", - "optional": false, - "description": "Storage format used (e.g., 'iceberg')", - "type": "string" - }, - { - "name": "name", - "optional": false, - "description": "Unique identifier for the bucket", - "type": "string" - }, - { - "name": "type", - "optional": false, - "description": "Bucket type - always 'ANALYTICS' for analytics buckets", - "type": { - "kind": "literal", - "value": "ANALYTICS" - } - }, - { - "name": "updated_at", - "optional": false, - "description": "ISO 8601 timestamp of last update", - "type": "string" - } - ] - } - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "properties": [ - { - "name": "data", - "optional": false, - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "List analytics buckets", - "code": "const { data, error } = await supabase\n .storage\n .analytics\n .listBuckets({\n limit: 10,\n offset: 0,\n sortColumn: 'created_at',\n sortOrder: 'desc'\n })" - } - ] - } - ] - }, - { - "category": "Vector Buckets", - "definitions": [ - { - "name": "createBucket", - "description": "Creates a new vector bucket Vector buckets are containers for vector indexes and their data\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "vectorBucketName", - "description": "Unique name for the vector bucket", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Creating a vector bucket", - "code": "const { data, error } = await supabase\n .storage\n .vectors\n .createBucket('embeddings-prod')" - } - ] - }, - { - "name": "deleteBucket", - "description": "Deletes a vector bucket (bucket must be empty) All indexes must be deleted before deleting the bucket\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "vectorBucketName", - "description": "Name of the vector bucket to delete", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Delete a vector bucket", - "code": "const { data, error } = await supabase\n .storage\n .vectors\n .deleteBucket('embeddings-old')" - } - ] - }, - { - "name": "from", - "description": "Access operations for a specific vector bucket Returns a scoped client for index and vector operations within the bucket\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "vectorBucketName", - "description": "Name of the vector bucket", - "type": "string" - } - ], - "returnType": { - "kind": "object", - "name": "VectorBucketScope", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "createIndex", - "optional": false, - "type": null - }, - { - "name": "deleteIndex", - "optional": false, - "type": null - }, - { - "name": "getIndex", - "optional": false, - "type": null - }, - { - "name": "index", - "optional": false, - "type": null - }, - { - "name": "listIndexes", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Accessing a vector bucket", - "code": "const bucket = supabase.storage.vectors.from('embeddings-prod')" - } - ] - }, - { - "name": "getBucket", - "description": "Retrieves metadata for a specific vector bucket\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "vectorBucketName", - "description": "Name of the vector bucket", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get bucket metadata", - "code": "const { data, error } = await supabase\n .storage\n .vectors\n .getBucket('embeddings-prod')\n\nconsole.log('Bucket created:', data?.vectorBucket.creationTime)" - } - ] - }, - { - "name": "listBuckets", - "description": "Lists all vector buckets with optional filtering and pagination\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "options", - "description": "Optional filters (prefix, maxResults, nextToken)", - "type": { - "kind": "object", - "name": "ListVectorBucketsOptions", - "properties": [ - { - "name": "maxResults", - "optional": true, - "description": "Maximum number of results to return (default: 100)", - "type": "number" - }, - { - "name": "nextToken", - "optional": true, - "description": "Token for pagination from previous response", - "type": "string" - }, - { - "name": "prefix", - "optional": true, - "description": "Filter buckets by name prefix", - "type": "string" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "List vector buckets", - "code": "const { data, error } = await supabase\n .storage\n .vectors\n .listBuckets({ prefix: 'embeddings-' })\n\ndata?.vectorBuckets.forEach(bucket => {\n console.log(bucket.vectorBucketName)\n})" - } - ] - }, - { - "name": "createIndex", - "description": "Creates a new vector index in this bucket Convenience method that automatically includes the bucket name\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "options", - "description": "Index configuration (vectorBucketName is automatically set)", - "type": { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "object", - "name": "CreateIndexOptions", - "properties": [ - { - "name": "dataType", - "optional": false, - "type": { - "kind": "literal", - "value": "float32" - } - }, - { - "name": "dimension", - "optional": false, - "type": "number" - }, - { - "name": "distanceMetric", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "cosine" - }, - { - "kind": "literal", - "value": "euclidean" - }, - { - "kind": "literal", - "value": "dotproduct" - } - ] - } - }, - { - "name": "indexName", - "optional": false, - "type": "string" - }, - { - "name": "metadataConfiguration", - "optional": true, - "type": { - "kind": "object", - "name": "MetadataConfiguration", - "properties": [ - { - "name": "nonFilterableMetadataKeys", - "optional": true, - "description": "Array of metadata keys that cannot be used in filters", - "type": { - "kind": "array", - "elementType": "string" - } - } - ] - } - }, - { - "name": "vectorBucketName", - "optional": false, - "type": "string" - } - ] - }, - { - "kind": "literal", - "value": "vectorBucketName" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Creating a vector index", - "code": "const bucket = supabase.storage.vectors.from('embeddings-prod')\nawait bucket.createIndex({\n indexName: 'documents-openai',\n dataType: 'float32',\n dimension: 1536,\n distanceMetric: 'cosine',\n metadataConfiguration: {\n nonFilterableMetadataKeys: ['raw_text']\n }\n})" - } - ] - }, - { - "name": "deleteIndex", - "description": "Deletes an index from this bucket Convenience method that automatically includes the bucket name\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "indexName", - "description": "Name of the index to delete", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Delete an index", - "code": "const bucket = supabase.storage.vectors.from('embeddings-prod')\nawait bucket.deleteIndex('old-index')" - } - ] - }, - { - "name": "getIndex", - "description": "Retrieves metadata for a specific index in this bucket Convenience method that automatically includes the bucket name\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "indexName", - "description": "Name of the index to retrieve", - "type": "string" - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get index metadata", - "code": "const bucket = supabase.storage.vectors.from('embeddings-prod')\nconst { data } = await bucket.getIndex('documents-openai')\nconsole.log('Dimension:', data?.index.dimension)" - } - ] - }, - { - "name": "index", - "description": "Access operations for a specific index within this bucket Returns a scoped client for vector data operations\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "indexName", - "description": "Name of the index", - "type": "string" - } - ], - "returnType": { - "kind": "object", - "name": "VectorIndexScope", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "deleteVectors", - "optional": false, - "type": null - }, - { - "name": "getVectors", - "optional": false, - "type": null - }, - { - "name": "listVectors", - "optional": false, - "type": null - }, - { - "name": "putVectors", - "optional": false, - "type": null - }, - { - "name": "queryVectors", - "optional": false, - "type": null - }, - { - "name": "setHeader", - "optional": false, - "type": null - }, - { - "name": "throwOnError", - "optional": false, - "type": null - } - ] - }, - "examples": [ - { - "title": "Accessing an index", - "code": "const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')\n\n// Insert vectors\nawait index.putVectors({\n vectors: [\n { key: 'doc-1', data: { float32: [...] }, metadata: { title: 'Intro' } }\n ]\n})\n\n// Query similar vectors\nconst { data } = await index.queryVectors({\n queryVector: { float32: [...] },\n topK: 5\n})" - } - ] - }, - { - "name": "listIndexes", - "description": "Lists indexes in this bucket Convenience method that automatically includes the bucket name\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "options", - "description": "Listing options (vectorBucketName is automatically set)", - "type": { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "object", - "name": "ListIndexesOptions", - "properties": [ - { - "name": "maxResults", - "optional": true, - "description": "Maximum number of results to return (default: 100)", - "type": "number" - }, - { - "name": "nextToken", - "optional": true, - "description": "Token for pagination from previous response", - "type": "string" - }, - { - "name": "prefix", - "optional": true, - "description": "Filter indexes by name prefix", - "type": "string" - }, - { - "name": "vectorBucketName", - "optional": false, - "description": "Name of the parent vector bucket", - "type": "string" - } - ] - }, - { - "kind": "literal", - "value": "vectorBucketName" - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "List indexes", - "code": "const bucket = supabase.storage.vectors.from('embeddings-prod')\nconst { data } = await bucket.listIndexes({ prefix: 'documents-' })" - } - ] - }, - { - "name": "deleteVectors", - "description": "Deletes vectors by keys from this index Convenience method that automatically includes bucket and index names\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "options", - "description": "Deletion options (bucket and index names automatically set)", - "type": { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "object", - "name": "DeleteVectorsOptions", - "properties": [ - { - "name": "indexName", - "optional": false, - "description": "Name of the index", - "type": "string" - }, - { - "name": "keys", - "optional": false, - "description": "Array of vector keys to delete (1-500 items)", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "vectorBucketName", - "optional": false, - "description": "Name of the vector bucket", - "type": "string" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "vectorBucketName" - }, - { - "kind": "literal", - "value": "indexName" - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Delete vectors by keys", - "code": "const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')\nawait index.deleteVectors({\n keys: ['doc-1', 'doc-2', 'doc-3']\n})" - } - ] - }, - { - "name": "getVectors", - "description": "Retrieves vectors by keys from this index Convenience method that automatically includes bucket and index names\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "options", - "description": "Vector retrieval options (bucket and index names automatically set)", - "type": { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "object", - "name": "GetVectorsOptions", - "properties": [ - { - "name": "indexName", - "optional": false, - "description": "Name of the index", - "type": "string" - }, - { - "name": "keys", - "optional": false, - "description": "Array of vector keys to retrieve", - "type": { - "kind": "array", - "elementType": "string" - } - }, - { - "name": "returnData", - "optional": true, - "description": "Whether to include vector data in response", - "type": "boolean" - }, - { - "name": "returnMetadata", - "optional": true, - "description": "Whether to include metadata in response", - "type": "boolean" - }, - { - "name": "vectorBucketName", - "optional": false, - "description": "Name of the vector bucket", - "type": "string" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "vectorBucketName" - }, - { - "kind": "literal", - "value": "indexName" - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Get vectors by keys", - "code": "const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')\nconst { data } = await index.getVectors({\n keys: ['doc-1', 'doc-2'],\n returnMetadata: true\n})" - } - ] - }, - { - "name": "listVectors", - "description": "Lists vectors in this index with pagination Convenience method that automatically includes bucket and index names\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "options", - "description": "Listing options (bucket and index names automatically set)", - "type": { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "object", - "name": "ListVectorsOptions", - "properties": [ - { - "name": "indexName", - "optional": false, - "description": "Name of the index", - "type": "string" - }, - { - "name": "maxResults", - "optional": true, - "description": "Maximum number of results to return (default: 500, max: 1000)", - "type": "number" - }, - { - "name": "nextToken", - "optional": true, - "description": "Token for pagination from previous response", - "type": "string" - }, - { - "name": "returnData", - "optional": true, - "description": "Whether to include vector data in response", - "type": "boolean" - }, - { - "name": "returnMetadata", - "optional": true, - "description": "Whether to include metadata in response", - "type": "boolean" - }, - { - "name": "segmentCount", - "optional": true, - "description": "Total number of parallel segments (1-16)", - "type": "number" - }, - { - "name": "segmentIndex", - "optional": true, - "description": "Zero-based index of this segment (0 to segmentCount-1)", - "type": "number" - }, - { - "name": "vectorBucketName", - "optional": false, - "description": "Name of the vector bucket", - "type": "string" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "vectorBucketName" - }, - { - "kind": "literal", - "value": "indexName" - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "List vectors with pagination", - "code": "const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')\nconst { data } = await index.listVectors({\n maxResults: 500,\n returnMetadata: true\n})" - } - ] - }, - { - "name": "putVectors", - "description": "Inserts or updates vectors in this index Convenience method that automatically includes bucket and index names\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "options", - "description": "Vector insertion options (bucket and index names automatically set)", - "type": { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "object", - "name": "PutVectorsOptions", - "properties": [ - { - "name": "indexName", - "optional": false, - "description": "Name of the index", - "type": "string" - }, - { - "name": "vectorBucketName", - "optional": false, - "description": "Name of the vector bucket", - "type": "string" - }, - { - "name": "vectors", - "optional": false, - "description": "Array of vectors to insert/upsert (1-500 items)", - "type": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "VectorObject", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Vector embedding data", - "type": { - "kind": "object", - "name": "VectorData", - "properties": [ - { - "name": "float32", - "optional": false, - "description": "Array of 32-bit floating point numbers", - "type": { - "kind": "array", - "elementType": "number" - } - } - ] - } - }, - { - "name": "key", - "optional": false, - "description": "Unique identifier for the vector", - "type": "string" - }, - { - "name": "metadata", - "optional": true, - "description": "Optional arbitrary metadata", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "any" - ] - } - } - ] - } - } - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "vectorBucketName" - }, - { - "kind": "literal", - "value": "indexName" - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Insert vectors into an index", - "code": "const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')\nawait index.putVectors({\n vectors: [\n {\n key: 'doc-1',\n data: { float32: [0.1, 0.2, ...] },\n metadata: { title: 'Introduction', page: 1 }\n }\n ]\n})" - } - ] - }, - { - "name": "queryVectors", - "description": "Queries for similar vectors in this index Convenience method that automatically includes bucket and index names\n**Public alpha:** This API is part of a public alpha release and may not be available to your account type.", - "parameters": [ - { - "name": "options", - "description": "Query options (bucket and index names automatically set)", - "type": { - "kind": "reference", - "name": "Omit", - "typeArguments": [ - { - "kind": "object", - "name": "QueryVectorsOptions", - "properties": [ - { - "name": "filter", - "optional": true, - "description": "Optional JSON filter for metadata", - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - "any" - ] - } - }, - { - "name": "indexName", - "optional": false, - "description": "Name of the index", - "type": "string" - }, - { - "name": "queryVector", - "optional": false, - "description": "Query vector to find similar vectors", - "type": { - "kind": "object", - "name": "VectorData", - "properties": [ - { - "name": "float32", - "optional": false, - "description": "Array of 32-bit floating point numbers", - "type": { - "kind": "array", - "elementType": "number" - } - } - ] - } - }, - { - "name": "returnDistance", - "optional": true, - "description": "Whether to include distance scores", - "type": "boolean" - }, - { - "name": "returnMetadata", - "optional": true, - "description": "Whether to include metadata in results", - "type": "boolean" - }, - { - "name": "topK", - "optional": true, - "description": "Number of nearest neighbors to return (default: 10)", - "type": "number" - }, - { - "name": "vectorBucketName", - "optional": false, - "description": "Name of the vector bucket", - "type": "string" - } - ] - }, - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "vectorBucketName" - }, - { - "kind": "literal", - "value": "indexName" - } - ] - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "object", - "name": "SuccessResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Response data of type T", - "type": { - "kind": "typeParam", - "name": "T" - } - }, - { - "name": "error", - "optional": false, - "description": "Null on success", - "type": { - "kind": "literal", - "value": null - } - } - ] - }, - { - "kind": "object", - "name": "ErrorResponse", - "properties": [ - { - "name": "data", - "optional": false, - "description": "Null on error", - "type": { - "kind": "literal", - "value": null - } - }, - { - "name": "error", - "optional": false, - "description": "StorageError with details (named StorageVectorsError for vector operations)", - "type": { - "kind": "object", - "name": "StorageError", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "status", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "number" - ] - } - }, - { - "name": "statusCode", - "optional": false, - "type": { - "kind": "union", - "types": [ - "undefined", - "string" - ] - } - } - ] - } - } - ] - } - ] - } - ] - }, - "examples": [ - { - "title": "Query similar vectors", - "code": "const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')\nconst { data } = await index.queryVectors({\n queryVector: { float32: [0.1, 0.2, ...] },\n topK: 5,\n filter: { category: 'technical' },\n returnDistance: true,\n returnMetadata: true\n})" - } - ] - } - ] - }, - { - "category": "Initializing", - "definitions": [ - { - "name": "getChannels", - "description": "Returns all Realtime channels.", - "parameters": [], - "returnType": { - "kind": "array", - "elementType": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - } - }, - "examples": [ - { - "title": "Get all channels", - "code": "const channels = supabase.getChannels()" - } - ] - }, - { - "name": "removeAllChannels", - "description": "Unsubscribes and removes all Realtime channels from Realtime client.", - "remarks": [ - "- Removing channels is a great way to maintain the performance of your project's Realtime service as well as your database if you're listening to Postgres changes. Supabase will automatically handle cleanup 30 seconds after a client is disconnected, but unused channels may cause degradation as more clients are simultaneously subscribed." - ], - "parameters": [], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "array", - "elementType": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "error" - }, - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - } - ] - } - } - ] - }, - "examples": [ - { - "title": "Remove all channels", - "code": "supabase.removeAllChannels()" - } - ] - }, - { - "name": "removeChannel", - "description": "Unsubscribes and removes Realtime channel from Realtime client.", - "remarks": [ - "- Removing a channel is a great way to maintain the performance of your project's Realtime service as well as your database if you're listening to Postgres changes. Supabase will automatically handle cleanup 30 seconds after a client is disconnected, but unused channels may cause degradation as more clients are simultaneously subscribed." - ], - "parameters": [ - { - "name": "channel", - "description": "The name of the Realtime channel.", - "type": { - "kind": "object", - "name": "RealtimeChannel", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "bindings", - "optional": false, - "type": { - "kind": "reference", - "name": "Record", - "typeArguments": [ - "string", - { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "Binding" - } - } - ] - } - }, - { - "name": "broadcastEndpointURL", - "optional": false, - "type": "string" - }, - { - "name": "params", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "config", - "optional": false, - "type": { - "kind": "object", - "properties": [ - { - "name": "broadcast", - "optional": true, - "description": "self option enables client to receive message it broadcast ack option instructs server to acknowledge that broadcast message was received replay option instructs server to replay broadcast messages", - "type": { - "kind": "object", - "properties": [ - { - "name": "ack", - "optional": true, - "type": "boolean" - }, - { - "name": "replay", - "optional": true, - "type": { - "kind": "reference", - "name": "ReplayOption" - } - }, - { - "name": "self", - "optional": true, - "type": "boolean" - } - ] - } - }, - { - "name": "presence", - "optional": true, - "description": "key option is used to track presence payload across clients", - "type": { - "kind": "object", - "properties": [ - { - "name": "enabled", - "optional": true, - "type": "boolean" - }, - { - "name": "key", - "optional": true, - "type": "string" - } - ] - } - }, - { - "name": "private", - "optional": true, - "description": "defines if the channel is private or not and if RLS policies will be used to check data", - "type": "boolean" - } - ] - } - } - ], - "name": "RealtimeChannelOptions" - } - }, - { - "name": "presence", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimePresence", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": { - "kind": "reference", - "name": "RealtimeChannel" - } - }, - { - "name": "state", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "private", - "optional": false, - "type": "boolean" - }, - { - "name": "socket", - "optional": false, - "type": { - "kind": "object", - "name": "RealtimeClient", - "properties": [ - { - "name": "constructor", - "optional": false, - "type": null - }, - { - "name": "accessToken", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - { - "kind": "object", - "properties": [] - } - ] - } - }, - { - "name": "accessTokenValue", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "apiKey", - "optional": false, - "type": { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": null - }, - "string" - ] - } - }, - { - "name": "channels", - "optional": false, - "type": { - "kind": "array", - "elementType": { - "kind": "reference", - "name": "RealtimeChannel" - } - } - }, - { - "name": "fetch", - "optional": false, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "headers", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "httpEndpoint", - "optional": false, - "type": "string" - }, - { - "name": "logLevel", - "optional": true, - "type": { - "kind": "reference", - "name": "LogLevel" - } - }, - { - "name": "params", - "optional": true, - "type": { - "kind": "object", - "properties": [] - } - }, - { - "name": "ref", - "optional": false, - "type": "number" - }, - { - "name": "serializer", - "optional": false, - "type": { - "kind": "reference", - "name": "Serializer" - } - }, - { - "name": "worker", - "optional": true, - "type": "boolean" - }, - { - "name": "workerRef", - "optional": true, - "type": { - "kind": "reference", - "name": "Worker" - } - }, - { - "name": "workerUrl", - "optional": true, - "type": "string" - }, - { - "name": "decode", - "optional": false, - "type": null - }, - { - "name": "encode", - "optional": false, - "type": null - }, - { - "name": "endPoint", - "optional": false, - "type": null - }, - { - "name": "heartbeatCallback", - "optional": false, - "type": null - }, - { - "name": "heartbeatIntervalMs", - "optional": false, - "type": null - }, - { - "name": "heartbeatTimer", - "optional": false, - "type": null - }, - { - "name": "pendingHeartbeatRef", - "optional": false, - "type": null - }, - { - "name": "reconnectAfterMs", - "optional": false, - "type": null - }, - { - "name": "reconnectTimer", - "optional": false, - "type": null - }, - { - "name": "sendBuffer", - "optional": false, - "type": null - }, - { - "name": "stateChangeCallbacks", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "transport", - "optional": false, - "type": null - }, - { - "name": "vsn", - "optional": false, - "type": null - }, - { - "name": "channel", - "optional": false, - "type": null - }, - { - "name": "connect", - "optional": false, - "type": null - }, - { - "name": "connectionState", - "optional": false, - "type": null - }, - { - "name": "disconnect", - "optional": false, - "type": null - }, - { - "name": "endpointURL", - "optional": false, - "type": null - }, - { - "name": "getChannels", - "optional": false, - "type": null - }, - { - "name": "isConnected", - "optional": false, - "type": null - }, - { - "name": "isConnecting", - "optional": false, - "type": null - }, - { - "name": "isDisconnecting", - "optional": false, - "type": null - }, - { - "name": "log", - "optional": false, - "type": null - }, - { - "name": "onHeartbeat", - "optional": false, - "type": null - }, - { - "name": "push", - "optional": false, - "type": null - }, - { - "name": "removeAllChannels", - "optional": false, - "type": null - }, - { - "name": "removeChannel", - "optional": false, - "type": null - }, - { - "name": "sendHeartbeat", - "optional": false, - "type": null - }, - { - "name": "setAuth", - "optional": false, - "type": null - } - ] - } - }, - { - "name": "subTopic", - "optional": false, - "type": "string" - }, - { - "name": "topic", - "optional": false, - "description": "Topic name can be any string.", - "type": "string" - }, - { - "name": "joinedOnce", - "optional": false, - "type": null - }, - { - "name": "joinPush", - "optional": false, - "type": null - }, - { - "name": "rejoinTimer", - "optional": false, - "type": null - }, - { - "name": "state", - "optional": false, - "type": null - }, - { - "name": "timeout", - "optional": false, - "type": null - }, - { - "name": "copyBindings", - "optional": false, - "type": null - }, - { - "name": "httpSend", - "optional": false, - "type": null - }, - { - "name": "on", - "optional": false, - "type": null - }, - { - "name": "presenceState", - "optional": false, - "type": null - }, - { - "name": "send", - "optional": false, - "type": null - }, - { - "name": "subscribe", - "optional": false, - "type": null - }, - { - "name": "teardown", - "optional": false, - "type": null - }, - { - "name": "track", - "optional": false, - "type": null - }, - { - "name": "unsubscribe", - "optional": false, - "type": null - }, - { - "name": "untrack", - "optional": false, - "type": null - }, - { - "name": "updateJoinPayload", - "optional": false, - "type": null - } - ] - } - } - ], - "returnType": { - "kind": "reference", - "name": "Promise", - "typeArguments": [ - { - "kind": "union", - "types": [ - { - "kind": "literal", - "value": "error" - }, - { - "kind": "literal", - "value": "ok" - }, - { - "kind": "literal", - "value": "timed out" - } - ] - } - ] - }, - "examples": [ - { - "title": "Removes a channel", - "code": "supabase.removeChannel(myChannel)" - } - ] - } - ] - } -] \ No newline at end of file