Skip to main content

Class: CortexFunctionInstance

A live function object. Every field from the API response is available directly on the object (e.g. fn.name, fn.slug), and the object also exposes action methods (publish(), deploy(), stop(), …).

Named CortexFunctionInstance to avoid shadowing the global Function type.

Extends

Constructors

new CortexFunctionInstance()

new CortexFunctionInstance(
ctx,
_projectId,
data): CortexFunctionInstance

Internal

Parameters

ParameterTypeDescription
ctxClientContext-
_projectIdstring-
dataobject-
data.activeDeployment?objectDeprecated Description Active deployment info (deprecated - use status field instead)
data.activeDeployment.createdAtstringFormat: date-time Description Creation timestamp
data.activeDeployment.fleetDeploymentId?stringDescription Fleet deployment ID
data.activeDeployment.fleetServiceId?stringDescription Fleet service ID
data.activeDeployment.functionIdstringDescription Function ID
data.activeDeployment.idstringDescription Deployment UUID
data.activeDeployment.invokeUrl?stringDescription Invoke URL (external via Cortex proxy)
data.activeDeployment.lastError?stringDescription Last error message
data.activeDeployment.lastInvokedAt?stringFormat: date-time Description Last invocation timestamp
data.activeDeployment.requestCountnumberDescription Total request count Example 0
data.activeDeployment.serviceIp?stringDescription Service IP address (internal)
data.activeDeployment.servicePort?numberDescription Service port (internal)
data.activeDeployment.status| "pending" | "failed" | "running" | "stopped" | "deploying"Description Deployment status
data.activeDeployment.updatedAtstringFormat: date-time Description Last update timestamp
data.activeDeployment.versionIdstringDescription Deployed version ID
data.authMode"api_key" | "public" | "signed"Description Authentication mode
data.createdAtstringFormat: date-time Description Creation timestamp
data.description?stringDescription Function description
data.draftCodestringDescription Draft source code
data.draftEntrypointstringDescription Entrypoint function name Example handler
data.envVarsobject[]Description Environment variables (secrets masked)
data.idstringDescription Function UUID
data.memorynumberDescription Memory limit in MB Example 256
data.namestringDescription Function name Example process-webhook
data.projectIdstringDescription Project ID
data.publishedVersionId?stringDescription Published version ID (if published)
data.runtime"nodejs20" | "nodejs22"Description Runtime environment
data.slugstringDescription URL-friendly identifier Example process-webhook
data.status"draft" | "published"Description Function status: draft (not published) or published (available in runtime)
data.tenantIdstringDescription Tenant ID
data.timeoutnumberDescription Execution timeout in milliseconds Example 30000
data.updatedAtstringFormat: date-time Description Last update timestamp

Returns

CortexFunctionInstance

Inherited from

CortexFunction.constructor

Defined in

4Players/cortex-typescript-sdk/src/resources/functions.ts:322

Properties

