SenderProfile manages sender profiles (From name, From address, etc.). SenderProfile methods only run on CloudPages / landing pages — they cannot run inside an email message at send time.

There is no SenderProfile.Retrieve in this Core namespace; use Init with a known key or query via WSProxy when you need discovery.

Methods

Method Returns Description
SenderProfile.Init(key) SenderProfileInstance Bind by external key
SenderProfile.Add(properties) object Create a sender profile (returns a CLR object, not "OK")
<SenderProfileInstance>.Update(properties) string Update the initialized profile
<SenderProfileInstance>.Remove() string Delete the profile

SenderProfile.Init

Initializes a SenderProfile instance for the given external key.

Syntax

SenderProfile.Init(key)

Parameters

Name Type Required Description
key string Yes External key

Return value

SenderProfileInstance

Examples

Platform.Load("core", "1");
var myProfile = SenderProfile.Init("mySenderProfile");
Show test script
<script runat="server">
Platform.Load("core", "1.1.5");

/*
 * Chapter: SenderProfile.Init(key)
 *
 * CloudPage GET context. Proves:
 *   1. SenderProfile requires the Core load and is then an object exposing
 *      exactly the two documented statics Init and Add.
 *   2. The page's claim that there is NO SenderProfile.Retrieve in this
 *      namespace — and no static Update or Remove either.
 *   3. Init(key) returns a SenderProfileInstance: an object whose only
 *      members are the two documented instance methods Update and Remove,
 *      both typeof "function".
 *   4. The instance exposes no Retrieve and no Add, matching the Methods
 *      table.
 *   5. The instance carries NO readable profile fields (CustomerKey, Name,
 *      Description, FromName, FromAddress read back undefined) — Init binds
 *      a key, it does not fetch the record.
 *   6. The same stub is returned for a nonsense key, so Init alone never
 *      confirms that a key resolves to a real sender profile.
 *   7. The exact example on the page runs.
 *
 * EXPECTED OUTPUT: every line starts with PASS.
 */

