LogoLogo
  • Introduction
  • Features
  • Getting Started
    • Cortex User Guide
      • Organizations
      • Log in
      • Generate an API key
      • Make your first API request
      • Configure the org settings
      • Set up a data model
        • Create custom objects
        • Add custom properties
      • One-to-many relationships
      • Read and write data
      • Making a Request
      • Handling responses
      • Authentication
      • Two-factor authentication
      • Set third-party cookies
      • Connections
      • Upload files
      • Cortex iOS
      • Get started with Swift
      • Cortex service accounts
      • Cortex developer tools
      • Automated Account Notifications
  • Cortex API
    • Overview
    • Objects
      • Objects Overview
      • Organization
      • Account
      • Connections
      • Notifications
      • Stats
      • Logs
      • Export
      • Events
      • Room
    • Object Definition
      • Object Properties
        • Any
        • Binary
        • Boolean
        • Date
        • Document
        • File
        • Geometry
        • List
        • Number
        • ObjectId
        • Reference
        • String
    • Object Types
    • Access Control
    • Querying
      • Query Operators
      • Property Selection
      • Property Access
    • Aggregating
      • Aggregation Operators
    • Scripting
      • Script Types
      • Script Limits
      • ObjectId
      • CortexObject
        • Accounts
        • Views
      • Cursors
      • Operations
      • Script Modules
        • API Module
        • Base64 Module
        • Cache Module
        • Connections Module
        • Console Module
        • Consts Module
        • Counters Module
        • Crypto Module
        • HTTP Module
        • Logger Module
        • Notifications Module
        • Request Module
        • Response Module
        • SAML Module
        • Schemas Modules
        • Script Module
        • Session Module
        • Util.id Module
        • Util.ip Module
        • Util.paths Module
        • XML Module
        • Developer
        • Config
        • Renderer
        • SFTP
        • FTP
        • DB
          • Cursors
          • Driver
      • Static Methods
        • Accounts
        • Views
        • Cursors
      • Audit
      • Environments
      • HTTP Driver
      • Notifications
        • Firebase Cloud Messaging (FCM)
        • Tencent Push Notification Service Configuration
      • Televisit
      • Transforms
      • Localization
      • Available Javascript Libraries
    • Decorators
      • Runtime
        • Acl
        • As
        • Log
        • Profile
      • Static
        • Env
        • Job
        • Object
        • On
        • Policy
        • Route
        • Transform
        • Trigger
    • Expressions
      • Primer
      • Pipelines
      • Operators
      • Accumulators
      • Variables
      • Conditionals
      • Transforms
      • Triggers
      • On
      • Events
    • Faults
      • Fault Reference
  • Releases
    • Cortex Release Notes
      • Cortex API 2.28.3 (R3.4.6)
      • Cortex API 2.28.1 (R3.4.3)
      • Cortex API 2.27.2 (R3.4.1)
      • Cortex API 2.27.1 (R3.3.5)
      • SQL DB Connector 1.3.4 (R3.3.3)
      • Cortex API 2.26.2 (R3.3.1)
      • Cortex API 2.26.1 (R3.2.2)
      • Cortex API 2.26.0 (R3.2.1)
      • SQL DB Connector 1.3.3
      • Cortex API 2.25.0 (R3.1.1)
      • SQL DB Connector 1.3.2 (R3.1.0)
      • Cortex API 2.24.2 (R3.0.2)
      • SQL DB Connector 1.3.1 (R3.0.0)
      • Cortex API 2.24.1 (R2.3.3)
      • Cortex API 2.24.0 (R2.3.2)
      • SQL DB Connector 1.3.0 (R2.3.0)
      • Cortex API 2.23.0 (R2.2.4)
      • SQL DB Connector 1.2.0 (R2.2.0)
      • Cortex API 2.22.2 (R2.1.2)
      • Cortex API 2.22.1 and SQL DB Connector 1.1.1 (R2.0.1)
      • Cortex API 2.22.0
      • Cortex API 2.21.3
      • Cortex API 2.21.2
      • Cortex Web 4.16.0
      • Cortex Web 4.15.1
      • Cortex API 2.20.1
      • Cortex Web 4.14.0
      • Cortex Renderer 1.3.3
      • Cortex API 2.19.4
      • Cortex API 2.19.3 and Cortex Web 4.13.1
      • Cortex Renderer 1.3.2
      • Cortex API 2.19.1
      • Cortex API 2.18.0
      • Cortex API 2.17.6
      • Cortex API 2.17.5
      • Cortex API 2.17.4
      • Cortex API 2.17.3
      • Cortex API 2.17.2
      • Cortex API 2.17.1
      • Cortex API 2.16.0
      • Cortex API 2.15.9
      • Cortex API 2.15.8-1
      • Cortex 2.15.8
      • Cortex API 2.18.1
      • Cortex API 2.16.1
      • Cortex Renderer 1.3.1
      • Cortex Renderer 1.3.0
      • Cortex Renderer 1.2.2
      • Cortex Renderer 1.2.1
      • Cortex Renderer 1.2.0
    • Third-Party License Attribution