PropertyTypeDescriptionInherited fromDefined in
activeDeployment?objectDeprecated Description Active deployment info (deprecated - use status field instead)CortexFunction.activeDeployment4Players/cortex-typescript-sdk/src/types.ts:4972
activeDeployment.createdAtstringFormat: date-time Description Creation timestamp-4Players/cortex-typescript-sdk/src/types.ts:4906
activeDeployment.fleetDeploymentId?stringDescription Fleet deployment ID-4Players/cortex-typescript-sdk/src/types.ts:4883
activeDeployment.fleetServiceId?stringDescription Fleet service ID-4Players/cortex-typescript-sdk/src/types.ts:4881
activeDeployment.functionIdstringDescription Function ID-4Players/cortex-typescript-sdk/src/types.ts:4872
activeDeployment.idstringDescription Deployment UUID-4Players/cortex-typescript-sdk/src/types.ts:4870
activeDeployment.invokeUrl?stringDescription Invoke URL (external via Cortex proxy)-4Players/cortex-typescript-sdk/src/types.ts:4889
activeDeployment.lastError?stringDescription Last error message-4Players/cortex-typescript-sdk/src/types.ts:4891
activeDeployment.lastInvokedAt?stringFormat: date-time Description Last invocation timestamp-4Players/cortex-typescript-sdk/src/types.ts:4901
activeDeployment.requestCountnumberDescription Total request count Example 0-4Players/cortex-typescript-sdk/src/types.ts:4896
activeDeployment.serviceIp?stringDescription Service IP address (internal)-4Players/cortex-typescript-sdk/src/types.ts:4885
activeDeployment.servicePort?numberDescription Service port (internal)-4Players/cortex-typescript-sdk/src/types.ts:4887
activeDeployment.status| "pending" | "failed" | "running" | "stopped" | "deploying"Description Deployment status-4Players/cortex-typescript-sdk/src/types.ts:4879
activeDeployment.updatedAtstringFormat: date-time Description Last update timestamp-4Players/cortex-typescript-sdk/src/types.ts:4911
activeDeployment.versionIdstringDescription Deployed version ID-4Players/cortex-typescript-sdk/src/types.ts:4874
authMode"api_key" | "public" | "signed"Description Authentication modeCortexFunction.authMode4Players/cortex-typescript-sdk/src/types.ts:4948
createdAtstringFormat: date-time Description Creation timestampCortexFunction.createdAt4Players/cortex-typescript-sdk/src/types.ts:4977
description?stringDescription Function descriptionCortexFunction.description4Players/cortex-typescript-sdk/src/types.ts:4931
draftCodestringDescription Draft source codeCortexFunction.draftCode4Players/cortex-typescript-sdk/src/types.ts:4933
draftEntrypointstringDescription Entrypoint function name Example handlerCortexFunction.draftEntrypoint4Players/cortex-typescript-sdk/src/types.ts:4938
envVarsobject[]Description Environment variables (secrets masked)CortexFunction.envVars4Players/cortex-typescript-sdk/src/types.ts:4960
idstringDescription Function UUIDCortexFunction.id4Players/cortex-typescript-sdk/src/types.ts:4915
memorynumberDescription Memory limit in MB Example 256CortexFunction.memory4Players/cortex-typescript-sdk/src/types.ts:4958
namestringDescription Function name Example process-webhookCortexFunction.name4Players/cortex-typescript-sdk/src/types.ts:4924
projectIdstringDescription Project IDCortexFunction.projectId4Players/cortex-typescript-sdk/src/types.ts:4919
publishedVersionId?stringDescription Published version ID (if published)CortexFunction.publishedVersionId4Players/cortex-typescript-sdk/src/types.ts:4962
runtime"nodejs20" | "nodejs22"Description Runtime environmentCortexFunction.runtime4Players/cortex-typescript-sdk/src/types.ts:4943
slugstringDescription URL-friendly identifier Example process-webhookCortexFunction.slug4Players/cortex-typescript-sdk/src/types.ts:4929
status"draft" | "published"Description Function status: draft (not published) or published (available in runtime)CortexFunction.status4Players/cortex-typescript-sdk/src/types.ts:4967
tenantIdstringDescription Tenant IDCortexFunction.tenantId4Players/cortex-typescript-sdk/src/types.ts:4917
timeoutnumberDescription Execution timeout in milliseconds Example 30000CortexFunction.timeout4Players/cortex-typescript-sdk/src/types.ts:4953
updatedAtstringFormat: date-time Description Last update timestampCortexFunction.updatedAt4Players/cortex-typescript-sdk/src/types.ts:4982

Accessors

data

get data(): object

The raw API response object.

Deprecated

The response fields are now available directly on this object (e.g. fn.name instead of fn.data.name). This accessor will be removed before the stable release.

Returns

object

