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:4594
activeDeployment.createdAtstringFormat: date-time Description Creation timestamp-4Players/cortex-typescript-sdk/src/types.ts:4528
activeDeployment.fleetDeploymentId?stringDescription Fleet deployment ID-4Players/cortex-typescript-sdk/src/types.ts:4505
activeDeployment.fleetServiceId?stringDescription Fleet service ID-4Players/cortex-typescript-sdk/src/types.ts:4503
activeDeployment.functionIdstringDescription Function ID-4Players/cortex-typescript-sdk/src/types.ts:4494
activeDeployment.idstringDescription Deployment UUID-4Players/cortex-typescript-sdk/src/types.ts:4492
activeDeployment.invokeUrl?stringDescription Invoke URL (external via Cortex proxy)-4Players/cortex-typescript-sdk/src/types.ts:4511
activeDeployment.lastError?stringDescription Last error message-4Players/cortex-typescript-sdk/src/types.ts:4513
activeDeployment.lastInvokedAt?stringFormat: date-time Description Last invocation timestamp-4Players/cortex-typescript-sdk/src/types.ts:4523
activeDeployment.requestCountnumberDescription Total request count Example 0-4Players/cortex-typescript-sdk/src/types.ts:4518
activeDeployment.serviceIp?stringDescription Service IP address (internal)-4Players/cortex-typescript-sdk/src/types.ts:4507
activeDeployment.servicePort?numberDescription Service port (internal)-4Players/cortex-typescript-sdk/src/types.ts:4509
activeDeployment.status| "pending" | "failed" | "running" | "stopped" | "deploying"Description Deployment status-4Players/cortex-typescript-sdk/src/types.ts:4501
activeDeployment.updatedAtstringFormat: date-time Description Last update timestamp-4Players/cortex-typescript-sdk/src/types.ts:4533
activeDeployment.versionIdstringDescription Deployed version ID-4Players/cortex-typescript-sdk/src/types.ts:4496
authMode"api_key" | "public" | "signed"Description Authentication modeCortexFunction.authMode4Players/cortex-typescript-sdk/src/types.ts:4570
createdAtstringFormat: date-time Description Creation timestampCortexFunction.createdAt4Players/cortex-typescript-sdk/src/types.ts:4599
description?stringDescription Function descriptionCortexFunction.description4Players/cortex-typescript-sdk/src/types.ts:4553
draftCodestringDescription Draft source codeCortexFunction.draftCode4Players/cortex-typescript-sdk/src/types.ts:4555
draftEntrypointstringDescription Entrypoint function name Example handlerCortexFunction.draftEntrypoint4Players/cortex-typescript-sdk/src/types.ts:4560
envVarsobject[]Description Environment variables (secrets masked)CortexFunction.envVars4Players/cortex-typescript-sdk/src/types.ts:4582
idstringDescription Function UUIDCortexFunction.id4Players/cortex-typescript-sdk/src/types.ts:4537
memorynumberDescription Memory limit in MB Example 256CortexFunction.memory4Players/cortex-typescript-sdk/src/types.ts:4580
namestringDescription Function name Example process-webhookCortexFunction.name4Players/cortex-typescript-sdk/src/types.ts:4546
projectIdstringDescription Project IDCortexFunction.projectId4Players/cortex-typescript-sdk/src/types.ts:4541
publishedVersionId?stringDescription Published version ID (if published)CortexFunction.publishedVersionId4Players/cortex-typescript-sdk/src/types.ts:4584
runtime"nodejs20" | "nodejs22"Description Runtime environmentCortexFunction.runtime4Players/cortex-typescript-sdk/src/types.ts:4565
slugstringDescription URL-friendly identifier Example process-webhookCortexFunction.slug4Players/cortex-typescript-sdk/src/types.ts:4551
status"draft" | "published"Description Function status: draft (not published) or published (available in runtime)CortexFunction.status4Players/cortex-typescript-sdk/src/types.ts:4589
tenantIdstringDescription Tenant IDCortexFunction.tenantId4Players/cortex-typescript-sdk/src/types.ts:4539
timeoutnumberDescription Execution timeout in milliseconds Example 30000CortexFunction.timeout4Players/cortex-typescript-sdk/src/types.ts:4575
updatedAtstringFormat: date-time Description Last update timestampCortexFunction.updatedAt4Players/cortex-typescript-sdk/src/types.ts:4604

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:4594
activeDeployment.createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4528
activeDeployment.fleetDeploymentId?stringDescription Fleet deployment ID4Players/cortex-typescript-sdk/src/types.ts:4505
activeDeployment.fleetServiceId?stringDescription Fleet service ID4Players/cortex-typescript-sdk/src/types.ts:4503
activeDeployment.functionIdstringDescription Function ID4Players/cortex-typescript-sdk/src/types.ts:4494
activeDeployment.idstringDescription Deployment UUID4Players/cortex-typescript-sdk/src/types.ts:4492
activeDeployment.invokeUrl?stringDescription Invoke URL (external via Cortex proxy)4Players/cortex-typescript-sdk/src/types.ts:4511
activeDeployment.lastError?stringDescription Last error message4Players/cortex-typescript-sdk/src/types.ts:4513
activeDeployment.lastInvokedAt?stringFormat: date-time Description Last invocation timestamp4Players/cortex-typescript-sdk/src/types.ts:4523
activeDeployment.requestCountnumberDescription Total request count Example 04Players/cortex-typescript-sdk/src/types.ts:4518
activeDeployment.serviceIp?stringDescription Service IP address (internal)4Players/cortex-typescript-sdk/src/types.ts:4507
activeDeployment.servicePort?numberDescription Service port (internal)4Players/cortex-typescript-sdk/src/types.ts:4509
activeDeployment.status| "pending" | "failed" | "running" | "stopped" | "deploying"Description Deployment status4Players/cortex-typescript-sdk/src/types.ts:4501
activeDeployment.updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:4533
activeDeployment.versionIdstringDescription Deployed version ID4Players/cortex-typescript-sdk/src/types.ts:4496
authMode"api_key" | "public" | "signed"Description Authentication mode4Players/cortex-typescript-sdk/src/types.ts:4570
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4599
description?stringDescription Function description4Players/cortex-typescript-sdk/src/types.ts:4553
draftCodestringDescription Draft source code4Players/cortex-typescript-sdk/src/types.ts:4555
draftEntrypointstringDescription Entrypoint function name Example handler4Players/cortex-typescript-sdk/src/types.ts:4560
envVarsobject[]Description Environment variables (secrets masked)4Players/cortex-typescript-sdk/src/types.ts:4582
idstringDescription Function UUID4Players/cortex-typescript-sdk/src/types.ts:4537
memorynumberDescription Memory limit in MB Example 2564Players/cortex-typescript-sdk/src/types.ts:4580
namestringDescription Function name Example process-webhook4Players/cortex-typescript-sdk/src/types.ts:4546
projectIdstringDescription Project ID4Players/cortex-typescript-sdk/src/types.ts:4541
publishedVersionId?stringDescription Published version ID (if published)4Players/cortex-typescript-sdk/src/types.ts:4584
runtime"nodejs20" | "nodejs22"Description Runtime environment4Players/cortex-typescript-sdk/src/types.ts:4565
slugstringDescription URL-friendly identifier Example process-webhook4Players/cortex-typescript-sdk/src/types.ts:4551
status"draft" | "published"Description Function status: draft (not published) or published (available in runtime)4Players/cortex-typescript-sdk/src/types.ts:4589
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:4539
timeoutnumberDescription Execution timeout in milliseconds Example 300004Players/cortex-typescript-sdk/src/types.ts:4575
updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:4604

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:4674

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:4733
deployment.createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4528
deployment.fleetDeploymentId?stringDescription Fleet deployment ID4Players/cortex-typescript-sdk/src/types.ts:4505
deployment.fleetServiceId?stringDescription Fleet service ID4Players/cortex-typescript-sdk/src/types.ts:4503
deployment.functionIdstringDescription Function ID4Players/cortex-typescript-sdk/src/types.ts:4494
deployment.idstringDescription Deployment UUID4Players/cortex-typescript-sdk/src/types.ts:4492
deployment.invokeUrl?stringDescription Invoke URL (external via Cortex proxy)4Players/cortex-typescript-sdk/src/types.ts:4511
deployment.lastError?stringDescription Last error message4Players/cortex-typescript-sdk/src/types.ts:4513
deployment.lastInvokedAt?stringFormat: date-time Description Last invocation timestamp4Players/cortex-typescript-sdk/src/types.ts:4523
deployment.requestCountnumberDescription Total request count Example 04Players/cortex-typescript-sdk/src/types.ts:4518
deployment.serviceIp?stringDescription Service IP address (internal)4Players/cortex-typescript-sdk/src/types.ts:4507
deployment.servicePort?numberDescription Service port (internal)4Players/cortex-typescript-sdk/src/types.ts:4509
deployment.status| "pending" | "failed" | "running" | "stopped" | "deploying"Description Deployment status4Players/cortex-typescript-sdk/src/types.ts:4501
deployment.updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:4533
deployment.versionIdstringDescription Deployed version ID4Players/cortex-typescript-sdk/src/types.ts:4496
invokeUrlstringDescription Public invoke URL Example https://cortex.odin.4players.io/invoke/proj123/my-function4Players/cortex-typescript-sdk/src/types.ts:4738
messagestringDescription Status message Example Deployment started4Players/cortex-typescript-sdk/src/types.ts:4743

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:4729
versionobjectDescription The published version4Players/cortex-typescript-sdk/src/types.ts:4724
version.buildError?stringDescription Build error message4Players/cortex-typescript-sdk/src/types.ts:4698
version.buildLogs?stringDescription Build logs output4Players/cortex-typescript-sdk/src/types.ts:4696
version.changelog?stringDescription Changelog description4Players/cortex-typescript-sdk/src/types.ts:4711
version.codestringDescription Source code (frozen)4Players/cortex-typescript-sdk/src/types.ts:4687
version.createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4716
version.entrypointstringDescription Entrypoint function name4Players/cortex-typescript-sdk/src/types.ts:4689
version.functionIdstringDescription Function ID4Players/cortex-typescript-sdk/src/types.ts:4680
version.idstringDescription Version UUID4Players/cortex-typescript-sdk/src/types.ts:4678
version.memorynumberDescription Memory limit in MB4Players/cortex-typescript-sdk/src/types.ts:4707
version.publishedBy?stringDescription User who published this version4Players/cortex-typescript-sdk/src/types.ts:4709
version.runtime"nodejs20" | "nodejs22"Description Runtime environment4Players/cortex-typescript-sdk/src/types.ts:4703
version.status"failed" | "ready" | "building"Description Build status4Players/cortex-typescript-sdk/src/types.ts:4694
version.timeoutnumberDescription Execution timeout in ms4Players/cortex-typescript-sdk/src/types.ts:4705
version.versionnumberDescription Version number Example 14Players/cortex-typescript-sdk/src/types.ts:4685

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:4750

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:4594
activeDeployment.createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4528
activeDeployment.fleetDeploymentId?stringDescription Fleet deployment ID4Players/cortex-typescript-sdk/src/types.ts:4505
activeDeployment.fleetServiceId?stringDescription Fleet service ID4Players/cortex-typescript-sdk/src/types.ts:4503
activeDeployment.functionIdstringDescription Function ID4Players/cortex-typescript-sdk/src/types.ts:4494
activeDeployment.idstringDescription Deployment UUID4Players/cortex-typescript-sdk/src/types.ts:4492
activeDeployment.invokeUrl?stringDescription Invoke URL (external via Cortex proxy)4Players/cortex-typescript-sdk/src/types.ts:4511
activeDeployment.lastError?stringDescription Last error message4Players/cortex-typescript-sdk/src/types.ts:4513
activeDeployment.lastInvokedAt?stringFormat: date-time Description Last invocation timestamp4Players/cortex-typescript-sdk/src/types.ts:4523
activeDeployment.requestCountnumberDescription Total request count Example 04Players/cortex-typescript-sdk/src/types.ts:4518
activeDeployment.serviceIp?stringDescription Service IP address (internal)4Players/cortex-typescript-sdk/src/types.ts:4507
activeDeployment.servicePort?numberDescription Service port (internal)4Players/cortex-typescript-sdk/src/types.ts:4509
activeDeployment.status| "pending" | "failed" | "running" | "stopped" | "deploying"Description Deployment status4Players/cortex-typescript-sdk/src/types.ts:4501
activeDeployment.updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:4533
activeDeployment.versionIdstringDescription Deployed version ID4Players/cortex-typescript-sdk/src/types.ts:4496
authMode"api_key" | "public" | "signed"Description Authentication mode4Players/cortex-typescript-sdk/src/types.ts:4570
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:4599
description?stringDescription Function description4Players/cortex-typescript-sdk/src/types.ts:4553
draftCodestringDescription Draft source code4Players/cortex-typescript-sdk/src/types.ts:4555
draftEntrypointstringDescription Entrypoint function name Example handler4Players/cortex-typescript-sdk/src/types.ts:4560
envVarsobject[]Description Environment variables (secrets masked)4Players/cortex-typescript-sdk/src/types.ts:4582
idstringDescription Function UUID4Players/cortex-typescript-sdk/src/types.ts:4537
memorynumberDescription Memory limit in MB Example 2564Players/cortex-typescript-sdk/src/types.ts:4580
namestringDescription Function name Example process-webhook4Players/cortex-typescript-sdk/src/types.ts:4546
projectIdstringDescription Project ID4Players/cortex-typescript-sdk/src/types.ts:4541
publishedVersionId?stringDescription Published version ID (if published)4Players/cortex-typescript-sdk/src/types.ts:4584
runtime"nodejs20" | "nodejs22"Description Runtime environment4Players/cortex-typescript-sdk/src/types.ts:4565
slugstringDescription URL-friendly identifier Example process-webhook4Players/cortex-typescript-sdk/src/types.ts:4551
status"draft" | "published"Description Function status: draft (not published) or published (available in runtime)4Players/cortex-typescript-sdk/src/types.ts:4589
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:4539
timeoutnumberDescription Execution timeout in milliseconds Example 300004Players/cortex-typescript-sdk/src/types.ts:4575
updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:4604

Defined in

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