function assert(id, actual, expected) {
    Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
function typeOf(fn) {
    try { return "" + fn(); } catch (ex) { return "THREW"; }
}
function invocationResult(fn) {
    try { fn(); return "returned"; } catch (ex) { return "threw"; }
}

/* 1. Availability after the Core load. */
assert("typeof SenderProfile is object", typeOf(function () { return typeof SenderProfile; }), "object");
assert("typeof SenderProfile.Init is function", typeOf(function () { return typeof SenderProfile.Init; }), "function");
assert("typeof SenderProfile.Add is function", typeOf(function () { return typeof SenderProfile.Add; }), "function");

/* 2. There is no Retrieve in this namespace, and no static Update/Remove. */
assert("SenderProfile.Retrieve does not exist in this namespace", typeOf(function () { return typeof SenderProfile.Retrieve; }), "undefined");
assert("SenderProfile.Update is not a static", typeOf(function () { return typeof SenderProfile.Update; }), "undefined");
assert("SenderProfile.Remove is not a static", typeOf(function () { return typeof SenderProfile.Remove; }), "undefined");

/* 3. Shape of the returned SenderProfileInstance. */
var myProfile = SenderProfile.Init("ssjs-guide-ts-sp-init");
assert("typeof SenderProfile.Init(key) is object", typeof myProfile, "object");
assert("typeof instance.Update is function", typeof myProfile.Update, "function");
assert("typeof instance.Remove is function", typeof myProfile.Remove, "function");

/* 4. The instance exposes only the two documented methods. */
assert("instance has no Retrieve", typeof myProfile.Retrieve, "undefined");
assert("instance has no Add", typeof myProfile.Add, "undefined");
assert("instance exposes exactly Remove + Update", "" + Stringify(myProfile), '{"Remove":"function","Update":"function"}');

/* 5. Init binds a key; it does not fetch the record. */
assert("instance.CustomerKey is undefined (Init does not fetch)", typeof myProfile.CustomerKey, "undefined");
assert("instance.Name is undefined (Init does not fetch)", typeof myProfile.Name, "undefined");
assert("instance.Description is undefined (Init does not fetch)", typeof myProfile.Description, "undefined");
assert("instance.FromName is undefined (Init does not fetch)", typeof myProfile.FromName, "undefined");
assert("instance.FromAddress is undefined (Init does not fetch)", typeof myProfile.FromAddress, "undefined");

/* 6. A nonsense key yields an indistinguishable stub. */
var bogus = SenderProfile.Init("ssjs-guide-no-such-sp-zzz");
assert("Init(nonsense key) still returns an object", typeof bogus, "object");
assert("Init(nonsense key) exposes Update", typeof bogus.Update, "function");
assert("Init(nonsense key) exposes Remove", typeof bogus.Remove, "function");
assert("Init(nonsense key) stub is indistinguishable from the other one", ("" + Stringify(bogus)) === ("" + Stringify(myProfile)) ? "true" : "false", "true");

/* 7. The exact example on the page. */
assert("page example: Init('mySenderProfile') returns an instance", invocationResult(function () { return SenderProfile.Init("mySenderProfile"); }), "returned");
</script>


SenderProfile.Add

Creates a new sender profile with the specified properties.

Syntax

SenderProfile.Add(properties)

Parameters

Name Type Required Description
properties object Yes Name, CustomerKey, Description, FromName, FromAddress, …

Return value

object — a CLR SenderProfile object (opaque from SSJS) on success; throws on failure. Not the "OK" string the docs imply.

Examples

Platform.Load("core", "1.1.5");
var newSP = {
    Name: "SSJS Added Send Profile",
    CustomerKey: "test_send_profile",
    Description: "An SSJS Added Profile",
    FromName: "Andrea Cruz",
    FromAddress: "acruz@example.com"
};
var status = SenderProfile.Add(newSP); // CLR object, not "OK"
Show test script
<script runat="server">
Platform.Load("core", "1.1.5");

/*
 * Chapter: SenderProfile.Add(properties)
 *
 * CloudPage GET context. Proves:
 *   1. SenderProfile.Add is a function taking one properties object.
 *   2. Add(properties) with Name / CustomerKey / Description / FromName /
 *      FromAddress returns without throwing — the documented success signal.
 *   3. DEVIATION "DEV": the return value is a CLR object, NOT the string
 *      "OK" the official docs describe. typeof is "clr", it stringifies to
 *      the .NET type name ExactTarget.Integration.WSDL.SenderProfile.
 *   4. DEVIATION "DEV": reading ANY property off the returned object throws
 *      "Use of Common Language Runtime (CLR) is not allowed" — the
 *      properties are not readable from SSJS (docs describe a readable
 *      result), so the only usable success test is "it did not throw".
 *   5. The workaround the page recommends: treat a non-throwing return as
 *      success — proven by initializing the just-created key and updating
 *      it successfully.
 *   6. Negative cases: Add() with no argument, Add({}) with an empty object,
 *      and a second Add re-using an existing CustomerKey all throw.
 *
 * FIXTURE: creates ssjs-guide-ts-sp-add and removes it again at the end.
 * Does NOT touch shared ssjs-senderprofile.
 *
 * EXPECTED OUTPUT: every line starts with PASS.
 */

function assert(id, actual, expected) {
    Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
function invocationResult(fn) {
    try { fn(); return "returned"; } catch (ex) { return "threw"; }
}
function threwFragment(fn, fragment) {
    try { fn(); return "did NOT throw"; } catch (ex) { return ("" + ex.message).indexOf(fragment) >= 0 ? "matched" : ("" + ex.message); }
}

var KEY = "ssjs-guide-ts-sp-add";

/* Orphan cleanup from a previously aborted run (returns "Error" if absent). */
SenderProfile.Init(KEY).Remove();

/* 1. Shape of the documented member. */
assert("typeof SenderProfile.Add is function", typeof SenderProfile.Add, "function");

/* 2. The documented payload is accepted (page example shape). */
var newSP = {
    Name: "SSJS Guide Test Sender Profile",
    CustomerKey: KEY,
    Description: "An SSJS Added Profile",
    FromName: "Andrea Cruz",
    FromAddress: "acruz@example.com"
};
var result = null;
assert("Add(properties) does not throw", invocationResult(function () { result = SenderProfile.Add(newSP); }), "returned");

/* 3. DEVIATION — a CLR object is returned, not the string "OK". */
assert("DEV typeof Add() result is clr (docs: string \"OK\")", typeof result, "clr");
assert("DEV Add() result is not the string OK (docs: \"OK\")", ("" + result) === "OK" ? "true" : "false", "false");
assert("DEV Add() result stringifies to its .NET type name (docs: \"OK\")", "" + result, "ExactTarget.Integration.WSDL.SenderProfile");
assert("DEV Stringify(Add() result) is the .NET type name (docs: \"OK\")", "" + Stringify(result), '"ExactTarget.Integration.WSDL.SenderProfile"');

/* 4. DEVIATION — its properties are not readable from SSJS. */
assert("DEV reading result.Name throws (docs imply a readable result)", invocationResult(function () { return result.Name; }), "threw");
assert("DEV reading result.Name reports the CLR restriction", threwFragment(function () { return result.Name; }, "Use of Common Language Runtime (CLR) is not allowed"), "matched");
assert("DEV reading result.CustomerKey throws (docs imply a readable result)", invocationResult(function () { return result.CustomerKey; }), "threw");
assert("DEV reading result.CustomerKey reports the CLR restriction", threwFragment(function () { return result.CustomerKey; }, "Use of Common Language Runtime (CLR) is not allowed"), "matched");
assert("DEV reading result.FromAddress throws (docs imply a readable result)", invocationResult(function () { return result.FromAddress; }), "threw");

/* 5. Workaround — a non-throwing return really did create the profile. */
assert("workaround: the created key now updates successfully", "" + SenderProfile.Init(KEY).Update({ Description: "confirmed by test script" }), "OK");

/* 6. Negative cases. */
assert("Add() with no argument throws", invocationResult(function () { return SenderProfile.Add(); }), "threw");
assert("Add({}) with an empty object throws", invocationResult(function () { return SenderProfile.Add({}); }), "threw");
assert("Add() re-using an existing CustomerKey throws", invocationResult(function () { return SenderProfile.Add(newSP); }), "threw");

/* Fixture cleanup. */
assert("fixture cleanup removed the created profile", "" + SenderProfile.Init(KEY).Remove(), "OK");
assert("shared ssjs-senderprofile still updates (not deleted)", "" + SenderProfile.Init("ssjs-senderprofile").Update({ Description: "ssjs-senderprofile kept" }), "OK");
</script>


<SenderProfileInstance>.Update

Updates the initialized sender profile with the given properties.

Syntax

<SenderProfileInstance>.Update(properties)

Parameters

Name Type Required Description
properties object Yes Attributes to change

Return value

"OK" on success.

Examples

Platform.Load("core", "1.1.5");
var myProfile = SenderProfile.Init("mySenderProfile");
var status = myProfile.Update({ Name: "SSJS Updated Sender Profile" });
Show test script
<script runat="server">
Platform.Load("core", "1.1.5");

/*
 * Chapter: <SenderProfileInstance>.Update(properties)
 *
 * CloudPage GET context. Proves:
 *   1. Update is an instance method (typeof "function") on the object
 *      returned by SenderProfile.Init.
 *   2. Update(properties) returns the string "OK" on success — the
 *      documented return value — and its typeof is "string".
 *   3. The exact shape of the page example, Update({ Name: ... }), succeeds.
 *   4. The change persists: a second Update on the same key also returns
 *      "OK", so the instance stayed bound to a real record.
 *   5. Negative case: Update on a key that does not resolve to a sender
 *      profile returns the plain string "Error" rather than throwing, so a
 *      caller MUST test the return value and cannot rely on try/catch alone.
 *
 * FIXTURE: creates ssjs-guide-ts-sp-update and removes it again at the end.
 *
 * EXPECTED OUTPUT: every line starts with PASS.
 */

function assert(id, actual, expected) {
    Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
function invocationResult(fn) {
    try { fn(); return "returned"; } catch (ex) { return "threw"; }
}

var KEY = "ssjs-guide-ts-sp-update";

/* Orphan cleanup, then create the fixture. */
SenderProfile.Init(KEY).Remove();
SenderProfile.Add({
    Name: "SSJS Guide Test Sender Profile",
    CustomerKey: KEY,
    Description: "An SSJS Added Profile",
    FromName: "Andrea Cruz",
    FromAddress: "acruz@example.com"
});

var myProfile = SenderProfile.Init(KEY);

/* 1. Shape. */
assert("typeof instance.Update is function", typeof myProfile.Update, "function");

/* 2 + 3. The documented return value, using the page example's payload. */
var status = myProfile.Update({ Name: "SSJS Updated Sender Profile" });
assert("page example: Update({Name}) returns \"OK\"", "" + status, "OK");
assert("Update returns a string", typeof status, "string");
assert("Update does not throw on success", invocationResult(function () { return myProfile.Update({ Description: "second update" }); }), "returned");

/* 4. The instance stays bound — a repeated update still succeeds. */
assert("a repeated Update on the same instance still returns \"OK\"", "" + myProfile.Update({ Description: "third update" }), "OK");
assert("a freshly initialized instance for the same key also returns \"OK\"", "" + SenderProfile.Init(KEY).Update({ Description: "fourth update" }), "OK");

/* 5. Negative case — a non-resolving key returns "Error", it does not throw. */
assert("Update on a nonexistent key returns \"Error\"", "" + SenderProfile.Init("ssjs-guide-no-such-sp-zzz").Update({ Name: "x" }), "Error");
assert("Update on a nonexistent key does NOT throw (test the return value)", invocationResult(function () { return SenderProfile.Init("ssjs-guide-no-such-sp-zzz").Update({ Name: "x" }); }), "returned");

/* Fixture cleanup. */
assert("fixture cleanup removed the created profile", "" + SenderProfile.Init(KEY).Remove(), "OK");
</script>


<SenderProfileInstance>.Remove

Removes the initialized sender profile.

Syntax

<SenderProfileInstance>.Remove()

Return value

"OK" on success.

Examples

Platform.Load("core", "1.1.5");
var myProfile = SenderProfile.Init("mySenderProfile");
var status = myProfile.Remove();
Show test script
<script runat="server">
Platform.Load("core", "1.1.5");

/*
 * Chapter: <SenderProfileInstance>.Remove()
 *
 * CloudPage GET context. Proves:
 *   1. Remove is an instance method (typeof "function") on the object
 *      returned by SenderProfile.Init and takes no arguments.
 *   2. Remove() returns the string "OK" on success — the documented return
 *      value — and its typeof is "string".
 *   3. The deletion really happened: after a successful Remove, a further
 *      Update on the same key no longer succeeds.
 *   4. Negative case: Remove() on a key that does not resolve to a sender
 *      profile returns the plain string "Error" rather than throwing — so a
 *      caller MUST test the return value and cannot rely on try/catch alone.
 *      This is also why the other scripts in this bundle can call Remove
 *      unconditionally as an orphan-cleanup preamble.
 *   5. Orphan recount for known ssjs-guide-ts-sp-* throwaway keys (no
 *      Retrieve in this namespace — existence via Update probe).
 *
 * FIXTURE: creates ssjs-guide-ts-sp-remove and deletes it as the assertion.
 *
 * EXPECTED OUTPUT: every line starts with PASS.
 */

function assert(id, actual, expected) {
    Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
function invocationResult(fn) {
    try { fn(); return "returned"; } catch (ex) { return "threw"; }
}
function existsViaUpdate(key) {
    return ("" + SenderProfile.Init(key).Update({ Description: "orphan-probe" })) === "OK" ? 1 : 0;
}

var KEY = "ssjs-guide-ts-sp-remove";
var KNOWN = ["ssjs-guide-ts-sp-add", "ssjs-guide-ts-sp-update", "ssjs-guide-ts-sp-remove", "ssjs-guide-ts-sp-init"];

/* Sweep known throwaways from aborted runs; never touch ssjs-senderprofile. */
var i;
for (i = 0; i < KNOWN.length; i++) {
    SenderProfile.Init(KNOWN[i]).Remove();
}

SenderProfile.Add({
    Name: "SSJS Guide Test Sender Profile",
    CustomerKey: KEY,
    Description: "An SSJS Added Profile",
    FromName: "Andrea Cruz",
    FromAddress: "acruz@example.com"
});

var myProfile = SenderProfile.Init(KEY);

/* 1. Shape. */
assert("typeof instance.Remove is function", typeof myProfile.Remove, "function");

/* Control: the fixture exists before the Remove. */
assert("control: the fixture updates successfully before Remove", "" + myProfile.Update({ Description: "about to be removed" }), "OK");

/* 2. The documented return value, using the page example's shape. */
var status = myProfile.Remove();
assert("page example: Remove() returns \"OK\"", "" + status, "OK");
assert("Remove returns a string", typeof status, "string");

/* 3. The deletion really happened. */
assert("after Remove the key no longer updates", "" + SenderProfile.Init(KEY).Update({ Name: "x" }), "Error");
assert("after Remove a second Remove on the same key returns \"Error\"", "" + SenderProfile.Init(KEY).Remove(), "Error");

/* 4. Negative case — a non-resolving key returns "Error", it does not throw. */
assert("Remove on a nonexistent key returns \"Error\"", "" + SenderProfile.Init("ssjs-guide-no-such-sp-zzz").Remove(), "Error");
assert("Remove on a nonexistent key does NOT throw (test the return value)", invocationResult(function () { return SenderProfile.Init("ssjs-guide-no-such-sp-zzz").Remove(); }), "returned");

/* 5. Orphan recount for known throwaway keys. */
var orphans = 0;
for (i = 0; i < KNOWN.length; i++) {
    orphans = orphans + existsViaUpdate(KNOWN[i]);
}
assert("known ssjs-guide-ts-sp-* orphan count is 0", "" + orphans, "0");
assert("shared ssjs-senderprofile still present", "" + existsViaUpdate("ssjs-senderprofile"), "1");
</script>

See also