NameTypeDescriptionDefined in
activeDeployment?objectDeprecated Description Active deployment info (deprecated - use status field instead)4Players/cortex-typescript-sdk/src/types.ts:4972
activeDeployment.createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4906
activeDeployment.fleetDeploymentId?stringDescription Fleet deployment ID4Players/cortex-typescript-sdk/src/types.ts:4883
activeDeployment.fleetServiceId?stringDescription Fleet service ID4Players/cortex-typescript-sdk/src/types.ts:4881
activeDeployment.functionIdstringDescription Function ID4Players/cortex-typescript-sdk/src/types.ts:4872
activeDeployment.idstringDescription Deployment UUID4Players/cortex-typescript-sdk/src/types.ts:4870
activeDeployment.invokeUrl?stringDescription Invoke URL (external via Cortex proxy)4Players/cortex-typescript-sdk/src/types.ts:4889
activeDeployment.lastError?stringDescription Last error message4Players/cortex-typescript-sdk/src/types.ts:4891
activeDeployment.lastInvokedAt?stringFormat: date-time Description Last invocation timestamp4Players/cortex-typescript-sdk/src/types.ts:4901
activeDeployment.requestCountnumberDescription Total request count Example 04Players/cortex-typescript-sdk/src/types.ts:4896
activeDeployment.serviceIp?stringDescription Service IP address (internal)4Players/cortex-typescript-sdk/src/types.ts:4885
activeDeployment.servicePort?numberDescription Service port (internal)4Players/cortex-typescript-sdk/src/types.ts:4887
activeDeployment.status| "pending" | "failed" | "running" | "stopped" | "deploying"Description Deployment status4Players/cortex-typescript-sdk/src/types.ts:4879
activeDeployment.updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:4911
activeDeployment.versionIdstringDescription Deployed version ID4Players/cortex-typescript-sdk/src/types.ts:4874
authMode"api_key" | "public" | "signed"Description Authentication mode4Players/cortex-typescript-sdk/src/types.ts:4948
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4977
description?stringDescription Function description4Players/cortex-typescript-sdk/src/types.ts:4931
draftCodestringDescription Draft source code4Players/cortex-typescript-sdk/src/types.ts:4933
draftEntrypointstringDescription Entrypoint function name Example handler4Players/cortex-typescript-sdk/src/types.ts:4938
envVarsobject[]Description Environment variables (secrets masked)4Players/cortex-typescript-sdk/src/types.ts:4960
idstringDescription Function UUID4Players/cortex-typescript-sdk/src/types.ts:4915
memorynumberDescription Memory limit in MB Example 2564Players/cortex-typescript-sdk/src/types.ts:4958
namestringDescription Function name Example process-webhook4Players/cortex-typescript-sdk/src/types.ts:4924
projectIdstringDescription Project ID4Players/cortex-typescript-sdk/src/types.ts:4919
publishedVersionId?stringDescription Published version ID (if published)4Players/cortex-typescript-sdk/src/types.ts:4962
runtime"nodejs20" | "nodejs22"Description Runtime environment4Players/cortex-typescript-sdk/src/types.ts:4943
slugstringDescription URL-friendly identifier Example process-webhook4Players/cortex-typescript-sdk/src/types.ts:4929
status"draft" | "published"Description Function status: draft (not published) or published (available in runtime)4Players/cortex-typescript-sdk/src/types.ts:4967
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:4917
timeoutnumberDescription Execution timeout in milliseconds Example 300004Players/cortex-typescript-sdk/src/types.ts:4953
updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:4982

Defined in

4Players/cortex-typescript-sdk/src/resources/functions.ts:334

Methods

delete()

delete(): Promise<object>

Delete this function and all its versions

Returns

Promise<object>

Deletion confirmation

NameTypeDescriptionDefined in
messagestringDescription Status message Example Function deleted successfully4Players/cortex-typescript-sdk/src/types.ts:5063

Defined in

4Players/cortex-typescript-sdk/src/resources/functions.ts:356


deploy()

deploy(): Promise<object>

Deploy this function to Fleet

Returns

Promise<object>

Deployment details with invoke URL