© 2025 Medable, Inc. All rights reserved.

On this page
  • Methods
  • apply(token, options)
  • create(objects, id, targets, options)
  • linkTo(objects, id, access, options)
  • list(options)
  • read(tokenOrId, options)
  • delete(tokenOrId, options)

Was this helpful?

  1. Cortex API
  2. Scripting
  3. Script Modules

Connections Module

Last updated 3 years ago

Was this helpful?

Import

import connections from 'connections';

Methods

apply(token, options)

Applies a connection

Arguments

  • token (String) the unique connection token.

  • options - skipAcl (Boolean:false) If true, the connection will be applied regardless of the script caller. Normally, only the connection target may apply a connection.

Returns

Connection (Object)

create(objects, id, targets, options)

Creates a connection.

Arguments

  • objects (String) the object plural name (eg. accounts)

  • id (ObjectID) the identifer of the context

  • targets (Object[]) a list of connection targets.

    • _id (ObjectId:null) the target account identifier. required if email is not set.

    • email (String:null) the target account email. required if _id is not set.

    • access (Number) the context access level to impart to the target.

    • roles (ObjectId[]:[]) a set of context roles to impart to the target.

  • options

    • skipAcl (Boolean:false) if true, share access to the sharing context is not required.

    • forceAuto (Boolean:false) automatically create connection, even for objects that normally require acceptance.

    • skipNotification (Boolean:false) suppress notifications.

    • connectionAppKey (String) attempts to use the original request key, if available. if not available, a key must be passed.

    • forceAllowConnections (Boolean:false) if true, will enable connections for an object for which connections are normally disabled.

Returns

Connection (Object)

linkTo(objects, id, access, options)

Creates an anonymous, active connection that can be used to access the referenced context via expansion.

Arguments

  • objects (String) the object plural name (eg. accounts)

  • id (ObjectID) the identifer of the context

  • access (Number) the level of access to grant the link.

  • options

    • skipAcl (Boolean:false) if true, share access to the sharing context is not required.

    • expiresInMs (Integer:null) an optional number of milliseconds before the link expires

    • expiresAt (Date:null) optional date when the link will expire. Supersedes expiresInMs.

    • usesRemaining (Integer:null) optional number of times the token can be used to load the connection before it expires.

    • connectionAppKey (String) attempts to use the original request key, if available. if not available, a key must be passed.

    • forceAllowConnections (Boolean:false) if true, will enable connections for an object for which connections are normally disabled.

    • roles (ObjectId[]:[]) a set of roles to apply to the caller when reading the connection context

Returns

Connection (Object)

list(options)

Lists connections for the caller.

Arguments

  • options

    • paths (String[]) limits the result to the specified paths

    • include (String[]) a list of optional paths to include. included paths that are expandable are automatically expanded

    • expand (String[]) a list of paths to expand from referenced ids. Items are expanded with the caller's access level

    • skip (Number:0) the number of items to skip. Useful when paging using non-unique sort criteria.

    • limit (Number:100) Limit the number of connections to return. Can be between 1 and 1000.

    • where (Object) json object describing the where query argument

    • map (Object) json object describing the map query argument

    • sort (Object) json object describing the sort query argument

    • group (Object) json object describing the group query argument

    • skipAcl (Boolean:false) if true, connections are not filtered by target/creator.

    • show (String) Filters the list. creator only shows invitations by the caller. target only shows invitations to the caller

Returns

Connection[] (Object)

read(tokenOrId, options)

Load a connection

Arguments

  • tokenOrId (String/ObjectId) the unique connection token or object id. unless skipAcl is used, loading by token is restricted to the connection target.

  • options

    • paths (String[]) limits the result to the specified paths

    • include (String[]) a list of optional paths to include. included paths that are expandable are automatically expanded

    • expand (String[]) a list of paths to expand from referenced ids. Items are expanded with the caller's access level

    • skipAcl (Boolean:false) when true, any principal is able to read the connection.

    • skipAccountTest (Boolean:false) when true, does not demand the calling principal account be verified.

Returns

Connection (Object)

delete(tokenOrId, options)

Delete a connection

Arguments

  • tokenOrId (String/ObjectId) the unique connection token or object id.

  • options

    • skipAcl (Boolean:false) when true, any principal is able to delete the connection.

apply(token, options)
create(objects, id, targets, options)
linkTo(objects, id, access, options)
list(options)
read(tokenOrId, options)
delete(tokenOrId, options)