Fetches a user by their foreignId. If no user exists, creates a new one. Also updates existing users if provided data differs.
Query Parameters
string
required
A unique external user identifier
string
User’s display name
string
User’s handle/username
string
URL to the user’s avatar image
string
User bio or description
string
JSON string of additional user metadata
string
JSON string of secure metadata (not returned in response)
Response
object
The user object
Show properties
string
User’s unique identifier
string
ID of the project this user belongs to
string
External reference ID
string
User’s full name
string
User’s username
string
URL to user’s avatar image
string
User’s biography
string | null
User’s birthdate
number
User’s reputation score
object | null
User’s location
object
Suspension status
Show properties
boolean
Whether the user is suspended
string | null
Suspension reason if applicable
string | null
Suspension start date
string | null
Suspension end date
object
Custom public metadata
string
Account creation timestamp
string
Last update timestamp
boolean
Whether the user was created during this request
boolean
Whether the user was updated during this request
Error Responses
Missing or Invalid Foreign ID - 400 Bad Request
{ "error": "Missing or invalid foreign user ID.", "code": "user/invalid-identifier"}
Server Error - 500 Internal Server Error
{ "error": "Internal server error", "code": "user/server-error", "details": "<Error message>"}
Notes
This endpoint is useful when managing users from external systems.
secureMetadata is accepted and used for updates, but never returned.
The response includes created and updated flags to indicate what occurred.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Sublay Documentation","colors":{"primary":"#D22F55","light":"#F06789","dark":"#9E1E3E"},"logo":{"light":"https://mintcdn.com/replyke/v1bBipIMITFr7df3/logo/wordmark-dark.png?fit=max\u0026auto=format\u0026n=v1bBipIMITFr7df3\u0026q=85\u0026s=b95cabb32c98884aa4bca294b07238cc","dark":"https://mintcdn.com/replyke/v1bBipIMITFr7df3/logo/wordmark-light.png?fit=max\u0026auto=format\u0026n=v1bBipIMITFr7df3\u0026q=85\u0026s=871e10ec08b164c26f260e845b44c5c5"},"favicon":"https://mintcdn.com/replyke/v1bBipIMITFr7df3/favicon.svg?fit=max\u0026auto=format\u0026n=v1bBipIMITFr7df3\u0026q=85\u0026s=4988ad1acfb2c3909d214fd1ea72e5d8","api":{"playground":{"display":"none"},"mdx":{"auth":{"method":"bearer"},"server":"https://api.sublay.io"}},"navbar":{"links":[{"href":"https://dash.sublay.io","label":"Dashboard"}]},"footer":{"socials":{"github":"https://github.com/sublay-io"}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","cursor","vscode"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"replyke","hasAudioNarration":false,"actualSubdomain":"replyke","customDomains":["docs.sublay.io"],"gitSource":{"type":"github","owner":"sublay-io","repo":"monorepo","deployBranch":"v8","contentDirectory":"docs","isPrivate":false,"mountPath":"","label":""},"entitlements":{},"buildId":"6af74153a071dcdd90feee77","clientVersion":"0.0.4142","searchFilterCounts":[{"language":"default","tag":"API Reference","count":521},{"language":"default","tag":"Hooks Reference","count":486},{"language":"default","tag":"SDK Reference","count":145},{"language":"default","tag":"Components","count":92},{"language":"default","tag":"Modules","count":84},{"language":"default","tag":"Spaces","count":68},{"language":"default","tag":"Data Models","count":55},{"language":"default","tag":"Models","count":55},{"language":"default","tag":"Workspaces","count":50},{"language":"default","tag":"JS SDK","count":44}]},"assistantConfig":{"enableStarterQuestions":false},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"v6/api-reference/users/fetch-user-by-foreign-id","slug":"/v6/api-reference/users/fetch-user-by-foreign-id","pageMetadata":{"title":"Fetch User By Foreign Id","api":"GET /api/v6/:projectId/users/by-foreign-id","description":"Get or create user by their external foreign ID","href":"/v6/api-reference/users/fetch-user-by-foreign-id"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Get or create user by their external foreign ID\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,hr:`hr`,li:`li`,p:`p`,pre:`pre`,span:`span`,ul:`ul`,..._provideComponents(),...props.components},{Accordion,AccordionGroup,CodeBlock,Expandable,Heading,ParamField,ResponseField}=_components;if(!Accordion)_missingMdxReference(`Accordion`,true);if(!AccordionGroup)_missingMdxReference(`AccordionGroup`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!ResponseField)_missingMdxReference(`ResponseField`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Fetches a user by their `,_jsx(_components.code,{children:`foreignId`}),`. If no user exists, creates a new one. Also updates existing users if provided data differs.`]}),`\n`,_jsx(Heading,{level:`2`,id:`query-parameters`,children:`Query Parameters`}),`\n`,_jsx(ParamField,{query:`foreignId`,type:`string`,required:true,id:`param-foreign-id`,children:_jsx(_components.p,{children:`A unique external user identifier`})}),`\n`,_jsx(ParamField,{query:`name`,type:`string`,id:`param-name`,children:_jsx(_components.p,{children:`User’s display name`})}),`\n`,_jsx(ParamField,{query:`username`,type:`string`,id:`param-username`,children:_jsx(_components.p,{children:`User’s handle/username`})}),`\n`,_jsx(ParamField,{query:`avatar`,type:`string`,id:`param-avatar`,children:_jsx(_components.p,{children:`URL to the user’s avatar image`})}),`\n`,_jsx(ParamField,{query:`bio`,type:`string`,id:`param-bio`,children:_jsx(_components.p,{children:`User bio or description`})}),`\n`,_jsx(ParamField,{query:`metadata`,type:`string`,id:`param-metadata`,children:_jsx(_components.p,{children:`JSON string of additional user metadata`})}),`\n`,_jsx(ParamField,{query:`secureMetadata`,type:`string`,id:`param-secure-metadata`,children:_jsx(_components.p,{children:`JSON string of secure metadata (not returned in response)`})}),`\n`,_jsx(Heading,{level:`2`,id:`response`,children:`Response`}),`\n`,_jsxs(ResponseField,{name:`user`,type:`object`,id:`param-user`,children:[_jsx(_components.p,{children:`The user object`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ResponseField,{name:`id`,type:`string`,id:`param-id`,children:_jsx(_components.p,{children:`User’s unique identifier`})}),_jsx(ResponseField,{name:`projectId`,type:`string`,id:`param-project-id`,children:_jsx(_components.p,{children:`ID of the project this user belongs to`})}),_jsx(ResponseField,{name:`foreignId`,type:`string`,id:`param-foreign-id-1`,children:_jsx(_components.p,{children:`External reference ID`})}),_jsx(ResponseField,{name:`name`,type:`string`,id:`param-name-1`,children:_jsx(_components.p,{children:`User’s full name`})}),_jsx(ResponseField,{name:`username`,type:`string`,id:`param-username-1`,children:_jsx(_components.p,{children:`User’s username`})}),_jsx(ResponseField,{name:`avatar`,type:`string`,id:`param-avatar-1`,children:_jsx(_components.p,{children:`URL to user’s avatar image`})}),_jsx(ResponseField,{name:`bio`,type:`string`,id:`param-bio-1`,children:_jsx(_components.p,{children:`User’s biography`})}),_jsx(ResponseField,{name:`birthdate`,type:`string | null`,id:`param-birthdate`,children:_jsx(_components.p,{children:`User’s birthdate`})}),_jsx(ResponseField,{name:`reputation`,type:`number`,id:`param-reputation`,children:_jsx(_components.p,{children:`User’s reputation score`})}),_jsx(ResponseField,{name:`location`,type:`object | null`,id:`param-location`,children:_jsx(_components.p,{children:`User’s location`})}),_jsxs(ResponseField,{name:`suspension`,type:`object`,id:`param-suspension`,children:[_jsx(_components.p,{children:`Suspension status`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ResponseField,{name:`isSuspended`,type:`boolean`,id:`param-is-suspended`,children:_jsx(_components.p,{children:`Whether the user is suspended`})}),_jsx(ResponseField,{name:`reason`,type:`string | null`,id:`param-reason`,children:_jsx(_components.p,{children:`Suspension reason if applicable`})}),_jsx(ResponseField,{name:`startDate`,type:`string | null`,id:`param-start-date`,children:_jsx(_components.p,{children:`Suspension start date`})}),_jsx(ResponseField,{name:`endDate`,type:`string | null`,id:`param-end-date`,children:_jsx(_components.p,{children:`Suspension end date`})})]})]}),_jsx(ResponseField,{name:`metadata`,type:`object`,id:`param-metadata-1`,children:_jsx(_components.p,{children:`Custom public metadata`})}),_jsx(ResponseField,{name:`createdAt`,type:`string`,id:`param-created-at`,children:_jsx(_components.p,{children:`Account creation timestamp`})}),_jsx(ResponseField,{name:`updatedAt`,type:`string`,id:`param-updated-at`,children:_jsx(_components.p,{children:`Last update timestamp`})})]})]}),`\n`,_jsx(ResponseField,{name:`created`,type:`boolean`,id:`param-created`,children:_jsx(_components.p,{children:`Whether the user was created during this request`})}),`\n`,_jsx(ResponseField,{name:`updated`,type:`boolean`,id:`param-updated`,children:_jsx(_components.p,{children:`Whether the user was updated during this request`})}),`\n`,_jsx(Heading,{level:`2`,id:`error-responses`,children:`Error Responses`}),`\n`,_jsxs(AccordionGroup,{children:[_jsx(Accordion,{title:`Missing or Invalid Foreign ID - 400 Bad Request`,id:`missing-or-invalid-foreign-id-400-bad-request`,children:_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"error\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Missing or invalid foreign user ID.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"code\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user/invalid-identifier\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})})}),_jsx(Accordion,{title:`Server Error - 500 Internal Server Error`,id:`server-error-500-internal-server-error`,children:_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"error\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Internal server error\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"code\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user/server-error\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"details\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cError message>\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})})})]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`notes`,children:`Notes`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`This endpoint is useful when managing users from external systems.`}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`secureMetadata`}),` is accepted and used for updates, but never returned.`]}),`\n`,_jsxs(_components.li,{children:[`The response includes `,_jsx(_components.code,{children:`created`}),` and `,_jsx(_components.code,{children:`updated`}),` flags to indicate what occurred.`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Fetch User By Foreign Id","api":"GET /api/v6/:projectId/users/by-foreign-id","description":"Get or create user by their external foreign ID","href":"/v6/api-reference/users/fetch-user-by-foreign-id"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Query Parameters","slug":"query-parameters","depth":2,"children":[]},{"title":"Response","slug":"response","depth":2,"children":[]},{"title":"Error Responses","slug":"error-responses","depth":2,"children":[]},{"title":"Notes","slug":"notes","depth":2,"children":[]}],"codeExamples":{},"endpoint":{"title":"Fetch User By Foreign Id","path":"/api/v6/:projectId/users/by-foreign-id","servers":[{"url":"https://api.sublay.io"}],"method":"get","request":{"security":[{"title":"Bearer Auth","parameters":{"header":{"Authorization":{"type":"http","scheme":"bearer","description":"Bearer authentication header of the form `Bearer \u003ctoken>`, where `\u003ctoken>` is your auth token."}},"query":{},"cookie":{}}}],"parameters":{"query":{"foreignId":{"schema":[{"type":"string","description":"A unique external user identifier","required":true}]},"name":{"schema":[{"type":"string","description":"User’s display name"}]},"username":{"schema":[{"type":"string","description":"User’s handle/username"}]},"avatar":{"schema":[{"type":"string","description":"URL to the user’s avatar image"}]},"bio":{"schema":[{"type":"string","description":"User bio or description"}]},"metadata":{"schema":[{"type":"string","description":"JSON string of additional user metadata"}]},"secureMetadata":{"schema":[{"type":"string","description":"JSON string of secure metadata (not returned in response)"}]}},"header":{},"cookie":{},"path":{}},"body":{}},"response":{"200":{"application/json":{"schemaArray":[{"type":"object","properties":{"user":[{"type":"object","properties":{"id":[{"type":"string","description":"User’s unique identifier"}],"projectId":[{"type":"string","description":"ID of the project this user belongs to"}],"foreignId":[{"type":"string","description":"External reference ID"}],"name":[{"type":"string","description":"User’s full name"}],"username":[{"type":"string","description":"User’s username"}],"avatar":[{"type":"string","description":"URL to user’s avatar image"}],"bio":[{"type":"string","description":"User’s biography"}],"birthdate":[{"type":"object","properties":{},"description":"User’s birthdate"}],"reputation":[{"type":"number","description":"User’s reputation score"}],"location":[{"type":"object","properties":{},"description":"User’s location"}],"suspension":[{"type":"object","properties":{"isSuspended":[{"type":"boolean","description":"Whether the user is suspended"}],"reason":[{"type":"object","properties":{},"description":"Suspension reason if applicable"}],"startDate":[{"type":"object","properties":{},"description":"Suspension start date"}],"endDate":[{"type":"object","properties":{},"description":"Suspension end date"}]},"description":"Suspension status"}],"metadata":[{"type":"object","properties":{},"description":"Custom public metadata"}],"createdAt":[{"type":"string","description":"Account creation timestamp"}],"updatedAt":[{"type":"string","description":"Last update timestamp"}]},"description":"The user object"}],"created":[{"type":"boolean","description":"Whether the user was created during this request"}],"updated":[{"type":"boolean","description":"Whether the user was updated during this request"}]}}],"examples":{"example":{"value":{"user":{"id":"\u003cstring>","projectId":"\u003cstring>","foreignId":"\u003cstring>","name":"\u003cstring>","username":"\u003cstring>","avatar":"\u003cstring>","bio":"\u003cstring>","birthdate":{},"reputation":123,"location":{},"suspension":{"isSuspended":true,"reason":{},"startDate":{},"endDate":{}},"metadata":{},"createdAt":"\u003cstring>","updatedAt":"\u003cstring>"},"created":true,"updated":true}}}}}},"deprecated":false}},"jsLinks":[],"subdomain":"replyke","siteName":"Sublay Documentation","title":"Fetch User By Foreign Id - Sublay Documentation","navMaps":{"firstHrefInVersion":{"8.0.0":{"href":"/v8/api-reference/users/fetch-user-by-foreign-id","matchLevel":1},"7.0.0":{"href":"/v7/api-reference/users/fetch-user-by-foreign-id","matchLevel":1},"6.0.0":{"href":"/v6/api-reference/users/fetch-user-by-foreign-id","matchLevel":0}},"firstHrefInLanguage":{}},"lastModified":"2026-04-13T17:14:53.256Z","originalFileLocation":"v6/api-reference/users/fetch-user-by-foreign-id.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Get or create user by their external foreign ID\">\u003cmeta data-mint-head name=\"application-name\" content=\"Sublay Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/replyke/a1LNRWO56FGzWHgw/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/replyke/a1LNRWO56FGzWHgw/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/replyke/a1LNRWO56FGzWHgw/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/replyke/a1LNRWO56FGzWHgw/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/replyke/a1LNRWO56FGzWHgw/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/replyke/a1LNRWO56FGzWHgw/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/replyke/a1LNRWO56FGzWHgw/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/replyke/a1LNRWO56FGzWHgw/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/replyke/a1LNRWO56FGzWHgw/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Fetch User By Foreign Id - Sublay Documentation\">\u003cmeta data-mint-head property=\"og:description\" content=\"Get or create user by their external foreign ID\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Sublay Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.sublay.io/v6/api-reference/users/fetch-user-by-foreign-id\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://replyke.mintlify.site/_mintlify/api/og/v2?division=User+Endpoints\u0026amp;title=Fetch+User+By+Foreign+Id\u0026amp;description=Get+or+create+user+by+their+external+foreign+ID\u0026amp;theme=1f560c5aaf3e1f0507c7e36a\u0026amp;signature=733425b955b0864a4889474c345cbf994f364ae2fbdb01df3b715ddcf232ce0a\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Fetch User By Foreign Id - Sublay Documentation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Get or create user by their external foreign ID\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://replyke.mintlify.site/_mintlify/api/og/v2?division=User+Endpoints\u0026amp;title=Fetch+User+By+Foreign+Id\u0026amp;description=Get+or+create+user+by+their+external+foreign+ID\u0026amp;theme=1f560c5aaf3e1f0507c7e36a\u0026amp;signature=733425b955b0864a4889474c345cbf994f364ae2fbdb01df3b715ddcf232ce0a\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/replyke/a1LNRWO56FGzWHgw/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Sublay Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#D22F55\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.sublay.io/v6/api-reference/users/fetch-user-by-foreign-id\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/v6/api-reference/users/fetch-user-by-foreign-id.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.sublay.io/#organization\",\"name\":\"Sublay Documentation\",\"url\":\"https://docs.sublay.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/replyke/v1bBipIMITFr7df3/logo/wordmark-dark.png?fit=max\u0026auto=format\u0026n=v1bBipIMITFr7df3\u0026q=85\u0026s=b95cabb32c98884aa4bca294b07238cc\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.sublay.io#website\",\"name\":\"Sublay Documentation\",\"url\":\"https://docs.sublay.io\",\"publisher\":{\"@id\":\"https://docs.sublay.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.sublay.io/v6/api-reference/users/fetch-user-by-foreign-id#webpage\",\"url\":\"https://docs.sublay.io/v6/api-reference/users/fetch-user-by-foreign-id\",\"name\":\"Fetch User By Foreign Id\",\"description\":\"Get or create user by their external foreign ID\",\"dateModified\":\"2026-04-13T17:14:53.256Z\",\"isPartOf\":{\"@id\":\"https://docs.sublay.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.sublay.io/v6/api-reference/users/fetch-user-by-foreign-id#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.sublay.io/v6/api-reference/users/fetch-user-by-foreign-id#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"User Endpoints\",\"item\":\"https://docs.sublay.io/v6/api-reference/users/fetch-user\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fetch User By Foreign Id\",\"item\":\"https://docs.sublay.io/v6/api-reference/users/fetch-user-by-foreign-id\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.sublay.io/v6/api-reference/users/fetch-user-by-foreign-id#apireference\",\"headline\":\"Fetch User By Foreign Id\",\"name\":\"Fetch User By Foreign Id\",\"description\":\"Get or create user by their external foreign ID\",\"url\":\"https://docs.sublay.io/v6/api-reference/users/fetch-user-by-foreign-id\",\"mainEntityOfPage\":{\"@id\":\"https://docs.sublay.io/v6/api-reference/users/fetch-user-by-foreign-id#webpage\"},\"dateModified\":\"2026-04-13T17:14:53.256Z\",\"publisher\":{\"@id\":\"https://docs.sublay.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.sublay.io#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Sublay Documentation\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Sublay Documentation\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/v6/api-reference/users/fetch-user-by-foreign-id.md","siteName":"Sublay Documentation","nav":{"global":null,"versions":[{"version":"8.0.0","tag":"Beta","pages":[{"title":"8.0.0","href":"/v8/api-reference/users/fetch-user-by-foreign-id"}]},{"version":"7.0.0","default":true,"pages":[{"title":"7.0.0","href":"/v7/api-reference/users/fetch-user-by-foreign-id"}]},{"version":"6.0.0","tabs":[{"tab":"Overview","pages":[{"title":"Overview","href":"/v6"}]},{"tab":"SDK Reference","pages":[{"title":"SDK Reference","href":"/v6/sdk/getting-started"}]},{"tab":"Components","pages":[{"title":"Components","href":"/v6/components/overview"}]},{"tab":"Hooks Reference","pages":[{"title":"Hooks Reference","href":"/v6/hooks/overview"}]},{"tab":"API Reference","groups":[{"group":"Getting Started","pages":[{"title":"Getting Started","href":"/v6/api-reference/getting-started"},{"title":"Authentication","href":"/v6/api-reference/authentication"}]},{"group":"Auth Endpoints","pages":[{"title":"Sign In","api":"POST /api/v6/:projectId/auth/sign-in","href":"/v6/api-reference/auth/sign-in"},{"title":"Sign Up","api":"POST /api/v6/:projectId/auth/sign-up","href":"/v6/api-reference/auth/sign-up"},{"title":"Sign Out","api":"POST /api/v6/:projectId/auth/sign-out","href":"/v6/api-reference/auth/sign-out"},{"title":"Request New Access Token","api":"POST /api/v6/:projectId/auth/request-new-access-token","href":"/v6/api-reference/auth/request-new-access-token"},{"title":"Verify External User","api":"POST /api/v6/:projectId/auth/verify-external-user","href":"/v6/api-reference/auth/verify-external-user"},{"title":"Change Password","api":"POST /api/v6/:projectId/auth/change-password","href":"/v6/api-reference/auth/change-password"}]},{"group":"User Endpoints","pages":[{"title":"Fetch User","api":"GET /api/v6/:projectId/users/:userId","description":"Retrieve details of a specific user by their ID","href":"/v6/api-reference/users/fetch-user"},{"title":"Fetch User By Foreign Id","api":"GET /api/v6/:projectId/users/by-foreign-id","href":"/v6/api-reference/users/fetch-user-by-foreign-id"},{"title":"Fetch User Suggestions","api":"GET /api/v6/:projectId/users/suggestions","description":"Get user suggestions for mentions and user pickers","href":"/v6/api-reference/users/fetch-user-suggestions"},{"title":"Check Username Availability","api":"GET /api/v6/:projectId/users/check-username","href":"/v6/api-reference/users/check-username-availability"},{"title":"Update User","api":"PATCH /api/v6/:projectId/users/:userId","href":"/v6/api-reference/users/update-user"}]},{"group":"User Follow Operations","pages":[{"title":"User Follow Operations Overview","href":"/v6/api-reference/users/follows/overview"},{"title":"Create Follow","api":"POST /api/v6/:projectId/users/:userId/follow","href":"/v6/api-reference/users/follows/create-follow"},{"title":"Delete Follow","api":"DELETE /api/v6/:projectId/users/:userId/follow","href":"/v6/api-reference/users/follows/delete-follow"},{"title":"Fetch Follow Status","api":"GET /api/v6/:projectId/users/:userId/follow","href":"/v6/api-reference/users/follows/fetch-follow-status"},{"title":"Fetch Followers","api":"GET /api/v6/:projectId/users/:userId/followers","href":"/v6/api-reference/users/follows/fetch-followers"},{"title":"Fetch Followers Count","api":"GET /api/v6/:projectId/users/:userId/followers-count","href":"/v6/api-reference/users/follows/fetch-followers-count"},{"title":"Fetch Following","api":"GET /api/v6/:projectId/users/:userId/following","href":"/v6/api-reference/users/follows/fetch-following"},{"title":"Fetch Following Count","api":"GET /api/v6/:projectId/users/:userId/following-count","href":"/v6/api-reference/users/follows/fetch-following-count"}]},{"group":"Follow Endpoints","pages":[{"title":"Overview","href":"/v6/api-reference/follows/overview"},{"title":"Fetch Following","api":"GET /api/v6/:projectId/follows/following","href":"/v6/api-reference/follows/fetch-following"},{"title":"Fetch Followers","api":"GET /api/v6/:projectId/follows/followers","href":"/v6/api-reference/follows/fetch-followers"},{"title":"Fetch Following Count","api":"GET /api/v6/:projectId/follows/following-count","href":"/v6/api-reference/follows/fetch-following-count"},{"title":"Fetch Followers Count","api":"GET /api/v6/:projectId/follows/followers-count","href":"/v6/api-reference/follows/fetch-followers-count"},{"title":"Delete Follow","api":"DELETE /api/v6/:projectId/follows/:followId","href":"/v6/api-reference/follows/delete-follow"}]},{"group":"User Connection Operations","pages":[{"title":"User Connection Operations Overview","href":"/v6/api-reference/users/connections/overview"},{"title":"Request Connection","api":"POST /api/v6/:projectId/users/:userId/connection","href":"/v6/api-reference/users/connections/request-connection"},{"title":"Fetch Connection Status","api":"GET /api/v6/:projectId/users/:userId/connection","href":"/v6/api-reference/users/connections/fetch-connection-status"},{"title":"Fetch Connections By User Id","api":"GET /api/v6/:projectId/users/:userId/connections","href":"/v6/api-reference/users/connections/fetch-connections-by-user-id"},{"title":"Fetch Connections Count By User Id","api":"GET /api/v6/:projectId/users/:userId/connections-count","href":"/v6/api-reference/users/connections/fetch-connections-count-by-user-id"},{"title":"Remove Connection By User Id","api":"DELETE /api/v6/:projectId/users/:userId/connection","href":"/v6/api-reference/users/connections/remove-connection-by-user-id"}]},{"group":"Connection Endpoints","pages":[{"title":"Connection Operations Overview","href":"/v6/api-reference/connections/overview"},{"title":"Get Current User Connections","api":"GET /api/v6/:projectId/connections","href":"/v6/api-reference/connections/fetch-connections"},{"title":"Get Current User Connections Count","api":"GET /api/v6/:projectId/connections/count","href":"/v6/api-reference/connections/fetch-connections-count"},{"title":"Get Sent Pending Requests","api":"GET /api/v6/:projectId/connections/pending/sent","href":"/v6/api-reference/connections/fetch-sent-pending-connections"},{"title":"Get Received Pending Requests","api":"GET /api/v6/:projectId/connections/pending/received","href":"/v6/api-reference/connections/fetch-received-pending-connections"},{"title":"Accept Connection Request","api":"PATCH /api/v6/:projectId/connections/:connectionId/accept","href":"/v6/api-reference/connections/accept-connection"},{"title":"Decline Connection Request","api":"PATCH /api/v6/:projectId/connections/:connectionId/decline","href":"/v6/api-reference/connections/decline-connection"},{"title":"Remove Connection","api":"DELETE /api/v6/:projectId/connections/:connectionId","href":"/v6/api-reference/connections/remove-connection"}]},{"group":"Entity Endpoints","pages":[{"title":"Create Entity","api":"POST /api/v6/:projectId/entities","href":"/v6/api-reference/entities/create-entity"},{"title":"Get Single Entity","api":"GET /api/v6/:projectId/entities/:entityId","href":"/v6/api-reference/entities/fetch-entity"},{"title":"Get Entity by Foreign ID","api":"GET /api/v6/:projectId/entities/by-foreign-id","href":"/v6/api-reference/entities/fetch-entity-by-foreign-id"},{"title":"Get Entity by Short ID","api":"GET /api/v6/:projectId/entities/by-short-id","href":"/v6/api-reference/entities/fetch-entity-by-short-id"},{"title":"Fetch Entities","api":"GET /api/v6/:projectId/entities","href":"/v6/api-reference/entities/fetch-many-entities"},{"title":"Update Entity","api":"PATCH /api/v6/:projectId/entities/:entityId","href":"/v6/api-reference/entities/update-entity"},{"title":"Upvote Entity","api":"PATCH /api/v6/:projectId/entities/:entityId/upvote","href":"/v6/api-reference/entities/upvote-entity"},{"title":"Downvote Entity","api":"PATCH /api/v6/:projectId/entities/:entityId/downvote","href":"/v6/api-reference/entities/downvote-entity"},{"title":"Remove Upvote from Entity","api":"PATCH /api/v6/:projectId/entities/:entityId/remove-upvote","href":"/v6/api-reference/entities/remove-entity-upvote"},{"title":"Remove Downvote from Entity","api":"PATCH /api/v6/:projectId/entities/:entityId/remove-downvote","href":"/v6/api-reference/entities/remove-entity-downvote"},{"title":"Increment Entity Views","api":"PATCH /api/v6/:projectId/entities/:entityId/increment-views","href":"/v6/api-reference/entities/increment-entity-views"},{"title":"Delete Entity","api":"DELETE /api/v6/:projectId/entities/:entityId","href":"/v6/api-reference/entities/delete-entity"}]},{"group":"Comment Endpoints","pages":[{"title":"Create Comment","api":"POST /api/v6/:projectId/comments","href":"/v6/api-reference/comments/create-comment"},{"title":"Get Comment","api":"GET /api/v6/:projectId/comments/:commentId","href":"/v6/api-reference/comments/fetch-comment"},{"title":"Get Comment by Foreign ID","api":"GET /api/v6/:projectId/comments/by-foreign-id","href":"/v6/api-reference/comments/fetch-comment-by-foreign-id"},{"title":"Get Comments","api":"GET /api/v6/:projectId/comments","href":"/v6/api-reference/comments/fetch-many-comments"},{"title":"Update Comment","api":"PATCH /api/v6/:projectId/comments/:commentId","href":"/v6/api-reference/comments/update-comment"},{"title":"Upvote Comment","api":"PATCH /api/v6/:projectId/comments/:commentId/upvote","href":"/v6/api-reference/comments/upvote-comment"},{"title":"Downvote Comment","api":"PATCH /api/v6/:projectId/comments/:commentId/downvote","href":"/v6/api-reference/comments/downvote-comment"},{"title":"Remove Upvote from Comment","api":"PATCH /api/v6/:projectId/comments/:commentId/remove-upvote","href":"/v6/api-reference/comments/remove-comment-upvote"},{"title":"Remove Downvote from Comment","api":"PATCH /api/v6/:projectId/comments/:commentId/remove-downvote","href":"/v6/api-reference/comments/remove-comment-downvote"},{"title":"Delete Comment","api":"DELETE /api/v6/:projectId/comments/:commentId","href":"/v6/api-reference/comments/delete-comment"}]},{"group":"List Endpoints","pages":[{"title":"Create Sub-List","api":"POST /api/v6/:projectId/lists/:listId/sub-lists","href":"/v6/api-reference/lists/create-new-list"},{"title":"Get Root List","api":"GET /api/v6/:projectId/lists/root","href":"/v6/api-reference/lists/fetch-root-list"},{"title":"Get Sub-Lists","api":"GET /api/v6/:projectId/lists/:listId/sub-lists","href":"/v6/api-reference/lists/fetch-sub-lists"},{"title":"Check if Entity is Saved","api":"GET /api/v6/:projectId/lists/is-entity-saved","href":"/v6/api-reference/lists/is-entity-saved"},{"title":"Update List","api":"PATCH /api/v6/:projectId/lists/:listId","href":"/v6/api-reference/lists/update-list"},{"title":"Add Entity to List","api":"PATCH /api/v6/:projectId/lists/:listId/add-entity","href":"/v6/api-reference/lists/add-entity-to-list"},{"title":"Remove Entity from List","api":"PATCH /api/v6/:projectId/lists/:listId/remove-entity","href":"/v6/api-reference/lists/remove-entity-from-list"},{"title":"Delete List","api":"DELETE /api/v6/:projectId/lists/:listId","href":"/v6/api-reference/lists/delete-list"}]},{"group":"App Notification Endpoints","pages":[{"title":"Get App Notifications","api":"GET /api/v6/:projectId/app-notifications","href":"/v6/api-reference/app-notifications/fetch-notifications"},{"title":"Count Unread Notifications","api":"GET /api/v6/:projectId/app-notifications/count","href":"/v6/api-reference/app-notifications/count-unread-notification"},{"title":"Mark Notification as Read","api":"PATCH /api/v6/:projectId/app-notifications/:notificationId/mark-as-read","href":"/v6/api-reference/app-notifications/mark-notification-as-read"}]},{"group":"Storage Endpoints","pages":[{"title":"Upload File","api":"POST /api/v6/:projectId/storage","href":"/v6/api-reference/storage/upload-file"}]},{"group":"Moderation Endpoints","pages":[{"title":"Submit a Report","api":"POST /api/v6/:projectId/reports","href":"/v6/api-reference/moderation/create-report"}]},{"group":"Crypto Endpoints","pages":[{"title":"Sign Testing JWT","api":"POST /api/v6/:projectId/crypto/sign-testing-jwt","href":"/v6/api-reference/crypto/sign-testing-jwt"}]}]},{"tab":"Data Models","pages":[{"title":"Data Models","href":"/v6/data-models/user"}]}],"global":{"anchors":[{"anchor":"Dashboard","icon":"gauge","href":"https://dash.sublay.io"}]}}]},"basePath":"","title":"Fetch User By Foreign Id - Sublay Documentation","buildId":"dpl_G2Qd45vZZ7MkBiGF9yYx8ZsbbKXX","deploymentId":"dpl_G2Qd45vZZ7MkBiGF9yYx8ZsbbKXX","dynamics":["c2aa737661","2b790eda92","b0f84f53ff"],"chunks":["OpenApiReferenceProvider-NXj-Rqjv.js","utils-m0thOP-_.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-D13EKcfm.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema--XTdfsEb.js","snippetPresets-D3s4lmAH.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","conditional-requirements-CFM0id0Q.js","ApiExamples-ChURybxL.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-DL8CiXq2.js","shallow-DI2-YB2E.js","getApiPlaygroundDisplay-DxbW7b_y.js","CodeSnippet-CiNYS0pP.js","CodeSnippets-BT87bThu.js","Page-DSpdRuhM.js","getPastedJson-F_g_IrFQ.js","icon-CCIG5BAs.js","MethodPill-DY3E0jwx.js","DuplicateIcon-BN88xnEg.js","createIcon-VCCc5HO5.js","DynamicMarkdown-CaSwclgK.js","SectionHeading-DXV8nWhc.js","axios-vUo_bRtp.js"]}