NameTypeDescriptionDefined in
deploymentobjectDescription The deployment4Players/cortex-typescript-sdk/src/types.ts:5122
deployment.createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4906
deployment.fleetDeploymentId?stringDescription Fleet deployment ID4Players/cortex-typescript-sdk/src/types.ts:4883
deployment.fleetServiceId?stringDescription Fleet service ID4Players/cortex-typescript-sdk/src/types.ts:4881
deployment.functionIdstringDescription Function ID4Players/cortex-typescript-sdk/src/types.ts:4872
deployment.idstringDescription Deployment UUID4Players/cortex-typescript-sdk/src/types.ts:4870
deployment.invokeUrl?stringDescription Invoke URL (external via Cortex proxy)4Players/cortex-typescript-sdk/src/types.ts:4889
deployment.lastError?stringDescription Last error message4Players/cortex-typescript-sdk/src/types.ts:4891
deployment.lastInvokedAt?stringFormat: date-time Description Last invocation timestamp4Players/cortex-typescript-sdk/src/types.ts:4901
deployment.requestCountnumberDescription Total request count Example 04Players/cortex-typescript-sdk/src/types.ts:4896
deployment.serviceIp?stringDescription Service IP address (internal)4Players/cortex-typescript-sdk/src/types.ts:4885
deployment.servicePort?numberDescription Service port (internal)4Players/cortex-typescript-sdk/src/types.ts:4887
deployment.status| "pending" | "failed" | "running" | "stopped" | "deploying"Description Deployment status4Players/cortex-typescript-sdk/src/types.ts:4879
deployment.updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:4911
deployment.versionIdstringDescription Deployed version ID4Players/cortex-typescript-sdk/src/types.ts:4874
invokeUrlstringDescription Public invoke URL Example https://ots.odin.4players.io/invoke/proj123/my-function4Players/cortex-typescript-sdk/src/types.ts:5127
messagestringDescription Status message Example Deployment started4Players/cortex-typescript-sdk/src/types.ts:5132

Defined in

4Players/cortex-typescript-sdk/src/resources/functions.ts:396


listVersions()

listVersions(): Promise<object[]>

List published versions of this function

Returns

Promise<object[]>

Array of function versions

Defined in

4Players/cortex-typescript-sdk/src/resources/functions.ts:369


publish()

publish(body): Promise<object>

Publish a version of this function

Parameters

ParameterTypeDescription
bodyobjectPublish payload (optional changelog)
body.changelog?stringDescription Changelog/description of changes

Returns

Promise<object>

Published version with message

NameTypeDescriptionDefined in
messagestringDescription Status message Example Version 1 published successfully4Players/cortex-typescript-sdk/src/types.ts:5118
versionobjectDescription The published version4Players/cortex-typescript-sdk/src/types.ts:5113
version.buildError?stringDescription Build error message4Players/cortex-typescript-sdk/src/types.ts:5087
version.buildLogs?stringDescription Build logs output4Players/cortex-typescript-sdk/src/types.ts:5085
version.changelog?stringDescription Changelog description4Players/cortex-typescript-sdk/src/types.ts:5100
version.codestringDescription Source code (frozen)4Players/cortex-typescript-sdk/src/types.ts:5076
version.createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:5105
version.entrypointstringDescription Entrypoint function name4Players/cortex-typescript-sdk/src/types.ts:5078
version.functionIdstringDescription Function ID4Players/cortex-typescript-sdk/src/types.ts:5069
version.idstringDescription Version UUID4Players/cortex-typescript-sdk/src/types.ts:5067
version.memorynumberDescription Memory limit in MB4Players/cortex-typescript-sdk/src/types.ts:5096
version.publishedBy?stringDescription User who published this version4Players/cortex-typescript-sdk/src/types.ts:5098
version.runtime"nodejs20" | "nodejs22"Description Runtime environment4Players/cortex-typescript-sdk/src/types.ts:5092
version.status"failed" | "ready" | "building"Description Build status4Players/cortex-typescript-sdk/src/types.ts:5083
version.timeoutnumberDescription Execution timeout in ms4Players/cortex-typescript-sdk/src/types.ts:5094
version.versionnumberDescription Version number Example 14Players/cortex-typescript-sdk/src/types.ts:5074

Defined in

4Players/cortex-typescript-sdk/src/resources/functions.ts:383


stop()

stop(): Promise<object>

Stop this function's deployment

Returns

Promise<object>

Stop confirmation

NameTypeDescriptionDefined in
messagestringDescription Status message Example Function stopped successfully4Players/cortex-typescript-sdk/src/types.ts:5139

Defined in

4Players/cortex-typescript-sdk/src/resources/functions.ts:409


update()

update(body): Promise<object>

Update this function's draft code and configuration

Parameters

