BoxLang 🚀 A New JVM Dynamic Language Learn More...

cordial-sdk

v1.0.7 Modules

WELCOME TO THE COLDBOX CORDIAL SDK

This module is a CFML SDK to interact with the Cordial Contact Management APIs.

LICENSE

Apache License, Version 2.0.

SYSTEM REQUIREMENTS

  • Lucee 5+
  • Adobe ColdFusion 2018+
  • ColdBox 8+

Setup

Configure your Cordial credentials in the config/ColdBox.cfc file.

moduleSettings = {
    "cordial-sdk" = {
        apiKey = getSystemSetting( "CORDIAL_SDK_API_KEY", "" ),
        baseURL = getSystemSetting( "CORDIAL_SDK_BASE_URL", "" ),
        maxConcurrency = 10,
        forceSubscribe = false
    }
};

Settings

Name Type Required? Default Description
apiKey Stringtrue "" Cordial API key. Can come from CORDIAL_SDK_API_KEY or ColdBox module overrides.
baseURL Stringtrue "" Cordial account API base URL (for example, https://<your-account-host>).
maxConcurrency Numericfalse 10 Maximum per-batch request concurrency. Values <= 0 fall back to configured module default.
forceSubscribe Booleanfalse false Default forceSubscribe behavior for create(...).

Methods

Resolve the service with WireBox:

var subscriptions = getInstance( "Subscriptions@cordial-sdk" );

create

Creates subscriptions for one list and many subscribers.

var result = subscriptions.create(
    listKey = "myListKey",
    subscribers = [ "[email protected]", "[email protected]" ],
    forceSubscribe = true,
    maxConcurrency = 5
);
Name Type Required? Default Description
listKey Stringtrue The Cordial list key to set to true.
subscribers Arraytrue Email subscribers for this operation.
forceSubscribe Booleanfalse module settingWhen true, includes forceSubscribe: true in the request payload.
maxConcurrency Numericfalse module settingMax async requests in each chunk.

Behavior:

  • Uses POST /v2/contacts per valid subscriber.
  • Sets channels.email.address and channels.email.subscribeStatus = "subscribed".
  • Sets dynamic list membership key (<listKey> = true).
  • Invalid email entries are reported as failures and do not generate HTTP requests.

cancel

Cancels subscriptions for one list and many subscribers.

var result = subscriptions.cancel(
    listKey = "myListKey",
    subscribers = [ "[email protected]", "[email protected]" ],
    maxConcurrency = 5
);
Name Type Required? Default Description
listKey Stringtrue The Cordial list key to set to false.
subscribers Arraytrue Email subscribers for this operation.
maxConcurrency Numericfalse module settingMax async requests in each chunk.

Behavior:

  • Uses PUT /v2/contacts/email:{urlEncodedEmail} per valid subscriber.
  • Sets dynamic list membership key (<listKey> = false).
  • Does not perform global channel unsubscribe.
  • Invalid email entries are reported as failures and do not generate HTTP requests.

unsubscribeAll

Unsubscribes many subscribers from all emails by setting their email channel subscribe status to unsubscribed.

var result = subscriptions.unsubscribeAll(
    subscribers = [ "[email protected]", "[email protected]" ],
    concurrencyLimit = 5
);
Name Type Required? Default Description
subscribers Arraytrue Email subscribers for this operation.
concurrencyLimit Numericfalse module settingMax async requests in each chunk.

Behavior:

  • Uses PUT /v2/contacts/email:{urlEncodedEmail}/unsubscribe/email per valid subscriber.
  • Performs a global email channel unsubscribe, not a list membership update.
  • Invalid email entries are reported as failures and do not generate HTTP requests.

resubscribe

Resubscribes many subscribers to the email channel.

var result = subscriptions.resubscribe(
    subscribers = [ "[email protected]", "[email protected]" ],
    concurrencyLimit = 5
);
Name Type Required? Default Description
subscribers Arraytrue Email subscribers for this operation.
concurrencyLimit Numericfalse module settingMax async requests in each chunk.

Behavior:

  • Uses PUT /v2/contacts/email:{urlEncodedEmail} per valid subscriber.
  • Sets forceSubscribe = true and channels.email.subscribeStatus = "subscribed".
  • Performs a global email channel resubscribe, not a list membership update.
  • Invalid email entries are reported as failures and do not generate HTTP requests.

Return Contract

All methods return an aggregate result struct:

{
    success   : true|false,
    total     : numeric,
    succeeded : numeric,
    failed    : numeric,
    results   : [
        {
            subscriber    : "[email protected]",
            success       : true|false,
            statusCode    : numeric,
            response      : HyperResponse|null,
            error         : "",
            exceptionType : ""
        }
    ]
}

Notes:

  • success is true only when failed == 0.
  • total is the count of input subscribers.
  • results includes preflight validation failures and HTTP operation outcomes.

Hyper Integration

The Cordial SDK uses the Hyper HTTP Client under the hood.

In ModuleConfig.cfc the Hyper client is preconfigured with:

  • Basic auth (username = apiKey, password = "")
  • Base URL from module settings
  • JSON request/response headers
binder
    .map( "CordialHyperClient@cordial-sdk" )
    .to( "hyper.models.HyperBuilder" )
    .asSingleton()
    .initWith(
        username = settings.apiKey,
        password = "",
        baseURL = settings.baseURL,
        bodyFormat = "json",
        headers = {
            "Content-Type" : "application/json",
            "Accept" : "application/json"
        }
    );

Because of this setup, each method only needs to provide endpoint and payload.

Testing

Unit Tests

Unit tests use Hyper fake support and TestBox matchers.

box server start --background --noSaveSettings --noOpenBrowser
# server stays running

Then run TestBox against /tests/runner.cfm.

Integration Tests

Integration tests are live-first and skip when required env vars are missing:

  • CORDIAL_SDK_API_KEY
  • CORDIAL_SDK_BASE_URL
  • CORDIAL_SDK_TEST_LIST_KEY
  • CORDIAL_SDK_TEST_EMAILS (comma-separated)

These tests validate list membership changes against real Cordial contact records.

v1.0.7

11 May 2026 — 21:14: 42 UTC

other

  • *: Merge pull request #2 from coldbox-modules/codex/sanitize-result-request-mementos (f96ca65)
  • *: Disable test result PR comments (3542e6d)
  • *: Allow experimental server startup failures (82914a6)
  • *: Disambiguate CI test artifacts (83cb330)
  • *: Add resubscribe subscription method (673196f)

$ box install cordial-sdk

No collaborators yet.
     
  • {{ getFullDate("2026-04-21T20:24:26Z") }}
  • {{ getFullDate("2026-05-11T21:14:48Z") }}
  • 295
  • 139