The apiKey property is the API Key for accessing ChainPatrol’s APIs. We
recommend using an environment variable to store your API Key.This property is required when the mode property is set to cloud,
even if proxyUrl is set. Leaving it out throws a Missing API key
error. The key is sent in the X-API-KEY header, so if your proxy adds
the real key on the server, pass any non-empty placeholder here.
The proxyUrl property is an optional property that can be used to
specify a proxy URL for accessing ChainPatrol’s APIs.This property is useful when you are behind a firewall or need to use a
proxy to access the internet.This value is only used when the mode property is set to cloud.
The redirectUrl property is an optional property that can be used to
specify a redirect URL for when the detector detects a scam.By default, the detector will return the ChainPatrol warning page URL,
but you can override this by specifying your own URL.If you specify a string, the string will be used as the redirect URL
with the scam URL appended as the originUrl query parameter:
const detector = new ThreatDetector({ redirectUrl: "https://your-warning-page.com/",});
If you specify a function, the function will be called with the scam URL
as the first argument:
The storage property is an optional property that can be used to
specify a custom storage adapter for the detector to cache URL lookups.By default, the detector will use the Storage.memory() adapter, which
stores the cache database in memory. This means that the database will be
cleared when the process exits. If you want to persist the database, you
can use the Storage.browser() adapter, which stores the database in
local storage, or the Storage.extension() adapter, which stores the database
in the browser’s extension storage.
{"docsConfig":{"theme":"palm","$schema":"https://mintlify.com/docs.json","name":"ChainPatrol","colors":{"primary":"#6622DC","light":"#985EFD","dark":"#2A186B"},"logo":{"light":"https://mintcdn.com/chainpatrol/R_CITzEDbsciFTsn/logo/light.svg?fit=max\u0026auto=format\u0026n=R_CITzEDbsciFTsn\u0026q=85\u0026s=8ca4a8411113008ec8f9a57dec249989","dark":"https://mintcdn.com/chainpatrol/R_CITzEDbsciFTsn/logo/dark.svg?fit=max\u0026auto=format\u0026n=R_CITzEDbsciFTsn\u0026q=85\u0026s=3fba0f7cf94681111da5d1ce52ebf33b","href":"https://chainpatrol.com"},"favicon":"https://mintcdn.com/chainpatrol/R_CITzEDbsciFTsn/favicon.svg?fit=max\u0026auto=format\u0026n=R_CITzEDbsciFTsn\u0026q=85\u0026s=2ee94dcfc07708e2929aad42ea5ab4c5","api":{"openapi":"https://app.chainpatrol.io/api/v2/openapi.json?v=2","mdx":{"auth":{"method":"key","name":"X-API-KEY"},"server":"https://app.chainpatrol.io/api/v2"}},"appearance":{"default":"dark"},"background":{"image":"https://mintcdn.com/chainpatrol/oLEHOzLMXL0CWKrg/background.png?fit=max\u0026auto=format\u0026n=oLEHOzLMXL0CWKrg\u0026q=85\u0026s=562d8e2e01dbe50733cb041efde433a6","color":{"dark":"#060114"}},"navbar":{"links":[{"href":"https://chainpatrol.com/blog","label":"Blog"},{"href":"https://chainpatrol.com/changelog","label":"Changelog"}],"primary":{"type":"button","label":"Dashboard","href":"https://app.chainpatrol.io/"}},"footer":{"socials":{"x":"https://x.com/chainpatrol","linkedin":"https://www.linkedin.com/company/89545915","github":"https://github.com/chainpatrol"}},"fonts":{"heading":{"family":"IBM Plex Sans"},"body":{"family":"Inter"}},"integrations":{"ga4":{"measurementId":"G-QEBBHCD92K"}},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"chainpatrol","hasAudioNarration":false,"actualSubdomain":"chainpatrol","customDomains":["chainpatrol.com"],"gitSource":{"type":"github","owner":"chainpatrol","repo":"docs","deployBranch":"main","contentDirectory":"","mountPath":"","label":""},"feedback":{"thumbs":true,"edits":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6aef6642ff56dc66d2b76831","clientVersion":"0.0.4087","searchFilterCounts":[{"language":"default","tag":"API Reference","count":105},{"language":"default","tag":"Documentation","count":29},{"language":"default","tag":"Integrations","count":24},{"language":"default","tag":"JavaScript SDK","count":22},{"language":"default","tag":"Getting Started","count":20},{"language":"default","tag":"CLI","count":16},{"language":"default","tag":"Concepts","count":14},{"language":"default","tag":"Assets","count":13},{"language":"default","tag":"Threat Detection","count":13},{"language":"default","tag":"Metrics","count":12}]},"assistantConfig":{},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"comment-mode","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[],"page":{"pagePath":"sdk/threat-detector/constructor","slug":"/sdk/threat-detector/constructor","pageMetadata":{"title":"ThreatDetector Constructor","description":"Instantiate a new ThreatDetector with local or cloud mode, an API key, storage adapter, proxy URL, and custom redirect URL for scam URL detection.","href":"/sdk/threat-detector/constructor"},"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: \"Instantiate a new ThreatDetector with local or cloud mode, an API key, storage adapter, proxy URL, and custom redirect URL for scam URL detection.\"\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`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Expandable,Heading,ParamField}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`modes`,children:`Modes`}),`\n`,_jsx(_components.p,{children:`There are two modes of operation for the Threat Detector:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`local`}),`: This mode uses a local database of scam URLs. Use this mode for offline threat detection and testing.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`cloud`}),`: This mode uses ChainPatrol’s cloud service to detect scams.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`local-mode`,children:`Local Mode`}),`\n`,_jsxs(_components.p,{children:[`To use the local mode, you need to instantiate the `,_jsx(_components.code,{children:`ThreatDetector`}),` class with the `,_jsx(_components.code,{children:`mode`}),` option set to `,_jsx(_components.code,{children:`local`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`javascript`,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:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` detector`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` ThreatDetector`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` mode:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"local\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`cloud-mode`,children:`Cloud Mode`}),`\n`,_jsxs(_components.p,{children:[`To use the cloud mode, you need to instantiate the `,_jsx(_components.code,{children:`ThreatDetector`}),` class with the `,_jsx(_components.code,{children:`mode`}),` option set to `,_jsx(_components.code,{children:`cloud`}),` and provide your API key.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`javascript`,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:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` detector`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` ThreatDetector`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` mode:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"cloud\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` apiKey:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"YOUR_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`parameters`,children:`Parameters`}),`\n`,_jsx(ParamField,{body:`options`,type:`object`,required:true,id:`param-options`,children:_jsxs(Expandable,{title:`properties`,defaultOpen:true,children:[_jsxs(ParamField,{body:`mode`,type:`'local' | 'cloud'`,required:true,id:`param-mode`,children:[_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`mode`}),` property controls the mode of operation for the Threat Detector.`]}),_jsxs(_components.p,{children:[`The value of this property can be either `,_jsx(_components.code,{children:`local`}),` or `,_jsx(_components.code,{children:`cloud`}),`.`]})]}),_jsxs(ParamField,{body:`apiKey`,type:`string`,id:`param-api-key`,children:[_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`apiKey`}),` property is the API Key for accessing ChainPatrol’s APIs. We\nrecommend using an environment variable to store your API Key.`]}),_jsxs(_components.p,{children:[`This property is required when the `,_jsx(_components.code,{children:`mode`}),` property is set to `,_jsx(_components.code,{children:`cloud`}),`,\neven if `,_jsx(_components.code,{children:`proxyUrl`}),` is set. Leaving it out throws a `,_jsx(_components.code,{children:`Missing API key`}),`\nerror. The key is sent in the `,_jsx(_components.code,{children:`X-API-KEY`}),` header, so if your proxy adds\nthe real key on the server, pass any non-empty placeholder here.`]})]}),_jsxs(ParamField,{body:`proxyUrl`,type:`string`,id:`param-proxy-url`,children:[_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`proxyUrl`}),` property is an optional property that can be used to\nspecify a proxy URL for accessing ChainPatrol’s APIs.`]}),_jsx(_components.p,{children:`This property is useful when you are behind a firewall or need to use a\nproxy to access the internet.`}),_jsxs(_components.p,{children:[`This value is only used when the `,_jsx(_components.code,{children:`mode`}),` property is set to `,_jsx(_components.code,{children:`cloud`}),`.`]})]}),_jsxs(ParamField,{body:`redirectUrl`,type:`string | (url: string) => string`,id:`param-redirect-url`,children:[_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`redirectUrl`}),` property is an optional property that can be used to\nspecify a redirect URL for when the detector detects a scam.`]}),_jsx(_components.p,{children:`By default, the detector will return the ChainPatrol warning page URL,\nbut you can override this by specifying your own URL.`}),_jsxs(_components.p,{children:[`If you specify a `,_jsx(_components.strong,{children:`string`}),`, the string will be used as the redirect URL\nwith the scam URL appended as the `,_jsx(_components.code,{children:`originUrl`}),` query parameter:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`javascript`,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:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` detector`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` ThreatDetector`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` redirectUrl:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://your-warning-page.com/\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),_jsxs(_components.p,{children:[`If you specify a `,_jsx(_components.strong,{children:`function`}),`, the function will be called with the scam URL\nas the first argument:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`javascript`,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:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` detector`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` ThreatDetector`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` redirectUrl`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`url`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `https://your-warning-page.com/?url=\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`encodeURIComponent`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`url`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`)`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})})]}),_jsxs(ParamField,{body:`storage`,type:`Storage`,id:`param-storage`,children:[_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`storage`}),` property is an optional property that can be used to\nspecify a custom storage adapter for the detector to cache URL lookups.`]}),_jsxs(_components.p,{children:[`By default, the detector will use the `,_jsx(_components.code,{children:`Storage.memory()`}),` adapter, which\nstores the cache database in memory. This means that the database will be\ncleared when the process exits. If you want to persist the database, you\ncan use the `,_jsx(_components.code,{children:`Storage.browser()`}),` adapter, which stores the database in\nlocal storage, or the `,_jsx(_components.code,{children:`Storage.extension()`}),` adapter, which stores the database\nin the browser’s extension storage.`]})]})]})})]})}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":"ThreatDetector Constructor","description":"Instantiate a new ThreatDetector with local or cloud mode, an API key, storage adapter, proxy URL, and custom redirect URL for scam URL detection.","href":"/sdk/threat-detector/constructor"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Modes","slug":"modes","depth":2,"children":[{"title":"Local Mode","slug":"local-mode","depth":3,"children":[]},{"title":"Cloud Mode","slug":"cloud-mode","depth":3,"children":[]}]},{"title":"Parameters","slug":"parameters","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"chainpatrol","siteName":"ChainPatrol","title":"ThreatDetector Constructor - ChainPatrol","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-07T17:56:16.010Z","originalFileLocation":"sdk/threat-detector/constructor.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=\"dark\"}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=\"Instantiate a new ThreatDetector with local or cloud mode, an API key, storage adapter, proxy URL, and custom redirect URL for scam URL detection.\">\u003cmeta data-mint-head name=\"application-name\" content=\"ChainPatrol\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/chainpatrol/NioFQGDQy3PBOTVO/_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=\"/docs/mintlify-assets/_mintlify/favicons/chainpatrol/NioFQGDQy3PBOTVO/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/chainpatrol/NioFQGDQy3PBOTVO/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/chainpatrol/NioFQGDQy3PBOTVO/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/chainpatrol/NioFQGDQy3PBOTVO/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/chainpatrol/NioFQGDQy3PBOTVO/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/chainpatrol/NioFQGDQy3PBOTVO/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/chainpatrol/NioFQGDQy3PBOTVO/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/chainpatrol/NioFQGDQy3PBOTVO/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"ThreatDetector Constructor - ChainPatrol\">\u003cmeta data-mint-head property=\"og:description\" content=\"Instantiate a new ThreatDetector with local or cloud mode, an API key, storage adapter, proxy URL, and custom redirect URL for scam URL detection.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"ChainPatrol\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://chainpatrol.com/docs/sdk/threat-detector/constructor\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://chainpatrol.mintlify.site/docs/_mintlify/api/og/v2?division=ThreatDetector\u0026amp;title=ThreatDetector+Constructor\u0026amp;description=Instantiate+a+new+ThreatDetector+with+local+or+cloud+mode%2C+an+API+key%2C+storage+adapter%2C+proxy+URL%2C+and+custom+redirect+URL+for+scam+URL+detection.\u0026amp;theme=1a8d7dd79d865cbc4c2f5879\u0026amp;signature=ed0003c229fdc735f8dfb4960418335a78d79fb9e92ff153cb0887a4458608e1\">\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=\"ThreatDetector Constructor - ChainPatrol\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Instantiate a new ThreatDetector with local or cloud mode, an API key, storage adapter, proxy URL, and custom redirect URL for scam URL detection.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://chainpatrol.mintlify.site/docs/_mintlify/api/og/v2?division=ThreatDetector\u0026amp;title=ThreatDetector+Constructor\u0026amp;description=Instantiate+a+new+ThreatDetector+with+local+or+cloud+mode%2C+an+API+key%2C+storage+adapter%2C+proxy+URL%2C+and+custom+redirect+URL+for+scam+URL+detection.\u0026amp;theme=1a8d7dd79d865cbc4c2f5879\u0026amp;signature=ed0003c229fdc735f8dfb4960418335a78d79fb9e92ff153cb0887a4458608e1\">\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=\"/docs/mintlify-assets/_mintlify/favicons/chainpatrol/NioFQGDQy3PBOTVO/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"ChainPatrol\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#6622DC\">\u003clink data-mint-head rel=\"canonical\" href=\"https://chainpatrol.com/docs/sdk/threat-detector/constructor\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/sdk/threat-detector/constructor.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://chainpatrol.com/#organization\",\"name\":\"ChainPatrol\",\"url\":\"https://chainpatrol.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/chainpatrol/R_CITzEDbsciFTsn/logo/light.svg?fit=max\u0026auto=format\u0026n=R_CITzEDbsciFTsn\u0026q=85\u0026s=8ca4a8411113008ec8f9a57dec249989\"}},{\"@type\":\"WebSite\",\"@id\":\"https://chainpatrol.com/docs#website\",\"name\":\"ChainPatrol\",\"url\":\"https://chainpatrol.com/docs\",\"publisher\":{\"@id\":\"https://chainpatrol.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://chainpatrol.com/docs/sdk/threat-detector/constructor#webpage\",\"url\":\"https://chainpatrol.com/docs/sdk/threat-detector/constructor\",\"name\":\"ThreatDetector Constructor\",\"description\":\"Instantiate a new ThreatDetector with local or cloud mode, an API key, storage adapter, proxy URL, and custom redirect URL for scam URL detection.\",\"dateModified\":\"2026-11-07T17:56:16.010Z\",\"isPartOf\":{\"@id\":\"https://chainpatrol.com/docs#website\"},\"breadcrumb\":{\"@id\":\"https://chainpatrol.com/docs/sdk/threat-detector/constructor#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://chainpatrol.com/docs/sdk/threat-detector/constructor#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"API Reference\",\"item\":\"https://chainpatrol.com/docs/sdk/threat-detector/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ThreatDetector\",\"item\":\"https://chainpatrol.com/docs/sdk/threat-detector/overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"ThreatDetector Constructor\",\"item\":\"https://chainpatrol.com/docs/sdk/threat-detector/constructor\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://chainpatrol.com/docs/sdk/threat-detector/constructor#article\",\"headline\":\"ThreatDetector Constructor\",\"name\":\"ThreatDetector Constructor\",\"description\":\"Instantiate a new ThreatDetector with local or cloud mode, an API key, storage adapter, proxy URL, and custom redirect URL for scam URL detection.\",\"url\":\"https://chainpatrol.com/docs/sdk/threat-detector/constructor\",\"mainEntityOfPage\":{\"@id\":\"https://chainpatrol.com/docs/sdk/threat-detector/constructor#webpage\"},\"dateModified\":\"2026-11-07T17:56:16.010Z\",\"publisher\":{\"@id\":\"https://chainpatrol.com/#organization\"},\"isPartOf\":{\"@id\":\"https://chainpatrol.com/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"ChainPatrol\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"ChainPatrol","nav":{"global":null,"tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":"/getting-started/what-we-do/introduction"}]},{"tab":"Integrations","pages":[{"title":"Integrations","href":"/integration/discord"}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/external-api/overview"}]},{"tab":"CLI","pages":[{"title":"CLI","href":"/cli/overview"}]},{"tab":"JavaScript SDK","groups":[{"group":"@chainpatrol/sdk","pages":[{"title":"ChainPatrol JavaScript SDK Overview","href":"/sdk/overview"},{"title":"ChainPatrol SDK Quickstart","href":"/sdk/quickstart"}]},{"group":"API Reference","pages":[{"group":"ThreatDetector","pages":[{"title":"ThreatDetector Class Overview","description":"The ThreatDetector class wraps ChainPatrol's phishing and scam detection APIs with caching, storage adapters, and URL checks for security-conscious apps.","href":"/sdk/threat-detector/overview"},{"title":"ThreatDetector Constructor","href":"/sdk/threat-detector/constructor"},{"group":"Instance methods","pages":[{"title":"url()","description":"Check whether a URL is a phishing or scam site with ThreatDetector.url(), returning an ALLOWED, BLOCKED, UNKNOWN or IGNORED status plus an optional redirectUrl.","href":"/sdk/threat-detector/instance-methods/url"},{"title":"allow()","href":"/sdk/threat-detector/instance-methods/allow"},{"title":"block()","href":"/sdk/threat-detector/instance-methods/block"},{"title":"ignore()","href":"/sdk/threat-detector/instance-methods/ignore"}]}]},{"group":"Storage","pages":[{"title":"Storage Adapters for ThreatDetector Caching","href":"/sdk/storage/overview"},{"title":"Browser","href":"/sdk/storage/browser"},{"title":"Extension","href":"/sdk/storage/extension"},{"title":"Memory","href":"/sdk/storage/memory"}]},{"group":"Relay","pages":[{"title":"Relay Class for Warning-Page Events","href":"/sdk/relay/overview"},{"group":"Static methods","pages":[{"title":"send()","href":"/sdk/relay/static-methods/send"},{"title":"run()","href":"/sdk/relay/static-methods/run"},{"title":"on()","href":"/sdk/relay/static-methods/on"}]}]},{"group":"ChainPatrolClient","pages":[{"title":"ChainPatrolClient Overview","href":"/sdk/chainpatrol-client/overview"},{"title":"ChainPatrolClient Constructor","href":"/sdk/chainpatrol-client/constructor"},{"group":"Instance methods","pages":[{"title":"asset.check","href":"/sdk/chainpatrol-client/instance-methods/asset-check"},{"title":"asset.list","href":"/sdk/chainpatrol-client/instance-methods/asset-list"},{"title":"asset.submit","href":"/sdk/chainpatrol-client/instance-methods/asset-submit"},{"title":"report.create","href":"/sdk/chainpatrol-client/instance-methods/report-create"}]}]}]}]},{"tab":"Glossary","pages":[{"title":"Glossary","href":"/glossary/overview"}]}]},"basePath":"","title":"ThreatDetector Constructor - ChainPatrol","buildId":"dpl_BSPUBxEoKhhK7HzXVDPxdPvWx4xc","deploymentId":"dpl_BSPUBxEoKhhK7HzXVDPxdPvWx4xc","dynamics":[],"chunks":[]}