ParameterTypeDescription
bodyobjectUpdated function data
body.authMode?"api_key" | "public" | "signed"Description Authentication mode
body.description?stringDescription Function description
body.draftCode?stringDescription Draft source code
body.draftEntrypoint?stringDescription Entrypoint function name
body.envVars?object[]Description Updated environment variables (replaces all)
body.memory?numberDescription Memory limit in MB (128-1024)
body.name?stringDescription Function name
body.runtime?"nodejs20" | "nodejs22"Description Runtime environment
body.timeout?numberDescription Execution timeout in ms (1000-300000)

Returns

Promise<object>

Updated function

NameTypeDescriptionDefined in
activeDeployment?objectDeprecated Description Active deployment info (deprecated - use status field instead)4Players/cortex-typescript-sdk/src/types.ts:4972
activeDeployment.createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4906
activeDeployment.fleetDeploymentId?stringDescription Fleet deployment ID4Players/cortex-typescript-sdk/src/types.ts:4883
activeDeployment.fleetServiceId?stringDescription Fleet service ID4Players/cortex-typescript-sdk/src/types.ts:4881
activeDeployment.functionIdstringDescription Function ID4Players/cortex-typescript-sdk/src/types.ts:4872
activeDeployment.idstringDescription Deployment UUID4Players/cortex-typescript-sdk/src/types.ts:4870
activeDeployment.invokeUrl?stringDescription Invoke URL (external via Cortex proxy)4Players/cortex-typescript-sdk/src/types.ts:4889
activeDeployment.lastError?stringDescription Last error message4Players/cortex-typescript-sdk/src/types.ts:4891
activeDeployment.lastInvokedAt?stringFormat: date-time Description Last invocation timestamp4Players/cortex-typescript-sdk/src/types.ts:4901
activeDeployment.requestCountnumberDescription Total request count Example 04Players/cortex-typescript-sdk/src/types.ts:4896
activeDeployment.serviceIp?stringDescription Service IP address (internal)4Players/cortex-typescript-sdk/src/types.ts:4885
activeDeployment.servicePort?numberDescription Service port (internal)4Players/cortex-typescript-sdk/src/types.ts:4887
activeDeployment.status| "pending" | "failed" | "running" | "stopped" | "deploying"Description Deployment status4Players/cortex-typescript-sdk/src/types.ts:4879
activeDeployment.updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:4911
activeDeployment.versionIdstringDescription Deployed version ID4Players/cortex-typescript-sdk/src/types.ts:4874
authMode"api_key" | "public" | "signed"Description Authentication mode4Players/cortex-typescript-sdk/src/types.ts:4948
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4977
description?stringDescription Function description4Players/cortex-typescript-sdk/src/types.ts:4931
draftCodestringDescription Draft source code4Players/cortex-typescript-sdk/src/types.ts:4933
draftEntrypointstringDescription Entrypoint function name Example handler4Players/cortex-typescript-sdk/src/types.ts:4938
envVarsobject[]Description Environment variables (secrets masked)4Players/cortex-typescript-sdk/src/types.ts:4960
idstringDescription Function UUID4Players/cortex-typescript-sdk/src/types.ts:4915
memorynumberDescription Memory limit in MB Example 2564Players/cortex-typescript-sdk/src/types.ts:4958
namestringDescription Function name Example process-webhook4Players/cortex-typescript-sdk/src/types.ts:4924
projectIdstringDescription Project ID4Players/cortex-typescript-sdk/src/types.ts:4919
publishedVersionId?stringDescription Published version ID (if published)4Players/cortex-typescript-sdk/src/types.ts:4962
runtime"nodejs20" | "nodejs22"Description Runtime environment4Players/cortex-typescript-sdk/src/types.ts:4943
slugstringDescription URL-friendly identifier Example process-webhook4Players/cortex-typescript-sdk/src/types.ts:4929
status"draft" | "published"Description Function status: draft (not published) or published (available in runtime)4Players/cortex-typescript-sdk/src/types.ts:4967
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:4917
timeoutnumberDescription Execution timeout in milliseconds Example 300004Players/cortex-typescript-sdk/src/types.ts:4953
updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:4982

Defined in

4Players/cortex-typescript-sdk/src/resources/functions.ts:343