Skip to main content

Examples

Runnable TypeScript examples for the Candescent Digital Insight API are available in the cdx-typescript-sdk repository. Clone the repo to explore recommended SDK usage patterns against the Stage environment.

PackageVersion
@cdx-forge/di-typescript-sdk1.0.0
OpenAPI spec (candescent-dev/openapi)1.6.0

Clone and install

Bash
git clone https://github.com/candescent-dev/cdx-typescript-sdk.git
cd cdx-typescript-sdk
pnpm install

pnpm install pulls @cdx-forge/di-typescript-sdk and other dependencies required to run scripts under examples/typescript/.

Environment setup

Bash
cp .env.example .env

Generate your credentials using the values provided in the Developer Console quickstart guide.

VariableRequiredDescription
CANDESCENT_INSTITUTION_IDYesInstitution identifier
CANDESCENT_CLIENT_IDYes*OAuth 2.0 client ID
CANDESCENT_CLIENT_SECRETYes*OAuth 2.0 client secret
CANDESCENT_BEARER_TOKENYes*Pre-obtained JWT (skips OAuth)
CANDESCENT_ENVIRONMENTNostage (default) or production

*Provide either CANDESCENT_BEARER_TOKEN or both CANDESCENT_CLIENT_ID and CANDESCENT_CLIENT_SECRET.

See .env.example for example-specific variables (account IDs, business banking, MX, alerts, and more).

Credential groups

If one OAuth app works for all flows, you can repeat the values for each group:

GroupVariables
Retail / defaultCANDESCENT_CLIENT_ID, CANDESCENT_CLIENT_SECRET, CANDESCENT_INSTITUTION_ID
Business bankingCANDESCENT_BB_CLIENT_ID, CANDESCENT_BB_CLIENT_SECRET, CANDESCENT_BB_INSTITUTION_ID
MX integrationCANDESCENT_MX_CLIENT_ID (MX also requires CANDESCENT_MX_API_KEY)

User identifiers:

VariableUsed for
CANDESCENT_HOST_USER_IDRetail examples (hostUserId)
CANDESCENT_LOGIN_IDRetail examples (loginId)
CANDESCENT_BB_LOGIN_IDBusiness banking examples

Set FALLBACK_CUSTOMER_ID to skip registration and test lookups against an existing customer.

Run a single example

Bash
node --experimental-strip-types examples/typescript/accounts.ts

Replace accounts.ts with any script from the catalog below.

note

Individual scripts do not auto‑load .env. Either source it manually (source .env) or use the batch runner below.

Run all examples

From the repo root:

Bash
node scripts/run-all-typescript-examples.mjs

Output is appended to developerscript/typescript/logs/all-examples.log of the cdx-typescript-sdk repo. The process exits non-zero if any example fails.

DetailValue
Default logdeveloperscript/typescript/logs/all-examples.log
Custom lognode scripts/run-all-typescript-examples.mjs --log=/tmp/ts-examples.log
CredentialsEnvironment variables or repo-root .env (loaded automatically by the batch runner)

When CANDESCENT_CLIENT_ID and CANDESCENT_CLIENT_SECRET are set, a static CANDESCENT_BEARER_TOKEN is stripped so examples use live OAuth.

Run error-handling.ts individually — it exercises intentional failures and is excluded from the batch runner:

Bash
node --experimental-strip-types examples/typescript/error-handling.ts

Example catalog

Example fileWhat it covers
accounts.tsList accounts, retrieve account details, banking images
transactions.tsTransaction history, filtering
authentication.tsOAuth token lifecycle
authentication-lifecycle.tsFull token creation, revoke flow
customer-management.tsContact methods, password reset, unlock
register-and-lookup.tsCustomer registration, search
disclosures.tsInstitution and user disclosures
estatements.tsE-statement delivery preferences
alert-configuration.tsAlert templates and types
alert-preferences.tsUser and institution alert preferences
alert-delivery.tsAlert history and content
notification-channels.tsSubscription management
business-registration.tsBusiness banking registration
business-entitlements.tsBusiness and user entitlements
business-payments.tsACH and wire payments
customer-campaigns.tsExperience groups and campaigns
money-movement.tsRecipients and transfers
mx-service.tsMX integration — widget, users, logs
pagination.tsPageIterator patterns
error-handling.tsError hierarchy showcase
user-status.tsUser authentication status

Example to operation coverage

API tagExample file(s)Operations covered
Accountsaccounts, transactionslist, get, banking images, activities, listTransactions
Alert Configurationalert-configurationTemplates, types, institution types CRUD
Alert Deliveryalert-deliveryHistory, content, publish events
Alert Preferencesalert-preferencesUser + institution preference CRUD
Authenticationauthentication, authentication-lifecycleAuthorize, legacy token, auth code, create/revoke token
Business Bankingbusiness-registration, business-entitlements, business-paymentsRegistration, entitlements, ACH/Wire
Customer Campaignscustomer-campaignsExperience groups, jobs, user lists
Customer Managementregister-and-lookup, user-status, customer-managementRegister, lookups, contact, password, unlock
Documents & Preferencesdisclosures, estatementsDisclosure CRUD, e-statement prefs/report
MXmx-serviceUsers, widget URL, transaction logs
Money Movementmoney-movementRecipients and transfers
Notification Channelsnotification-channelsSubscriptions CRUD and send event
Cross-cuttingerror-handling, paginationError hierarchy, pagination patterns

All API operations are covered by these scripts.