Skip to content

SDK API Reference / CASSDK

Class: CASSDK

CAS SDK — composable audience operations

Constructors

Constructor

new CASSDK(context): CASSDK

Parameters

context

SDKContext

Returns

CASSDK

Properties

_connectionSDK?

optional _connectionSDK?: ConnectionSDK

Set by TDX constructor to provide cross-SDK access

Methods

deleteSegment()

deleteSegment(audienceNameOrId, segmentName): Promise<{ id: string; }>

Delete a single composable child segment by name, under the given audience. Single-named- target only (not a directory/bulk prune) — see push-workflow.ts's deleteComposableSegment doc comment.

Prefer deleteSegmentById when the caller has already resolved the segment (e.g. to check it exists before confirming) — this method re-lists and re-resolves by name internally, which is an extra round-trip and a TOCTOU window: if a different segment gets created under the same name between the caller's own lookup and this call, this would delete that one instead of the one the caller actually confirmed.

Parameters

audienceNameOrId

string

segmentName

string

Returns

Promise<{ id: string; }>


deleteSegmentById()

deleteSegmentById(segmentId): Promise<void>

Delete a composable child segment by its already-resolved ID — no name/audience lookup, no re-resolution. Use this whenever the caller already has the segment's ID from its own prior lookup, to avoid both an extra round-trip and the race deleteSegment's doc comment describes.

Parameters

segmentId

string

Returns

Promise<void>


get()

get(idOrName): Promise<ComposableAudience>

Get a composable audience by ID or name

Parameters

idOrName

string

Returns

Promise<ComposableAudience>


getParentSegmentEntity()

getParentSegmentEntity(id): Promise<ParentSegment>

Show counterpart of listParentSegmentEntities. Takes a resolved audience id.

Parameters

id

string

Returns

Promise<ParentSegment>


getSegment()

getSegment(segmentId): Promise<ComposableSegment>

Get one composable segment by id.

Takes no audience id — /entities/composable_segments/:id does not need one — and unlike listSegments it also returns journey-local segments, which that method filters out (see COMPOSABLE_SEGMENT_TYPE_JOURNEY). Journey pull needs this to label the segments a journey's steps reference.

Parameters

segmentId

string

Returns

Promise<ComposableSegment>


list()

list(): Promise<ComposableAudience[]>

List all composable audiences

Returns

Promise<ComposableAudience[]>


listFolders()

listFolders(audienceId): Promise<CASFolder[]>

List a composable audience's folders (flat; hierarchy is reconstructed from parentFolderId).

Unlike its name-accepting siblings on this class, this takes an already-resolved id — its callers (journey pull/list) resolve the audience through resolveAudienceContext first, so a name lookup here would only add a wasted round-trip.

Parameters

audienceId

string

Returns

Promise<CASFolder[]>


listParentSegmentEntities()

listParentSegmentEntities(): Promise<ParentSegment[]>

List composable audiences as v5 entities, carrying the root-folder relationship.

This is the composable half of the union that resolveAudienceContext (sdk/segment/audience-context.ts) matches names against, which is why it returns the same ParentSegment shape as SegmentSDK.listParents() rather than ComposableAudience — see CASApiClient.listComposableParentSegments' doc comment for why the two shapes are interchangeable here.

Returns

Promise<ParentSegment[]>


listSegments()

listSegments(audienceNameOrId): Promise<ComposableSegment[]>

List segments for a composable audience

Parameters

audienceNameOrId

string

Returns

Promise<ComposableSegment[]>


preview()

preview(audienceNameOrId, segmentNameOrId): Promise<{ customers?: CASPreviewCustomers; query: CASPreviewResult; }>

Preview a composable segment (runs query on CDW). Accepts segment name or ID. Submits query, polls for completion, fetches customer rows.

The preview endpoint consumes a rule, not a segment ID (see CASApiClient.previewSegment) — an absent/empty rule would silently preview SQL FALSE and report count=0 (CAS-812), so reject those upfront.

Parameters

audienceNameOrId

string

segmentNameOrId

string

Returns

Promise<{ customers?: CASPreviewCustomers; query: CASPreviewResult; }>


pull()

pull(nameOrId, options): Promise<CASPullResult>

Pull a composable audience + segments + activations to YAML files

Parameters

nameOrId

string

options

CASPullOptions

Returns

Promise<CASPullResult>


push()

push(files, options?): Promise<CASPushResult>

Push YAML files to CAS API

Parameters

files

string[]

options?

CASPushOptions

Returns

Promise<CASPushResult>


resolveAudienceId()

resolveAudienceId(nameOrId): Promise<string>

Resolve audience name → ID

Parameters

nameOrId

string

Returns

Promise<string>


resolveSegment()

resolveSegment(audienceNameOrId, segmentNameOrId): Promise<ComposableSegment>

Resolve segment name or ID → full segment (including its saved rule) within an audience

Parameters

audienceNameOrId

string

segmentNameOrId

string

Returns

Promise<ComposableSegment>


resolveSegmentId()

resolveSegmentId(audienceNameOrId, segmentNameOrId): Promise<string>

Resolve segment name → ID within an audience

Parameters

audienceNameOrId

string

segmentNameOrId

string

Returns

Promise<string>