// sfmc-globals.d.ts — GENERATED by ssjs-data/scripts/generate-dts.mjs
// DO NOT EDIT — run `npm run generate:dts` in ssjs-data to regenerate.
// Ambient declarations for the complete SFMC SSJS global API surface.
// Designed for use with TypeScript's noLib:true (no lib.es5.d.ts).
// ── Runtime built-ins ────────────────────────────────────────────────────────
interface IArguments {
[index: number]: any;
length: number;
callee: Function;
}
declare var arguments: IArguments;
declare const NaN: number;
declare const Infinity: number;
// ── Platform ────────────────────────────────────────────────────────────────
declare namespace Platform {
/**
* Loads a platform library. Must be called before using Core library objects.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-load/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The docs describe Platform.Load as void, but it returns the literal null; never test the result to detect success because a failed load throws. The documented required libraryName accepts an empty string or null as a silent no-op, while "core" is matched case-insensitively. Accepted versions include "1", "1.0", "1.1", "1.0.0" and revisions "1.1.0" through "1.1.6"; later revisions and other major or minor versions are rejected. 32767 selects the newest version in the minor or revision slot, but not the major slot. Loading Core enables bare-name aliases such as Variable, Attribute and DataExtension; Platform.* objects are already available without it. The load spans the whole request, and repeated loads are harmless.
* @param libraryName - Library to load (e.g. "core")
* @param version - Library version (e.g. "1.1.5")
* @example
* Platform.Load("core", "1.1.5");
* var de = DataExtension.Init("MyDE");
* var rows = de.Rows.Retrieve();
*/
function Load(libraryName: string, version: string): null;
/**
* SFMC Platform function API.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/)
*
*/
namespace Function {
/**
* Retrieves a single field value from the first Data Extension row matching filter criteria. The returned value keeps the column's native runtime type (Text/EmailAddress become string, Number/Decimal become number, Boolean becomes boolean, Date becomes a real Date object). Three distinct empty-ish returns: when no row matches it returns a genuine JavaScript null (=== null is true); when a row exists but the field is empty/NULL it returns a CLR null whose typeof is "clr" (=== null is FALSE) and which stringifies to ""; otherwise the populated native value. To filter by multiple columns, pass string arrays for whereFieldNames and whereFieldValues (AND logic). Within a single request the engine caches the query: repeating the same lookup returns the FIRST result even if rows were written in between. The cache key is the (data extension, filter) pair, so the array filter form and a changed returnField are stale too — only a different filter column reads fresh data.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/lookup/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type the return as a string, but at runtime Lookup returns the column's typed value. Runtime-verified per DE field type: Text/EmailAddress/Locale/Phone return a string, Number/Decimal return a number, Boolean returns a boolean, and Date returns a real Date object. No-match returns a genuine JavaScript null. A row with an empty/NULL field returns a CLR null (typeof "clr", not === null) that stringifies to "". Guard empty fields by coercing with String() first: a loose == null throws "Value cannot be null." and a truthiness test throws "Object cannot be cast from DBNull to other types.". Also note the request-scoped query cache — a repeated identical lookup returns the pre-write value.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param returnField - Name of the field to return
* @param whereFieldNames - Filter field name, or an array of field names connected with AND logic
* @param whereFieldValues - Filter field value matching whereFieldNames; must be an array of equal length when whereFieldNames is an array
* @example
* // Single filter:
* var email = Platform.Function.Lookup("Subscribers", "EmailAddress", "SubscriberKey", "abc123");
*
* // Multiple filters (AND logic):
* var phone = Platform.Function.Lookup("CustomerData", "Phone", ["FirstName", "LastName"], ["Carolyn", "Baumgartner"]);
*/
function Lookup(deName: string, returnField: string, whereFieldNames: string | string[], whereFieldValues: string | any[]): string | number | boolean | Date | null;
/**
* Returns an array of row objects from a Data Extension matching filter criteria (up to 2,000 rows). Each row object also carries the system fields _CustomObjectKey (number) and _CreatedDate (string). Returns null (not an empty array) when no row matches. To filter by multiple columns, pass string arrays for whereFieldNames and whereFieldValues (AND logic).
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/lookuprows/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs do not mention that no-match returns null (rather than an empty array) or that each row object includes the system fields _CustomObjectKey and _CreatedDate. Most fields are returned as their typed/native JS value, unlike DataExtension.Rows.Retrieve() which stringifies every field. Runtime-verified per DE field type: Text/EmailAddress/Locale/Phone come back as string, Number/Decimal as number, Boolean as boolean; Date columns are the exception — they come back as an ISO-8601 string (e.g. "2024-01-15T00:00:00.000"), NOT a Date object — this differs from Platform.Function.Lookup, which returns a real Date for Date columns. Runtime testing confirms the return value is a genuine JavaScript Array (Array.isArray is true; .push/.slice/.sort work), so the return type is object[]; note that instanceof Array is unreliable in the SFMC engine, so use the Array.isArray polyfill to test it.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param whereFieldNames - Filter field name, or an array of field names connected with AND logic
* @param whereFieldValues - Filter field value matching whereFieldNames; must be an array of equal length when whereFieldNames is an array
* @example
* // Single filter:
* var rows = Platform.Function.LookupRows("MyDE", "Status", "active");
* for (var i = 0; i < rows.length; i++) {
* Write(rows[i]["Name"] + "
");
* }
*
* // Multiple filters (AND logic):
* var rows2 = Platform.Function.LookupRows("CustomerData", ["PreferredLanguage", "RewardsTier"], ["English", "Gold"]);
*/
function LookupRows(deName: string, whereFieldNames: string | string[], whereFieldValues: string | any[]): object[] | null;
/**
* Returns an ordered array of row objects from a Data Extension. The sort expression is a single string in the format "ColumnName ASC" or "ColumnName DESC". Multiple columns can be separated by commas. Returns up to 2,000 rows; values below 1 for count default to 2,000. Each row object also carries the system fields _CustomObjectKey (number) and _CreatedDate (string). To filter by multiple columns, pass string arrays for whereFieldNames and whereFieldValues (AND logic).
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/lookuporderedrows/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs do not mention that each returned row object includes the system fields _CustomObjectKey and _CreatedDate. Most fields are returned as their typed/native JS value, unlike DataExtension.Rows.Retrieve() which stringifies every field. Runtime-verified per DE field type: Text/EmailAddress/Locale/Phone come back as string, Number/Decimal as number, Boolean as boolean; Date columns are the exception — they come back as an ISO-8601 string (e.g. "2024-01-15T00:00:00.000"), NOT a Date object — this differs from Platform.Function.Lookup, which returns a real Date for Date columns. Runtime testing confirms the return value is a genuine JavaScript Array (Array.isArray is true; .push/.slice/.sort work), so the return type is object[]; note that instanceof Array is unreliable in the SFMC engine, so use the Array.isArray polyfill to test it.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param count - Maximum number of rows to return; values below 1 return up to 2,000
* @param orderBy - Sort expression using "ColumnName ASC/DESC" syntax (e.g. "LastName ASC, FirstName ASC")
* @param whereFieldNames - Filter field name, or an array of field names connected with AND logic
* @param whereFieldValues - Filter field value matching whereFieldNames; must be an array of equal length when whereFieldNames is an array
* @example
* // Single filter, sorted by LastName ASC:
* var rows = Platform.Function.LookupOrderedRows("MyDE", 10, "LastName ASC", "RewardsTier", "Silver");
* for (var i = 0; i < rows.length; i++) {
* Write(rows[i]["Email"] + "
");
* }
*
* // Multiple filters (AND logic):
* var rows2 = Platform.Function.LookupOrderedRows("CustomerData", 0, "LastName ASC", ["PreferredLanguage", "RewardsTier"], ["English", "Silver"]);
*/
function LookupOrderedRows(deName: string, count: string | number, orderBy: string, whereFieldNames: string | string[], whereFieldValues: string | any[]): object[] | null;
/**
* Adds a new row to a Data Extension and returns the number of rows inserted. Recommended for non-sending contexts (CloudPages, landing pages, microsites, and SMS messages), but the *DE variants also run and commit there — see InsertDE().
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/insertdata/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): deName is matched against the data extension's Name only — the external key / CustomerKey is not accepted. Passing the CustomerKey of a data extension whose Name is deliberately a different string throws "The Data Extension name for a InsertData function call is invalid. A Data Extension of this name does not exist.", and a read-back confirmed the rejected call inserted no row.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param fieldNames - Array of column names to populate
* @param fieldValues - Array of values aligned to fieldNames
* @example
* var rowsAffected = Platform.Function.InsertData("MyDE", ["Email", "Name"], ["jane@example.com", "Jane"]);
*/
function InsertData(deName: string, fieldNames: string[], fieldValues: any[]): number;
/**
* Adds a new row to a Data Extension. Returns null (no value). The official docs describe this as an email-context function, but it was proven to run and commit on a CloudPage as well. InsertData() is still preferred outside email because it returns the affected-row count.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/insertde/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs restrict InsertDE to email contexts, but at runtime it executes and commits its insert on a CloudPage too; it returns null rather than a row count.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param fieldNames - Array of column names to populate
* @param fieldValues - Array of values aligned to fieldNames
* @example
* Platform.Function.InsertDE("MyDE", ["Email", "Name"], ["jane@example.com", "Jane"]);
*/
function InsertDE(deName: string, fieldNames: string[], fieldValues: any[]): null;
/**
* Modifies existing rows in a Data Extension matching filter criteria and returns the number of rows updated. All four filter and update name/value arguments require nonempty, positionally aligned arrays. The Data Extension is resolved by Name, not external key.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/updatedata/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs permit scalar filter names and values, but all four filter and update name/value arguments require nonempty, positionally aligned arrays at runtime.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param whereFieldNames - Nonempty array of column names used to identify rows; multiple columns use positional AND logic
* @param whereFieldValues - Nonempty array of values positionally aligned to whereFieldNames
* @param fieldNames - Nonempty array of column names to update
* @param fieldValues - Nonempty array of new values positionally aligned to fieldNames
* @example
* var count = Platform.Function.UpdateData("MyDE", ["Email"], ["jane@example.com"], ["Status"], ["inactive"]);
*/
function UpdateData(deName: string, whereFieldNames: string[], whereFieldValues: any[], fieldNames: string[], fieldValues: any[]): number;
/**
* Modifies existing rows in a Data Extension matching filter criteria and returns null. All four filter and update name/value arguments require nonempty, positionally aligned arrays. It also executes and commits on CloudPages despite the documented email-context restriction.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/updatede/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. All four filter and update name/value arguments require nonempty, positionally aligned arrays despite the documented scalar filter forms. UpdateDE returns null rather than an affected-row count and commits on CloudPages despite the documented email-context restriction.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param whereFieldNames - Nonempty array of column names used to identify rows; multiple columns use positional AND logic
* @param whereFieldValues - Nonempty array of values positionally aligned to whereFieldNames
* @param fieldNames - Nonempty array of column names to update
* @param fieldValues - Nonempty array of new values positionally aligned to fieldNames
* @example
* Platform.Function.UpdateDE("MyDE", ["Email"], ["jane@example.com"], ["Status"], ["inactive"]);
*/
function UpdateDE(deName: string, whereFieldNames: string[], whereFieldValues: any[], fieldNames: string[], fieldValues: any[]): null;
/**
* Inserts a new row or updates an existing one in a Data Extension and returns the number of rows affected. Takes array arguments for the where and field pairs — a flat/variadic argument form is not supported and throws at runtime. Recommended for non-sending contexts (CloudPages, landing pages), but the *DE variants also run and commit there — see UpsertDE().
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/upsertdata/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the docs allow whereFieldNames and whereFieldValues to be plain strings for a single-column filter, but a scalar in either position aborts the call with "Unable to retrieve security descriptor for this frame." — reproduced independently in two separate chapters. Wrap the single filter column and its value in one-element arrays instead; that form both inserted and updated in the same run. The flat/variadic argument form is likewise unsupported and throws.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param whereFieldNames - Column name(s) to identify an existing row; use an array for multiple columns (AND logic)
* @param whereFieldValues - Value(s) to match in whereFieldNames; must be an array of equal length when whereFieldNames is an array
* @param fieldNames - Array of column names to insert or update
* @param fieldValues - Array of values aligned to fieldNames
* @example
* var count = Platform.Function.UpsertData("CustomerData", ["ID"], ["12345"], ["Company", "Country"], ["exampleCompany", "USA"]);
*/
function UpsertData(deName: string, whereFieldNames: string | string[], whereFieldValues: string | any[], fieldNames: string[], fieldValues: any[]): number;
/**
* Inserts one row when no filter match exists or updates every matching row in a Data Extension. The Data Extension is resolved by Name, not external key. UpsertDE returns null, runs on CloudPages despite the documented sendable-context restriction, and requires arrays even for a single filter or field. UpsertData() is preferred outside email when the affected-row count is needed.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/upsertde/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Contrary to the official scalar-or-array types, all four filter and field name/value arguments require nonempty, positionally aligned arrays. The documented numeric result is also incorrect: inserts and updates return null. UpsertDE also executes and commits on CloudPages despite the documented sendable-context restriction.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param whereFieldNames - Nonempty array of column names used to find existing rows; multiple columns use positional AND logic
* @param whereFieldValues - Nonempty array of values positionally aligned to whereFieldNames
* @param fieldNames - Nonempty array of column names to insert or update
* @param fieldValues - Nonempty array of values positionally aligned to fieldNames
* @example
* Platform.Function.UpsertDE("CustomerData", ["ID"], ["12345"], ["Company", "Country"], ["exampleCompany", "USA"]);
*/
function UpsertDE(deName: string, whereFieldNames: string[], whereFieldValues: any[], fieldNames: string[], fieldValues: any[]): null;
/**
* Removes rows from a Data Extension matching filter criteria and returns the number of rows deleted. Recommended for non-sending contexts (CloudPages, landing pages, microsites, and SMS messages), but the *DE variants also run and commit there — see DeleteDE().
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/deletedata/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): deName is matched against the data extension's Name only — the external key / CustomerKey is not accepted. Passing the CustomerKey of a data extension whose Name is deliberately a different string throws "The Data Extension name for a DeleteData function call is invalid. A Data Extension of this name does not exist.", and a follow-up call by Name still deleted the row — proving the rejected key call removed nothing.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param whereFieldNames - Array of column names to match for deletion
* @param whereFieldValues - Array of values aligned to whereFieldNames that identify rows to delete
* @example
* var count = Platform.Function.DeleteData("MyDE", ["Email"], ["jane@example.com"]);
*/
function DeleteData(deName: string, whereFieldNames: string[], whereFieldValues: any[]): number;
/**
* Removes rows from a Data Extension matching filter criteria. Returns null (no value). The official docs describe this as an email-context function, but it was proven to run and commit on a CloudPage as well. DeleteData() is still preferred outside email because it returns the affected-row count.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/deletede/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs restrict DeleteDE to email contexts, but at runtime it executes and commits its delete on a CloudPage too; it returns null rather than a row count.
* @param deName - Data Extension name (resolved by Name, not external key)
* @param whereFieldNames - Array of column names to match for deletion
* @param whereFieldValues - Array of values aligned to whereFieldNames that identify rows to delete
* @example
* Platform.Function.DeleteDE("MyDE", ["Email"], ["jane@example.com"]);
*/
function DeleteDE(deName: string, whereFieldNames: string[], whereFieldValues: any[]): null;
/**
* Renders a Content Builder asset referenced by customer key. Runtime note: when optional arguments are supplied, every argument must be a compile-time literal — passing a variable in a multi-argument call throws a resolved-value error.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/contentblockbykey/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs do not mention that supplying the optional arguments requires every argument to be a compile-time literal; variables are rejected at runtime once more than the key is passed.
* @param customerKey - Customer key of the Content Builder asset
* @param regionName - Impression region name for tracking
* @param stopOnError - When true, returns an exception and terminates if content cannot be retrieved. When false, the call proceeds.
* @param fallbackContent - Default content to display if the call does not return content
* @example
* var html = Platform.Function.ContentBlockByKey("my-header-block");
* Write(html);
*
* // With optional params:
* var html2 = Platform.Function.ContentBlockByKey("my-header-block", "impressionRegion", false, "defaultContent");
*/
function ContentBlockByKey(customerKey: string, regionName?: string, stopOnError?: boolean, fallbackContent?: string): string;
/**
* Renders a Content Builder asset referenced by folder path and name. If the same name is used across multiple folders, supply the full path. Runtime note: when optional arguments are supplied, every argument must be a compile-time literal.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/contentblockbyname/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): only the single-argument form works from SSJS, and folder paths must be separated by a BACKSLASH — a forward-slash path always throws. Any 2nd argument — string literal, number, boolean, empty string, null or variable, including a closure-free top-level all-literal call — is rejected with "invalid parameter value ... Parameter Name: ImpressionRegionName, Parameter Ordinal: 2, Parameter Type: ResolvedValueParameter", so regionName, stopOnError and fallbackContent cannot be supplied; statusVariable is unreachable for a separate reason, because arity 5 throws "Unable to retrieve security descriptor for this frame" before the parameter check runs. A name that does not resolve THROWS rather than returning an empty string or the fallback, so callers must wrap the call in try/catch. A bare asset name resolves at any folder depth, so the path is only a disambiguator, and a literal ending in a backslash aborts the page with an uncatchable HTTP 422. Use Platform.Function.TreatAsContent() with the AMPscript form when the optional parameters are needed — it honours all five.
* @param name - Folder path and name of the Content Builder asset
* @param regionName - Impression region name for tracking
* @param stopOnError - When true, returns an error if the content area cannot be found or is invalid. When false, no error is returned.
* @param fallbackContent - Default content to return if an error occurs. Defaults to empty string.
* @param statusVariable - Receives the status of the call: 0 = success, -1 = no content or invalid content area
* @example
* var html = Platform.Function.ContentBlockByName("Shared Content/Footer");
* Write(html);
*/
function ContentBlockByName(name: string, regionName?: string, stopOnError?: boolean, fallbackContent?: string, statusVariable?: number): string;
/**
* Renders a Content Builder asset by its numeric identifier. Runtime note: when optional arguments are supplied, every argument must be a compile-time literal.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/contentblockbyid/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): only the single-argument form works from SSJS. Any 2nd argument — string literal, number, boolean, empty string, null or variable, including a closure-free top-level all-literal call — is rejected with "invalid parameter value ... Parameter Name: ImpressionRegionName, Parameter Ordinal: 2, Parameter Type: ResolvedValueParameter", which is neither a literal-vs-variable rule nor a test-harness artefact. Because parameter 2 is rejected first, stopOnError and fallbackContent are unreachable: both stopOnError=true and stopOnError=false throw, and the fallback string is never emitted — even when the referenced block exists. Use Platform.Function.TreatAsContent() with the AMPscript form when the optional parameters are needed.
* @param id - Numeric ID of the Content Builder asset
* @param regionName - Impression region name for tracking
* @param stopOnError - When true, returns an exception and terminates if content cannot be retrieved. When false, the call proceeds.
* @param fallbackContent - Default content to display if the call does not return content
* @example
* var html = Platform.Function.ContentBlockByID(12345);
* Write(html);
*
* // With optional params:
* var html2 = Platform.Function.ContentBlockByID(12345, "impressionRegion", false, "defaultContent");
*/
function ContentBlockByID(id: string | number, regionName?: string, stopOnError?: boolean, fallbackContent?: string): string;
/**
* Returns an HTML img tag for a Content Builder image identified by its external key. An optional fallback image ID can be supplied if the primary image is not found.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/contentimagebykey/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the Content Builder image
* @param fallbackId - Numeric ID of a fallback image when the primary cannot be found
* @example
* var imgTag = Platform.Function.ContentImageByKey("hero-banner-key");
* Write(imgTag);
*/
function ContentImageByKey(key: string, fallbackId?: number): string;
/**
* Returns an HTML img tag for a Content Builder image identified by its numeric ID. An optional fallback ID can be supplied if the primary image is not found.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/contentimagebyid/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param id - Numeric ID of the Content Builder image
* @param fallbackId - Numeric ID of a fallback image when the primary cannot be found
* @example
* var imgTag = Platform.Function.ContentImageByID(98765);
* Write(imgTag);
*/
function ContentImageByID(id: string | number, fallbackId?: string | number): string;
/**
* Processes a string as AMPscript/HTML on the SFMC server and returns the rendered result directly as a string. Inline AMPscript (%%=..=%%) is returned in the result; a block-only %%[..]%% string renders to an empty string but its variable side effects persist and are readable by later calls. Does not require Platform.Load("core").
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/treatascontent/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param content - String containing AMPscript or HTML to evaluate (non-string values are coerced to string)
* @example
* var result = Platform.Function.TreatAsContent("%%=Add(2,3)=%%");
* Write(result); // "5"
*/
function TreatAsContent(content: string): string;
/**
* Marks the start of a named impression tracking region within content. Runtime note: the region name must be a compile-time literal — a variable is rejected with a resolved-value error.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/beginimpressionregion/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs do not mention that the region name must be a compile-time literal; a variable argument is rejected at runtime.
* @param name - Name identifying the impression region
* @example
* Platform.Function.BeginImpressionRegion("hero-banner");
* Write(heroContent);
* Platform.Function.EndImpressionRegion();
*/
function BeginImpressionRegion(name: string): void;
/**
* Marks the end of an impression tracking region within content.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/endimpressionregion/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type the return as void, but the runtime always returns a genuine null (typeof "object", === null) — including when called with no matching BeginImpressionRegion.
* @param closeAll - When true, closes all nested impression regions
* @example
* Platform.Function.BeginImpressionRegion("footer");
* Write(footerContent);
* Platform.Function.EndImpressionRegion();
*/
function EndImpressionRegion(closeAll?: string | boolean | number): null;
/**
* Returns the current server date/time as a Date object (in the account timezone, Central by default), or the timestamp of the triggering send when called with true. Concatenating it to a string yields an RFC 2822-style value such as "Tue, 14 Jul 2026 17:59:40 GMT-06:00".
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/now/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the official docs describe the return as an RFC 2822-compliant date-time string, but the runtime returns a genuine Date object — typeof "object", `Object.prototype.toString` reports "[object Date]", `.constructor === Date`, and `getFullYear()`/`getHours()`/`getTime()` all work (identical to `new Date()`). The only anomaly is that `instanceof Date` returns false, due to the engine-wide `instanceof`-on-builtins bug (also affects Array/RegExp/Function) — detect via `.constructor === Date`, not `instanceof`. It coerces to an RFC 2822-style string during output. useContextTime also accepts number 0/1 and the strings "true"/"false".
* @param useContextTime - When true, returns the time the triggering send or activity was initiated. When false or omitted, returns the current system clock time. Also accepts number 0/1 and the strings "true"/"false".
* @example
* var current = Platform.Function.Now();
* Write(current); // e.g. "Tue, 14 Jul 2026 17:59:40 GMT-06:00"
*
* // current is a Date object:
* Write(current.getFullYear()); // 2026
*
* // Use context time during triggered sends:
* var sendTime = Platform.Function.Now(true);
*/
function Now(useContextTime?: string | boolean | number): Date;
/**
* Converts a date-time value from Marketing Cloud system time (CST, without daylight saving) to the local time of the account or user. Returns a Date object (not a string).
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/systemdatetolocaldate/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the official docs type the return value as a string, but the runtime returns a genuine Date object — typeof "object", `Object.prototype.toString` reports "[object Date]", `.constructor === Date`, and `getFullYear()`/`getHours()`/`getTime()` all work (identical to `new Date()`). The only anomaly is that `instanceof Date` returns false, due to the engine-wide `instanceof`-on-builtins bug — detect via `.constructor === Date`, not `instanceof`. It coerces to an ISO-like string when written or stringified.
* @param dateString - Date-time value in system time (CST) (string or Date)
* @example
* var systemDate = Platform.Function.Now();
* var localDate = Platform.Function.SystemDateToLocalDate(systemDate);
* Write(localDate);
*/
function SystemDateToLocalDate(dateString: string | Date): Date;
/**
* Converts a date-time value from the local time of the account or user to Marketing Cloud system time (CST, without daylight saving). Returns a Date object (not a string).
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/localdatetosystemdate/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the official docs type the return value as a string, but the runtime returns a genuine Date object — typeof "object", `Object.prototype.toString` reports "[object Date]", `.constructor === Date`, and `getFullYear()`/`getHours()`/`getTime()` all work (identical to `new Date()`). The only anomaly is that `instanceof Date` returns false, due to the engine-wide `instanceof`-on-builtins bug — detect via `.constructor === Date`, not `instanceof`. It coerces to an ISO-like string when written or stringified.
* @param dateString - Date-time value in local account/user time (string or Date)
* @example
* var localDate = "8/5/2025 12:00:00 PM";
* var systemDate = Platform.Function.LocalDateToSystemDate(localDate);
* Write(systemDate);
*/
function LocalDateToSystemDate(dateString: string | Date): Date;
/**
* Raises an error with an optional scope flag. When the second parameter is true, the error stops only the current recipient's send. When false, the error halts the entire send job.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/raiseerror/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs mark currentRecipientOnly, errorCode, and errorNumber as required, but the runtime accepts a single message argument; and the caught exception on a CloudPage exposes only message and description (an AMPScriptRaiseErrorException) — the errorCode and errorNumber values are not surfaced on the error object.
* @param message - Error message describing what went wrong
* @param currentRecipientOnly - When true, the error applies only to the current recipient. When false, the entire send job stops.
* @param errorCode - Short user-defined code identifying the error type
* @param errorNumber - User-defined numeric error code for reference
* @example
* var status = Platform.Function.Lookup("MyDE", "Status", "Email", emailAddress);
* if (!status) {
* Platform.Function.RaiseError("Subscriber not found", true, "NOT_FOUND", 404);
* }
*/
function RaiseError(message: string, currentRecipientOnly?: boolean, errorCode?: string | number, errorNumber?: string | number): void;
/**
* Generates a new globally unique identifier as a lowercase canonical UUID v4 string (36 characters). Does not require Platform.Load("core"); passing any argument throws.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/guid/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var id = Platform.Function.GUID();
* Write(id); // e.g. "550e8400-e29b-41d4-a716-446655440000"
*/
function GUID(): string;
/**
* Checks whether a string is a valid email address format.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/isemailaddress/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param value - String to validate
* @example
* if (Platform.Function.IsEmailAddress(emailInput)) {
* Write("Valid email");
* } else {
* Write("Invalid email format");
* }
*/
function IsEmailAddress(value: string): boolean;
/**
* Evaluates whether a string is a valid phone number and returns a boolean. Runtime-verified (CloudPage): the accepted format is digits 0-9 only, with no spaces and no leading 0. To present any country's country code (including the US) you omit the leading 00/+ and write the country code as bare digits with no leading zero. Values containing spaces, a leading 0, or a +/00 international prefix return false, as do empty, letters, and mixed-text inputs. This is the same digits-only, no-leading-zero format that SFMC phone-number fields and the SMS (MobileConnect) service expect.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/isphonenumber/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs describe generic "valid phone number" validation, but the runtime enforces a stricter format: digits 0-9 only, no spaces, and no leading 0 — country codes must be written without the leading 00/+ (the same format SFMC phone fields and the SMS service expect).
* @param value - Value to evaluate
* @example
* if (Platform.Function.IsPhoneNumber(phoneInput)) {
* Write("Valid phone");
* } else {
* Write("Invalid phone number");
* }
*/
function IsPhoneNumber(value: string | number): boolean;
/**
* Instantiates a Marketing Cloud SOAP API object.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/createobject/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the docs type the return value as a plain object, but the instance is a .NET CLR host object — typeof reports "clr" for DataExtensionObject, Subscriber and APIProperty alike. Properties assigned with SetObjectProperty() or AddObjectArrayItem() therefore cannot be read back from SSJS; unreadable is not unset, so the only way to prove a value landed is to submit the object through an Invoke* call and read the result from the API.
* @param objectType - SOAP API object type name
* @example
* var sub = Platform.Function.CreateObject("Subscriber");
* Platform.Function.SetObjectProperty(sub, "EmailAddress", "jane@example.com");
* Platform.Function.SetObjectProperty(sub, "SubscriberKey", "sk-123");
*/
function CreateObject(objectType: string): object;
/**
* Assigns a property value on a SOAP API object created with CreateObject. The property name is validated against the object's real SOAP API schema at set-time: setting an unknown property (or a value the property rejects) throws. String and number values are accepted; the assigned property cannot be read back from SSJS because the underlying CLR object blocks introspection. Returns a genuine JavaScript null on success.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/setobjectproperty/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type the return as void, but at runtime SetObjectProperty returns a genuine JavaScript null (=== null is true) on success. It also validates the property name against the object schema, throwing when the property is unknown or the value is invalid for it.
* @param apiObject - SOAP API object instance
* @param propertyName - Property name to set
* @param value - Value to assign
* @example
* var sub = Platform.Function.CreateObject("Subscriber");
* Platform.Function.SetObjectProperty(sub, "EmailAddress", "jane@example.com");
*/
function SetObjectProperty(apiObject: object, propertyName: string, value: any): null;
/**
* Appends an item to a SOAP API object's array property.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/addobjectarrayitem/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type a returned object, but at runtime the call returns a genuine JavaScript null (typeof "object", === null, String() "null") and mutates the passed object in place.
* @param apiObject - SOAP API object instance
* @param propertyName - Array property name
* @param value - Item to append
* @example
* var ts = Platform.Function.CreateObject("TriggeredSend");
* Platform.Function.AddObjectArrayItem(ts, "Subscribers", sub);
*/
function AddObjectArrayItem(apiObject: object, propertyName: string, value: any): null;
/**
* Executes a SOAP API Create call on an API object and returns the OverallStatus message as a string.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/invokecreate/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type the return value as an object, but at runtime the call returns the OverallStatus message as a string ("OK" / "Error: ..."); the request ID is written to status[1] and the error code (a number) is written into the status array.
* @param apiObject - SOAP API object instance
* @param status - Array that receives the status message and request ID of the API call (e.g. [0, 0]); status[0] is the message string, status[1] the request ID
* @param options - API configure options to include in the call. Can contain a null value.
* @example
* var StatusAndRequestID = [0, 0];
* var result = Platform.Function.InvokeCreate(CreateRequest, StatusAndRequestID, null);
* var status = StatusAndRequestID[0];
* var requestID = StatusAndRequestID[1];
*/
function InvokeCreate(apiObject: object, status: any[], options: object): string;
/**
* Executes a SOAP API Update call on an API object and returns the OverallStatus message as a string.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/invokeupdate/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type the return value as an object, but at runtime the call returns the OverallStatus message as a string ("OK" / "Error: ..."); the request ID is written to status[1] and the error code (a number) is written into the status array.
* @param apiObject - SOAP API object instance
* @param status - Array that receives the status message and request ID of the API call (e.g. [0, 0]); status[0] is the message string, status[1] the request ID
* @param options - API configure options to include in the call. Can contain a null value.
* @example
* var StatusAndRequestID = [0, 0];
* var result = Platform.Function.InvokeUpdate(UpdateRequest, StatusAndRequestID, null);
* var status = StatusAndRequestID[0];
* var requestID = StatusAndRequestID[1];
*/
function InvokeUpdate(apiObject: object, status: any[], options: object): string;
/**
* Executes a SOAP API Delete call on an API object and returns the OverallStatus message as a string.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/invokedelete/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type the return value as an object, but at runtime the call returns the OverallStatus message as a string ("OK" / "Error: ..."); the request ID is written to status[1] and the error code (a number) is written into the status array.
* @param apiObject - SOAP API object instance
* @param status - Array that receives the status message and request ID of the API call (e.g. [0, 0]); status[0] is the message string, status[1] the request ID
* @param options - API configure options to include in the call. Can contain a null value.
* @example
* var StatusAndRequestID = [0, 0];
* var result = Platform.Function.InvokeDelete(DeleteRequest, StatusAndRequestID, null);
* var status = StatusAndRequestID[0];
* var requestID = StatusAndRequestID[1];
*/
function InvokeDelete(apiObject: object, status: any[], options: object): string;
/**
* Executes a SOAP API Retrieve call, returning an array of result objects when records match or null on error / no match.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/invokeretrieve/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs do not mention the null return: at runtime the call returns an array of result objects when records match, but returns null on error or when no records match.
* @param apiObject - SOAP API RetrieveRequest object instance
* @param status - Status out-parameter required by the signature, but inert at runtime — it is never populated (stays empty even on success, so status[0] and status[1] are undefined). Pass an array (e.g. [0, 0]); read the returned array for results.
* @example
* var RetrieveRequest = Platform.Function.CreateObject("RetrieveRequest");
* Platform.Function.SetObjectProperty(RetrieveRequest, "ObjectType", "Email");
* Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "Email.Name");
* var StatusAndRequestID = [0, 0];
* var Emails = Platform.Function.InvokeRetrieve(RetrieveRequest, StatusAndRequestID);
*/
function InvokeRetrieve(apiObject: object, status: any[]): object[] | null;
/**
* Executes a SOAP API Perform action on an API object and returns the OverallStatus message as a string.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/invokeperform/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type the return value as an object, but the SOAP Perform contract returns the OverallStatus message as a string; the error code and perform response are written into the status array.
* @param apiObject - SOAP API object instance
* @param method - Method to perform on the object
* @param status - Array that receives the status, error code, and perform response of the API call (e.g. [0, 0, 0])
* @param options - API configure options to include in the call. Can be omitted or null.
* @example
* var StatusAndRequestID = [0, 0, 0];
* var result = Platform.Function.InvokePerform(APIObject, "Validate", StatusAndRequestID, null);
* var statusMessage = StatusAndRequestID[0];
* var errorCode = StatusAndRequestID[1];
* var performResponse = StatusAndRequestID[2];
*/
function InvokePerform(apiObject: object, method: string, status: any[], options?: object): string;
/**
* Executes a SOAP API Configure call on an API object and returns the OverallStatus message as a string.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/invokeconfigure/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type the return value as an object, but the SOAP Configure contract returns the OverallStatus message as a string; the request ID is written into the status array.
* @param apiObject - SOAP API object instance
* @param method - Method to perform on the object
* @param status - Array that receives the status and request ID of the API call (e.g. [0, 0])
* @param options - API configure options to include in the call. Can contain a null value.
* @example
* var StatusAndRequestID = [0, 0];
* var result = Platform.Function.InvokeConfigure(ConfigureObject, "create", StatusAndRequestID, null);
*/
function InvokeConfigure(apiObject: object, method: string, status: any[], options: object): string;
/**
* Executes a SOAP API Execute call on an API object and returns an array of result objects. Takes exactly two arguments.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/invokeexecute/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs list three arguments (including an options object) and type the return value as an object, but at runtime the call takes exactly two arguments (apiObject, status) — passing the documented third argument throws "Unable to retrieve security descriptor for this frame." — and returns an array of result objects.
* @param apiObject - SOAP API object instance
* @param status - Status out-parameter required by the signature, but inert at runtime — it is never populated (stays empty even on success). Pass an array (e.g. [0, 0]); read the returned array for results, where each element may carry its own StatusCode/StatusMessage/ErrorCode as data.
* @example
* var StatusAndRequestID = [0, 0];
* var result = Platform.Function.InvokeExecute(ExecuteRequest, StatusAndRequestID);
* var firstResult = result[0];
*/
function InvokeExecute(apiObject: object, status: any[]): object[];
/**
* Invokes the Extract SOAP API method on the specified object. The docs describe the return as the OverallStatus message string; that string was not reproducible from a CloudPage invoke.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/invokeextract/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs list a third options argument and type the return value as an object; at runtime the call takes exactly two arguments (a third throws) and the statusArray is inert (never populated). The documented OverallStatus string return could not be reproduced from a CloudPage even against real saved Data Extract definitions: every two-argument call throws a catchable exception carrying only the generic wrapper message "An error occurred when attempting to evaluate an InvokeExtract function call. See inner exception for details.", and the inner exception is not surfaced to SSJS, so the cause is not observable. The string return type is per-docs and unproven at runtime.
* @param apiObject - SOAP API object on which to invoke Extract
* @param statusArray - Status out-parameter required by the signature, but inert at runtime — it is never populated. Pass an array (e.g. [0, 0]).
* @example
* var statusArr = [0, 0];
* var result = Platform.Function.InvokeExtract(extractObj, statusArr);
* Write(result);
*/
function InvokeExtract(apiObject: object, statusArray: any[]): string;
/**
* Invokes the Schedule SOAP API method on the specified object and returns the OverallStatus message as a string.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/invokeschedule/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type the return value as an object, but at runtime the call returns the OverallStatus message as a string; the statusArray argument is required (minimum four arguments), with the trailing options argument optional.
* @param apiObject - SOAP API object on which to invoke Schedule
* @param action - Action to perform on the object
* @param schedule - Schedule definition object
* @param statusArray - Array that receives the status and RequestID of the API call
* @param options - Additional API options; may be null
* @example
* var statusArr = [];
* var result = Platform.Function.InvokeSchedule(sendDef, "start", scheduleDef, statusArr);
* Write(result);
*/
function InvokeSchedule(apiObject: object, action: string, schedule: object, statusArray: any[], options?: object): string;
/**
* Performs an HTTP GET request and returns the response body as a string. Only works with HTTP on port 80 and HTTPS on port 443. Times out after 30 seconds. Valid call forms are exactly two: HTTPGet(url) with a single argument, or the full 6-argument form; passing 2-5 arguments is an argument count it does not accept and throws the generic "Unable to retrieve security descriptor for this frame." error. The statusVariable out-parameter is unreliable (observed empty even on success), so read the body from the return value.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/httpget/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a CloudPage. Three corrections to the official docs. (1) The docs state this returns a numeric status, but it actually returns the response body as a string. (2) The argument count is a discontinuous overload, not a simple range: only a 1-argument call (url only) or the full 6-argument call are valid. Calling with 2, 3, 4, or 5 arguments throws "Unable to retrieve security descriptor for this frame." The trailing five arguments (continueOnError, emptyContentHandling, headerNames, headerValues, statusVariable) form an all-or-nothing group — you must supply all five together or none. This contradicts the older claim that "all six arguments are required" (the 1-argument form works) as well as the docs listing arguments 3-6 as independently optional. (3) Even on a successful 6-argument call the statusVariable out-parameter was observed empty (statusVariable.length === 0, statusVariable[0] === undefined), so the numeric status is not reliably delivered in a CloudPage context — read the returned body string and do not depend on statusVariable[0].
* @param url - URL to request
* @param continueOnError - When true, the request terminates if an error occurs. When false, the request continues on error. Only valid in the 6-argument form; the trailing five arguments are all-or-nothing.
* @param emptyContentHandling - How to handle a URL that returns empty content: 0 = allow empty, 1 = return error, 2 = skip subscriber. Only valid in the 6-argument form (co-required with the other trailing arguments).
* @param headerNames - Array of header names to include in the GET request (pass null when none). Only valid in the 6-argument form (co-required with the other trailing arguments).
* @param headerValues - Array of header values corresponding to headerNames (pass null when none). Only valid in the 6-argument form (co-required with the other trailing arguments).
* @param statusVariable - Array intended to receive the status code, but observed empty at runtime even on success — do not rely on it. Only valid in the 6-argument form (co-required with the other trailing arguments).
* @example
* // Valid form 1 - single argument, returns the response body as a string
* var body = Platform.Function.HTTPGet("https://api.example.com/data");
* var obj = Platform.Function.ParseJSON(body);
*
* // Valid form 2 - full 6-argument form (the trailing five are all-or-nothing)
* var status = [];
* var content = Platform.Function.HTTPGet(
* "https://api.example.com/data",
* false,
* 0,
* ["x-request-id"],
* ["sampleValue"],
* status
* );
* // Note: status[0] is unreliable (observed empty); read the body from `content`.
* var parsed = Platform.Function.ParseJSON(content);
*/
function HTTPGet(url: string, continueOnError?: boolean, emptyContentHandling?: string | number, headerNames?: string[], headerValues?: string[], statusVariable?: number[]): string;
/**
* Performs an HTTP POST request with a content type and payload. Only works with HTTP on port 80 and HTTPS on port 443. Times out after 30 seconds. Returns the HTTP status code as a number (e.g. 200 for success). The optional response out-parameter is unreliable — in runtime tests it stayed empty even for successful requests, so read the status code from the return value and use HTTP.Post / a WSProxy call when you need the response body.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/httppost/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a CloudPage. Three corrections to the official docs. (1) The argument count is a discontinuous overload, not a simple range: only a 3-argument call (url, contentType, payload) or the full 6-argument call are valid. Calling with 4 or 5 arguments throws "Unable to retrieve security descriptor for this frame." The trailing three arguments (headerNames, headerValues, response) form an all-or-nothing group, so the docs listing them as independently optional is wrong. (2) A 4xx or 5xx response is never handed back as a status code — it throws "An error occurred when attempting to evaluate a HTTPPost function call. See inner exception for details." The docs branch on statusCode == 200 as if a failing status were observable; it is not, so wrap the call in try/catch. Successful 2xx statuses (200, 201, 204) from the same host are returned normally, which rules out a transport-level explanation. (3) Even on a successful call the response out-parameter was observed empty (response.length === 0, response[0] === undefined), so the body is not delivered in a CloudPage context — use HTTP.Post when you need the response body.
* @param url - URL to post to
* @param contentType - MIME type of the request body
* @param payload - Request body content
* @param headerNames - Array of header names (co-required with headerValues)
* @param headerValues - Array of header values corresponding to headerNames (co-required)
* @param response - Array intended to receive the response body. Unreliable — observed empty even on successful (200) responses; do not depend on it.
* @example
* var statusCode = Platform.Function.HTTPPost(
* "https://api.example.com/items",
* "application/json",
* Stringify({ name: "Jane", status: "active" })
* );
* if (statusCode == 200) { Write("posted"); }
*/
function HTTPPost(url: string, contentType: string, payload: string, headerNames?: string[], headerValues?: string[], response?: any[]): number;
/**
* Parses a JSON-formatted string (also accepts boolean or number) and returns the resulting JavaScript object or array. SFMC-native equivalent of JSON.parse(), which is not available in the legacy SSJS engine. Only single JSON object/array strings are deserialised; scalar JSON values are returned as strings and invalid, empty, null, or undefined input returns null (no error is thrown). A boolean argument yields CLR "True"/"False" strings. Passing an array or other object throws a runtime error.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/parsejson/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a CloudPage. Two corrections to the official docs: (1) The docs type the argument as `string or string[]` and describe passing an "array of strings"; at runtime passing an array (or any non-string object) throws `System.InvalidOperationException: Unable to retrieve security descriptor for this frame`. A single string, boolean, or number is accepted: a number matches ParseJSON of the equivalent numeric string; a boolean yields the CLR strings "True"/"False" (not JSON boolean primitives and not equal to ParseJSON("true")/"false"). (2) The docs return type `object|object[]` is incomplete: only JSON objects/arrays are deserialised; a scalar JSON string ("42", "\"hello\"", "true", "null") is returned unchanged as a string, and invalid/empty/null/undefined input returns null (it does NOT throw).
* @param jsonString - A JSON-formatted string, boolean, or number to parse. A number yields the same result as the equivalent numeric string. A boolean is accepted but returns CLR "True"/"False" (not JSON boolean primitives). Passing an array or other object throws a runtime error (contrary to the official docs).
* @example
* var jsonString = '{"name":"Jane","age":30}';
* var obj = Platform.Function.ParseJSON(jsonString);
* Write(obj.name); // outputs: Jane
*
* // Invalid or empty input returns null (it does NOT throw):
* var bad = Platform.Function.ParseJSON("{not json");
* if (bad === null) { Write("could not parse"); }
*
* // Use String() to convert CLR response content before parsing:
* var req = new Script.Util.HttpRequest("https://api.example.com/data");
* req.method = "GET";
* var resp = req.send();
* var result = Platform.Function.ParseJSON(String(resp.content));
*/
function ParseJSON(jsonString: string | boolean | number): any;
/**
* Specifies the target of an email link as a complete URL stored in an attribute, data extension field, or variable. Use only within the href attribute of an anchor tag in HTML emails. In text emails, add the http:// prefix without spaces inside the parentheses. Include anchor tags in the email body (not in retrieved link content) to retain click-tracking.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/redirectto/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs imply no return value, but at runtime RedirectTo returns the passed-in URL string (typeof "string") and does not issue an HTTP redirect nor halt execution when called from SSJS; it requires exactly one argument (zero or two arguments throw a TypeError).
* @param url - The URL to redirect to
* @example
* var email = "aruiz@example.com";
* var firstName = "Angela";
* var baseUrl = "https://example.com?email=";
* var nameJoin = "&name=";
* Platform.Function.RedirectTo(baseUrl.concat(email, nameJoin, firstName));
* // Use inside href: link
*/
function RedirectTo(url: string): string;
/**
* Percent-encodes only the query string after the first question mark; a URL without one is returned unchanged. The default mode encodes spaces as %20. Reserved-encoding mode uses + for spaces and lowercase percent escapes for characters outside alphanumerics and - _ . ! * ( ).
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/urlencode/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The documented reserved set does not match the runtime: ! * ( ) pass through, while " % < >, backslash, ^ ` { | } and ~ are encoded. The effective passthrough set is alphanumerics plus - _ . ! * ( ). Only the query string after the first question mark is processed, so this function cannot encode an arbitrary value. Escapes use lowercase hex; non-ASCII characters are encoded as lowercase UTF-8 byte escapes only in reserved-encoding mode.
* @param url - Complete URL whose query string is encoded
* @param encodeReservedKeywords - When true, encodes every character outside the passthrough set; spaces become +. When false (default), only spaces are encoded as %20.
* @example
* var baseURL = "https://www.example.com?value=12+3 12;3";
* var encoded = Platform.Function.UrlEncode(baseURL);
* Write(encoded); // "https://www.example.com?value=12+3%2012;3"
* var encodedFull = Platform.Function.UrlEncode(baseURL, true);
* Write(encodedFull); // "https://www.example.com?value%3d12%2b3+12%3b3"
*/
function UrlEncode(url: string, encodeReservedKeywords?: boolean): string;
/**
* Encodes any string value to standard Base64. The optional charset controls the byte encoding. The result is interoperable standard Base64 and can be decoded by any Base64 decoder. For a simpler single-parameter form without charset control, see `Base64Encode()`.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/base64encode/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs claim output can only be decoded by the matching Base64Decode() function, but the runtime produces standard interoperable Base64 that any decoder accepts.
* @param string - String to encode
* @param charset - Character set to use when encoding, such as ASCII or UTF-8
* @example
* var normalStr = Platform.Function.Lookup("ForBase64Info","ReceiptData","ReceiptKey","stringValue");
* var encodedStr = Platform.Function.Base64Encode(normalStr);
*/
function Base64Encode(string: string, charset?: string): string;
/**
* Decodes a standard Base64-encoded string. The optional charset controls how the decoded bytes are interpreted. It decodes any valid standard Base64 string, not only values produced by `Base64Encode()`.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/base64decode/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs imply it only decodes values created by the matching Base64Encode() function, but the runtime decodes any valid standard Base64 string.
* @param encodedString - Base64 encoded string to decode
* @param charset - Character set to use when decoding, such as ASCII or UTF-8
* @example
* var encodedStr = Platform.Function.Lookup("forBase64Info","ReceiptData","ReceiptKey","stringValue");
* var decodedStr = Platform.Function.Base64Decode(encodedStr);
*/
function Base64Decode(encodedString: string, charset?: string): string;
/**
* Returns a lowercase 32-character hexadecimal MD5 hash for a given string value. The optional charset only affects non-ASCII input and defaults to UTF-8.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/md5/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param string - String to evaluate
* @param charset - Character set to use when evaluating, such as ASCII or UTF-8
* @example
* var normalStr = Platform.Function.Lookup("ForMD5Info","HashData","HashKey","stringValue");
* var hashedStr = Platform.Function.MD5(normalStr);
*/
function MD5(string: string, charset?: string): string;
/**
* Converts a JavaScript object into its JSON string representation. Works only with known JSON-serializable types. Not to be confused with `String()`, which converts CLR response objects to plain strings. The bare-name Stringify() global is equivalent but requires Platform.Load("core","1.1.5"); this Platform.Function form works without it.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/stringify/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param value - Value to serialize to JSON. Accepts objects, arrays, strings, numbers, and booleans.
* @returns JSON string representation of the value. Serializes objects, arrays, nested structures, and scalars; null and undefined both serialize to the literal string "null".
* @example
* var json = Platform.Function.Stringify({ name: "Jane", age: 30 });
* Platform.Response.Write(json);
*/
function Stringify(value: any): string;
/**
* Retrieves content from a specified classic Content Area by ID. Salesforce documents Content Areas as deprecated in favour of Content Builder blocks. Only the single-argument form works: an existing id returns its content (a numeric string works too), while supplying regionName throws an "invalid parameter value ... ImpressionRegionName ... ResolvedValueParameter" error that leaves stopOnError and fallbackContent unreachable. Note: the bare-name ContentArea() global uses a string errorMsg as the 3rd parameter and requires Platform.Load("core","1.1.5"); this Platform.Function form does not.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/contentarea/)
*
* @deprecated
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the three optional parameters the docs describe cannot be reached from SSJS. Every shape of the 2nd argument (regionName) — string literal, concatenation, variable, empty string, null — is rejected with an "invalid parameter value ... Parameter Name: ImpressionRegionName, Parameter Ordinal: 2, Parameter Type: ResolvedValueParameter" error, so arity 3 (stopOnError) and arity 4 (fallbackContent) never execute: setting stopOnError to false does not let the call proceed, and the fallback string is never assigned or returned. Only the single-argument form is usable, and even that throws unless the id resolves to an existing Content Area — the numeric ids in the docs' examples all failed with "An error occurred when attempting to evaluate an ContentArea function call". Use Platform.Function.ContentBlockByID() instead, or invoke the AMPscript form through Platform.Function.TreatAsContent() when the optional parameters are needed.
* @param id - ID of the Content Area.
* @param regionName - Impression region for content.
* @param stopOnError - When true, throws on failure; when false the call proceeds.
* @param fallbackContent - Default content to display when the area cannot be retrieved.
* @returns Rendered content from the Content Area.
* @example
* var content = Platform.Function.ContentArea(123456, "impressionRegion", false, "defaultContentHere");
*/
function ContentArea(id: string | number, regionName?: string, stopOnError?: boolean, fallbackContent?: string): string;
/**
* Retrieves content from a specified classic Content Area by name. Salesforce documents Content Areas as deprecated in favour of Content Builder blocks. Only the single-argument form works: an existing name returns its content, matching is case-insensitive and the backslash-separated folder-path form resolves, while a CustomerKey, a space-padded name and an unknown name are rejected. Supplying regionName throws an "invalid parameter value ... ImpressionRegionName ... ResolvedValueParameter" error that leaves stopOnError and fallbackContent unreachable. Note: the bare-name ContentAreaByName() global uses a string errorMsg as the 3rd parameter and requires Platform.Load("core","1.1.5"); this Platform.Function form does not.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/contentareabyname/)
*
* @deprecated
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the single-argument form does return the content once the name resolves, but the three optional parameters the docs describe cannot be reached from SSJS. Every shape of the 2nd argument (regionName) — string literal, concatenation, variable, empty string, null — is rejected with an "invalid parameter value ... Parameter Name: ImpressionRegionName, Parameter Ordinal: 2, Parameter Type: ResolvedValueParameter" error, so arity 3 (stopOnError) and arity 4 (fallbackContent) never execute: setting stopOnError to false does not let the call proceed, and the fallback string is never assigned or returned. Use Platform.Function.ContentBlockByName() instead, or invoke the AMPscript form through Platform.Function.TreatAsContent() when the optional parameters are needed.
* @param name - Name of the Content Area.
* @param regionName - Impression region for content.
* @param stopOnError - When true, throws on failure; when false the call proceeds.
* @param fallbackContent - Default content to display when the area cannot be retrieved.
* @returns Rendered content from the Content Area.
* @example
* var content = Platform.Function.ContentAreaByName("My Content\\myContentArea", "impressionRegion", false, "defaultContentHere");
*/
function ContentAreaByName(name: string, regionName?: string, stopOnError?: boolean, fallbackContent?: string): string;
/**
* Indicates whether the passed-in user-agent value represents a CHTML browser. CHTML browsers (e.g. feature phones) use a modified version of HTML. Returns true when the user agent is a CHTML browser.
*
* [ssjs.guide reference](https://ssjs.guide/platform-functions/ischtmlbrowser/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param userAgentString - User-agent string to evaluate.
* @returns True if the user agent represents a CHTML browser.
* @example
* Platform.Response.Write(Platform.Request.UserAgent);
* Platform.Response.Write("
Is CHTML: ");
* Platform.Response.Write(Platform.Function.IsCHTMLBrowser(Platform.Request.UserAgent));
*/
function IsCHTMLBrowser(userAgentString: string): boolean;
}
/**
* SSJS variable declaration and retrieval methods.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-variable/)
*
*/
namespace Variable {
/**
* Retrieves the value of an AMPscript variable from the SSJS context.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-variable/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage GET): values retain their SSJS scalar type within the request, while a never-set variable returns JavaScript `null` and an explicitly empty variable returns `""`. The leading `@` is optional, and variable names are case-insensitive.
* @param variableName - Name of the AMPscript variable
* @example
* var sk = Platform.Variable.GetValue("SubscriberKey");
* Write(sk);
* // Bare-name alias: Variable.GetValue("SubscriberKey")
*/
function GetValue(variableName: string): string | number | boolean | null;
/**
* Assigns a value to an AMPscript variable from the SSJS context.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-variable/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage GET): the method returns JavaScript `null`, not void. Strings, numbers, and booleans retain their SSJS scalar type in later SSJS blocks; null and undefined read back as `null`. The leading `@` is optional, and values are request-local.
* @param variableName - Name of the AMPscript variable
* @param value - Scalar value to assign
* @example
* Platform.Variable.SetValue("greeting", "Hello from SSJS");
* // @greeting is now available in subsequent AMPscript blocks
* // Bare-name alias: Variable.SetValue("greeting", "Hello from SSJS")
*/
function SetValue(variableName: string, value: string | number | boolean | null | undefined): null;
}
/**
* HTTP response manipulation methods.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-response/)
*
*/
namespace Response {
/**
* Sets a response header on the current page response.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-response/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the header appears verbatim in the HTTP response and the call returns JavaScript null, not void. Numeric values are coerced to their string form.
* @param headerName - Name of the response header.
* @param value - Value for the response header.
* @example
* Platform.Response.SetResponseHeader("Content-Type", "application/json");
* Platform.Response.Write(Stringify({ status: "ok" }));
*/
function SetResponseHeader(headerName: string, value: string): null;
/**
* Removes a previously set HTTP response header from the response.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-response/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): removes a header set earlier in the same request and returns JavaScript null, not void. Removing a header that was never set is a no-op rather than an error.
* @param headerName - Name of the HTTP response header to remove.
* @example
* Platform.Response.RemoveResponseHeader("X-Powered-By");
*/
function RemoveResponseHeader(headerName: string): null;
/**
* Redirects the current page to a new URL and stops script execution immediately. Pass false for a 302 temporary redirect or true for a 301 permanent redirect; omitting the flag also yields a 302. Do not use 301 if you want browsers to re-check the original URL later.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-response/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage). Behaviours the official docs do not state: the second argument is optional — a single-argument call produces a 302 with the Location header set; a successful redirect discards any response body already written; and a redirect inside try is catchable — the catch runs and can call Redirect again, overriding the Location (keep redirects out of try, or guard the catch).
* @param url - URL to redirect to.
* @param movedPermanently - True for 301 permanent redirect, false for 302 temporary. Defaults to a 302 when omitted.
* @example
* Platform.Response.Redirect("https://pub.pages.example.com/thank-you", false);
*/
function Redirect(url: string, movedPermanently?: boolean): void;
/**
* Sets a cookie on the client browser response.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-response/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): each call returns JavaScript null, not void, and emits its own Set-Cookie header. Without an expiry the cookie is a session cookie; a JavaScript Date object is accepted for the expiry alongside a date string and is rendered as a GMT timestamp.
* @param name - Name of the cookie to set.
* @param value - Value to store in the cookie.
* @param expires - Expiration date/time for the cookie. Accepts a date string or a JavaScript Date object.
* @param secure - If true, the cookie is only sent over HTTPS.
* @example
* Platform.Response.SetCookie("userId", subscriberKey, "12/31/2025", true);
*/
function SetCookie(name: string, value: string, expires?: string | Date, secure?: boolean): null;
/**
* Attempts to remove a browser cookie from a CloudPage response. In the tested runtime it returns null but emits no deletion header; use SetCookie with an empty value and a past JavaScript Date instead.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-response/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a published CloudPage GET with the named request cookie present: the call returns JavaScript null, not void, and emits no Set-Cookie header. The proven workaround is SetCookie(name, "", new Date(1970, 0, 1), true), which emits an empty cookie with a past expiry and removes it from the next cookie-jar request.
* @param name - Name of the cookie to remove.
* @example
* Platform.Response.SetCookie("userId", "", new Date(1970, 0, 1), true);
*/
function RemoveCookie(name: string): null;
/**
* Writes content to the HTTP response output. Distinct from the bare-name `Write()`, which also writes to the response after Core load. Non-string values use CLR stringification (not JS toString); use Stringify for objects.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-response/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param content - Content string to write to the response.
* @example
* var data = { name: "Jane", status: "active" };
* Platform.Response.Write(Stringify(data));
*/
function Write(content: string): void;
var ContentType: any;
var CharacterSet: any;
}
/**
* HTTP request reading methods and properties.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-request/)
*
*/
namespace Request {
/**
* Retrieves the value of a URL query string parameter.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-request/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage GET): an absent parameter returns strict JavaScript `null`, not an empty string. Empty values return `""`; repeated values are comma-joined in URL order; names are case-insensitive; plus signs, percent escapes, and UTF-8 sequences are decoded; numeric names are coerced to strings. Guard reads with truthiness or `!= null`.
* @param parameterName - Name of the query string parameter.
* @example
* // Page URL: /mypage?email=jane@example.com
* var email = Platform.Request.GetQueryStringParameter("email");
* Write(email);
*/
function GetQueryStringParameter(parameterName: string): string | null;
/**
* Retrieves a named field from a submitted POST form body. On a CloudPage GET it does not fall back to query parameters and returns null.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-request/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage GET): it returns strict JavaScript `null` for an absent field and does not read a same-named query-string parameter. Use GetQueryStringParameter for URL values.
* @param name - Name of the form field to retrieve.
* @example
* var email = Platform.Request.GetFormField("emailAddress");
* Write(email);
*/
function GetFormField(name: string): string | null;
/**
* Returns the raw body of the HTTP POST request. CAVEAT: Only returns data on the FIRST call per request; subsequent calls return nothing. Store the result in a variable if you need it multiple times.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-request/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param encoding - Character encoding for the post data.
* @example
* // Read raw POST body once and store it:
* var rawBody = Platform.Request.GetPostData();
* var payload = Platform.Function.ParseJSON(rawBody);
*/
function GetPostData(encoding?: string): string;
/**
* Retrieves the value of a named cookie from the HTTP request sent by the client browser.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-request/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): a supplied cookie returns its string value; an absent cookie returns strict JavaScript `null`, not an empty string.
* @param cookieName - Name of the cookie to retrieve.
* @example
* var sessionId = Platform.Request.GetCookieValue("sessionId");
* if (sessionId) { Write("Session: " + sessionId); }
*/
function GetCookieValue(cookieName: string): string | null;
/**
* Returns the value of the named HTTP request header, or null if not present.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-request/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param headerName - Name of the HTTP request header to retrieve.
* @example
* var auth = Platform.Request.GetRequestHeader("Authorization");
* if (auth) { Write("Auth: " + auth); }
*/
function GetRequestHeader(headerName: string): string | null;
const Browser: object;
const ClientIP: string;
const HasSSL: boolean;
const IsSSL: boolean;
const Method: string;
const QueryString: string;
const ReferrerURL: string;
const RequestURL: string;
const UserAgent: string;
}
/**
* Methods to access subscriber and recipient data.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-recipient/)
*
*/
namespace Recipient {
/**
* Returns the value of a subscriber attribute or sendable data extension field for the current recipient.
*
* [ssjs.guide reference](https://ssjs.guide/platform-objects/platform-recipient/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): does NOT throw outside a send context — in a plain CloudPage it returns `""` (empty string, typeof "string") for any attribute because no recipient is bound. The bare-name `Recipient` alias is NOT available even after Platform.Load; use `Platform.Recipient.GetAttributeValue(...)` (or `Attribute.GetValue(...)` after load).
* @param attributeName - Name of the subscriber attribute or sendable DE field to retrieve
* @example
* var email = Platform.Recipient.GetAttributeValue("EmailAddress");
* Platform.Response.Write(email);
*/
function GetAttributeValue(attributeName: string): string;
}
}
// ── Bare-name globals ────────────────────────────────────────────────────────
declare namespace Variable {
/**
* Retrieves the value of an AMPscript variable from the SSJS context.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/variable/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage GET): values retain their SSJS scalar type within the request, while a never-set variable returns JavaScript `null` and an explicitly empty variable returns `""`. The leading `@` is optional, and variable names are case-insensitive.
* @param variableName - Name of the AMPscript variable
* @example
* var sk = Platform.Variable.GetValue("SubscriberKey");
* Write(sk);
* // Bare-name alias: Variable.GetValue("SubscriberKey")
*/
function GetValue(variableName: string): string | number | boolean | null;
/**
* Assigns a value to an AMPscript variable from the SSJS context.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/variable/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage GET): the method returns JavaScript `null`, not void. Strings, numbers, and booleans retain their SSJS scalar type in later SSJS blocks; null and undefined read back as `null`. The leading `@` is optional, and values are request-local.
* @param variableName - Name of the AMPscript variable
* @param value - Scalar value to assign
* @example
* Platform.Variable.SetValue("greeting", "Hello from SSJS");
* // @greeting is now available in subsequent AMPscript blocks
* // Bare-name alias: Variable.SetValue("greeting", "Hello from SSJS")
*/
function SetValue(variableName: string, value: string | number | boolean | null | undefined): null;
}
declare namespace Request {
/**
* Returns the full URL of the current page request.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/request/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var requestURL = Request.URL();
* Write(requestURL);
*/
function URL(): string;
/**
* Returns the path portion of the current page request.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/request/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var path = Request.PagePath();
* Write(path);
*/
function PagePath(): string;
/**
* Returns the HTTP method (GET, POST, etc.) of the current request.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/request/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var method = Request.Method();
* Write(method);
*/
function Method(): string;
/**
* Returns the application ID associated with the current request.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/request/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var appId = Request.ApplicationID();
* Write(appId);
*/
function ApplicationID(): string;
/**
* Returns the package ID associated with the current request.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/request/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var packageId = Request.PackageID();
* Write(packageId);
*/
function PackageID(): string;
/**
* Returns the base URL of the application for the current request.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/request/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var baseUrl = Request.ApplicationBaseURL();
* Write(baseUrl);
*/
function ApplicationBaseURL(): string;
/**
* Returns the value of a named URL query string parameter for the current page request, or null when the parameter is absent.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/request/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param name - Key name of the query string parameter to read.
* @example
* var sku = Request.GetQueryStringParameter("sku");
* if (sku) { Write("SKU: " + sku); }
*/
function GetQueryStringParameter(name: string | number): string;
/**
* Returns the value of a named form field submitted with the current request (POST form data), or null when the field is absent. Does not read GET query string parameters — use Request.GetQueryStringParameter for those.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/request/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param name - Name of the form field to read.
* @example
* var email = Request.GetFormField("emailAddress");
* if (email) { Write(email); }
*/
function GetFormField(name: string): string;
}
/**
* Encodes plain text to a Base64 encoded string. For charset control or scope-independent use, use `Platform.Function.Base64Encode(string, charset)` instead.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/base64encode/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param string - Text to encode
* @example
* Platform.Load("core", "1.1.5");
* var encoded = Base64Encode('Convert to Base64'); // "Q29udmVydCB0byBCYXNlNjQ="
*/
declare function Base64Encode(string: string): string;
/**
* Decodes a Base64 encoded string to plain text. For charset control or scope-independent use, use `Platform.Function.Base64Decode(encodedString, charset)` instead.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/base64decode/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param encodedString - Base64 encoded string to decode
* @example
* Platform.Load("core", "1.1.5");
* var decoded = Base64Decode('VGhpcyB3YXMgYSBCYXNlNjQgZW5jb2RlZCBzdHJpbmcu'); // "This was a Base64 encoded string."
*/
declare function Base64Decode(encodedString: string): string;
/**
* Retrieves content from a classic Content Area by numeric ID. Salesforce documents Content Areas as deprecated in favour of Content Builder blocks. Note: the Platform.Function.ContentArea() variant does not require Platform.Load and accepts a boolean stopOnError parameter instead of a string errorMsg.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/contentarea/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the bare-name `ContentArea` IS defined as a function after `Platform.Load("core", ...)` has run (the load must precede use; once loaded the bare name is usable in that scope and in nested helper bodies that close over it). Only the single-argument form works: passing the id of an existing Content Area returns its content, and a numeric string for the same id works too. Supplying regionName (parameter 2) throws an "invalid parameter value ... ImpressionRegionName ... ResolvedValueParameter" error, which leaves errorMsg and fallbackContent unreachable. An arity-1 call that throws means the id did not resolve to a Content Area. The Platform.Function.ContentArea() variant does not require Platform.Load.
* @param id - ID of the Content Area.
* @param regionName - Impression region for content.
* @param errorMsg - Error message string returned on failure.
* @param fallbackContent - Default content to display when the area cannot be retrieved.
* @returns Rendered content from the Content Area.
* @example
* Platform.Load("core", "1.1.5");
* var content = ContentArea(123456, "impressionRegion", "fallback error msg", "defaultContentHere");
*/
declare function ContentArea(id: string | number, regionName?: string, errorMsg?: string, fallbackContent?: string): string;
/**
* Retrieves content from a classic Content Area by name. Salesforce documents Content Areas as deprecated in favour of Content Builder blocks. Note: the Platform.Function.ContentAreaByName() variant does not require Platform.Load and accepts a boolean stopOnError parameter instead of a string errorMsg.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/contentareabyname/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the bare-name `ContentAreaByName` IS defined as a function after `Platform.Load("core", ...)` has run (the load must precede use; once loaded the bare name is usable in that scope and in nested helper bodies that close over it). Only the single-argument form works: passing the name of an existing Content Area returns its content. Name matching is case-insensitive and the backslash-separated folder-path form resolves as well, while a CustomerKey, a space-padded name and an unknown name are all rejected. Supplying regionName (parameter 2) throws an "invalid parameter value ... ImpressionRegionName ... ResolvedValueParameter" error, which leaves errorMsg and fallbackContent unreachable. The Platform.Function.ContentAreaByName() variant does not require Platform.Load.
* @param name - Name of the Content Area.
* @param regionName - Impression region for content.
* @param errorMsg - Error message string returned on failure.
* @param fallbackContent - Default content to display when the area cannot be retrieved.
* @returns Rendered content from the Content Area.
* @example
* Platform.Load("core", "1.1.5");
* var content = ContentAreaByName("My Content\\myContentArea", "impressionRegion", "fallback error msg", "defaultContentHere");
*/
declare function ContentAreaByName(name: string, regionName?: string, errorMsg?: string, fallbackContent?: string): string;
/**
* Marks the start of a named impression tracking region within content. Runtime note: unusable from SSJS — every call (literal or variable argument) throws a resolved-value error; impression regions are an AMPscript-only feature.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/beginimpressionregion/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the bare-name `BeginImpressionRegion` IS defined as a function after `Platform.Load("core", ...)`, but calling it — with either a string literal or a variable — throws "A BeginImpressionRegion function call includes an invalid parameter value. The values making up the parameter value for this call must be a literal (constant) values." The bare alias and the `Platform.Function.BeginImpressionRegion` form behave identically (both throw the same error), so impression regions are effectively unusable from SSJS — they are an AMPscript-only feature. SCOPE RULE: bare-name Core globals exist ONLY after Platform.Load has run — call the load first.
* @param name - The impression region name.
* @example
* Platform.Load("core", "1.1.5");
* // Note: throws at runtime in SSJS — impression regions are AMPscript-only.
* BeginImpressionRegion("hero-banner");
*/
declare function BeginImpressionRegion(name: string): void;
/**
* Marks the end of an impression tracking region within content. Runtime note: the bare alias returns `undefined` (its `Platform.Function.EndImpressionRegion` counterpart returns `null`); has no practical effect in SSJS because impression regions are AMPscript-only.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/endimpressionregion/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the bare-name `EndImpressionRegion` IS defined as a function after `Platform.Load("core", ...)` and can be called without throwing. It DIFFERS from its `Platform.Function.EndImpressionRegion` counterpart in return value: the bare alias returns `undefined` (typeof "undefined"), whereas `Platform.Function.EndImpressionRegion()` returns a genuine `null` (typeof "object", === null). The official docs type the return as void. Because `BeginImpressionRegion` is unusable from SSJS, this method has no practical effect in SSJS either. SCOPE RULE: bare-name Core globals exist ONLY after Platform.Load has run — call the load first.
* @param closeAll - Optional flag to close all open impression regions.
* @example
* Platform.Load("core", "1.1.5");
* EndImpressionRegion(); // returns undefined (Platform.Function form returns null)
*/
declare function EndImpressionRegion(closeAll?: string | boolean | number): undefined;
/**
* Returns the current server date/time as a Date object (in the account timezone, Central by default), or the timestamp of the triggering send when called with `true`. Same return shape as `Platform.Function.Now()`; surplus arguments are ignored (the qualified form throws on arity 2+).
*
* [ssjs.guide reference](https://ssjs.guide/core-library/now/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the bare-name `Now` works after `Platform.Load("core", ...)` and returns the same kind of value as `Platform.Function.Now()` — a genuine Date object: typeof "object", `Object.prototype.toString` reports "[object Date]", `.constructor === Date`, and `getFullYear()`/`getHours()`/`getTime()` all work (identical to `new Date()`). The only anomaly is that `instanceof Date` returns false, due to the engine-wide `instanceof`-on-builtins bug — detect via `.constructor === Date`, not `instanceof`. It coerces to an RFC 2822-style string such as "Tue, 21 Jul 2026 10:18:24 GMT-06:00" during output. The official docs describe the return as an RFC 2822-compliant date-time string. Surplus arguments beyond maxArgs 1 are silently ignored on the bare form; `Platform.Function.Now(...)` throws on arity 2+. useContextTime also accepts number 0/1 and the strings "true"/"false". SCOPE RULE: bare-name Core globals exist ONLY after Platform.Load has run — call the load first.
* @param useContextTime - Pass `true` to return the timestamp of the triggering send instead of the current time. Also accepts number 0/1 and the strings "true"/"false".
* @example
* Platform.Load("core", "1.1.5");
* var current = Now(); // e.g. "Tue, 21 Jul 2026 10:18:24 GMT-06:00"
* Write(current.getFullYear()); // 2026
*/
declare function Now(useContextTime?: string | boolean | number): Date;
/**
* Redirects the browser to another address. For scope-independent use that needs no Platform.Load, use `Platform.Response.Redirect(url, movedPermanently)`. Meaningful only in CloudPage context.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/redirect/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param url - The address to send the browser to.
* @param movedPermanently - Pass `true` / `1` / `"true"` for an HTTP 301 (permanent) redirect or `false` / `0` / `"false"` for a 302 (temporary) redirect.
* @example
* Platform.Load("core", "1.1.5");
* Redirect("https://www.example.com", false); // or, scope-independent: Platform.Response.Redirect("https://www.example.com", false);
*/
declare function Redirect(url: string, movedPermanently: string | boolean | number): void;
/**
* Generates a new globally unique identifier as a lowercase canonical UUID v4 string (36 characters). Requires Platform.Load("core"). Same return shape as Platform.Function.GUID(); surplus arguments are ignored (the qualified form throws).
*
* [ssjs.guide reference](https://ssjs.guide/core-library/guid/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* Platform.Load("core", "1.1.5");
* var id = GUID(); // e.g. "f038aa14-708f-4392-a329-7dfa46abaf4b"
*/
declare function GUID(): string;
/**
* Checks whether a string is a valid email address format. Same boolean answers as `Platform.Function.IsEmailAddress()` for one string argument; arity 0 returns false and surplus arguments are ignored (the qualified form throws).
*
* [ssjs.guide reference](https://ssjs.guide/core-library/isemailaddress/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param value - The string to validate.
* @example
* Platform.Load("core", "1.1.5");
* if (IsEmailAddress(emailInput)) { Write("Valid email"); }
*/
declare function IsEmailAddress(value: string): boolean;
/**
* Checks whether a value is a valid North American Numbering Plan (NANP) phone number. Same boolean answers as `Platform.Function.IsPhoneNumber()` for one argument; arity 0 returns false and surplus arguments are ignored (the qualified form throws). See that entry for the NANP format details.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/isphonenumber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the bare-name `IsPhoneNumber` works after `Platform.Load("core", ...)` and returns the same boolean as `Platform.Function.IsPhoneNumber()` for the documented 1-argument form. Calling with no arguments returns false (does not throw); surplus arguments are silently ignored. `Platform.Function.IsPhoneNumber` throws on arity 0 and on surplus arguments. Documented contract remains minArgs/maxArgs 1. The official docs describe generic "valid phone number" validation; see the `Platform.Function.IsPhoneNumber` entry for the NANP runtime format details. SCOPE RULE: bare-name Core globals exist ONLY after Platform.Load has run — call the load first.
* @param value - The value to validate.
* @example
* Platform.Load("core", "1.1.5");
* if (IsPhoneNumber(phoneInput)) { Write("Valid phone"); }
*/
declare function IsPhoneNumber(value: string | number): boolean;
/**
* Writes text to the HTTP response output. Non-string values use CLR stringification (not JS toString); use Stringify for objects. For scope-independent output that needs no Platform.Load, use `Platform.Response.Write(text)` instead.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/write/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param text - Text to write to the response.
* @example
* Platform.Load("core", "1.1.5");
* Write("Hello world"); // or, scope-independent: Platform.Response.Write("Hello world");
*/
declare function Write(content: string): void;
/**
* Serializes a value to a JSON string. Requires Platform.Load("core"). Same JSON text as `Platform.Function.Stringify(value)` for a given value; surplus arguments are ignored and zero arguments return "null" (the qualified form throws). For scope-independent use, prefer `Platform.Function.Stringify(value)`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/stringify/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param value - Value to serialize to JSON.
* @returns JSON string representation of the value. Serializes objects, arrays, nested structures, and scalars; null and undefined both serialize to the literal string "null".
* @example
* Platform.Load("core", "1.1.5");
* var json = Stringify({ a: 1, b: "x" }); // '{"a":1,"b":"x"}'
*/
declare function Stringify(value: any): string;
/**
* Applies a formatting rule to a string, number, or Date. Use format codes such as `C` (currency), `D` (decimal), `N` (number with separators), `P` (percentage), `O` (ISO 8601 date), `s` (sortable date), `d` (short date), `t` (12-hour time), etc. Append a digit to control decimal places, e.g. `C2` for two decimal places.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/format/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): bare-name `Format` requires `Platform.Load("core", ...)`. Numeric codes match the official examples (e.g. Format(4213.65, "C2") -> "$4,213.65"). DIFFERS: predefined short-form `d` returns a four-digit year (`8/5/2024` for the sample instant), not the two-digit year (`8/5/24`) shown in the official docs. textToFormat also accepts a real Date for date format codes (same result as the matching date string). Boolean is rejected for numeric codes. SCOPE RULE: bare-name Core globals exist ONLY after Platform.Load has run.
* @param textToFormat - The string, number, or Date to apply a formatting rule to.
* @param formatCode - A format code to apply. Numeric: C, D, E, F, G, N, P (append digit for decimal places). Date/time: d, M, f, g, O, r, s, t, T, or a custom pattern.
* @example
* Platform.Load("core", "1.1.5");
* var price = Format(4213.65, "C2"); // "$4,213.65"
* var isoDate = Format("2024-08-05T13:41:23", "O"); // "2024-08-05T13:41:23.0000000"
* Write(price + " / " + isoDate);
*/
declare function Format(textToFormat: string | number | Date, formatCode: string): string;
// ── DataExtension instance interfaces ───────────────────────────────────────
interface DataExtensionFields {
/**
* Adds a field to the previously initialized data extension. `properties.Name` is required; the rest (`CustomerKey`, `FieldType`, `MaxLength`, `IsRequired`, `IsPrimaryKey`, `Ordinal`, `Scale`, `DefaultValue`) are optional. `FieldType` accepts: 'Boolean', 'Date', 'Decimal', 'EmailAddress', 'Locale', 'Number', 'Phone', 'Text'.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension-fields/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - Object describing the new field.
* @returns Returns "OK" on success. Runtime returns the string "Error" (rather than throwing) when the field cannot be added or arguments are missing.
* @example
* Platform.Load("core", "1.1.5");
* var de = DataExtension.Init("SSJSTest");
* var newField = { Name: "NewFieldV2", CustomerKey: "CustomerKey", FieldType: "Number", IsRequired: true, DefaultValue: "100" };
* var status = de.Fields.Add(newField);
*/
Add(properties: object): string;
/**
* Returns an array of field definitions for the previously initialized data extension.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension-fields/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs example response lists only Name, FieldType, IsPrimaryKey, MaxLength, Ordinal, and DefaultValue. At runtime each field object also includes an `ObjectID` (string) property.
* @returns List of field-definition objects. Each object exposes `Name` (string), `ObjectID` (string), `FieldType` (string), `IsPrimaryKey` (boolean), `MaxLength` (number), `Ordinal` (number), and `DefaultValue` (string).
* @example
* Platform.Load("core", "1.1.5");
* var birthdayDE = DataExtension.Init("birthdayDE");
* var fields = birthdayDE.Fields.Retrieve();
*/
Retrieve(): object[];
/**
* Updates which data extension field is used to relate the data extension to the All Subscribers list during sending. Pass the name of the data extension field, and which subscriber attribute it should map to.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension-fields/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param deFieldName - Name of the data extension field that should make the connection to the subscriber list.
* @param subscriberField - Subscriber attribute to map the data extension field to.
* @returns Returns "OK" on success (confirmed at runtime; the doc has no `@returns`). Returns the string "Error" instead of throwing on failure. Runtime defect: a no-argument call returns "OK" although the mapping is unchanged, so an "OK" return alone does not prove a mapping was applied.
* @example
* Platform.Load("core", "1.1.5");
* var updateDE = DataExtension.Init("sendableDataExtension");
* var status = updateDE.Fields.UpdateSendableField("DifferentSubKey", "Subscriber Key");
*/
UpdateSendableField(deFieldName: string, subscriberField: string): string;
}
interface DataExtensionRows {
/**
* Adds one or more rows to the previously initialized data extension. Accepts either an array of row objects or a single row object.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension-rows/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a CloudPage: returns a number (the count of rows added), not the string "OK". Also accepts a single row object in addition to an array of objects.
* @param rowData - Array of row objects (or a single row object). Each object's keys must match data extension field names.
* @returns The number of rows that were added.
* @example
* Platform.Load("core", "1.1.5");
* var arrContacts = [
* { Email: "jdoe@example.com", FirstName: "John", LastName: "Doe" },
* { Email: "aruiz@example.com", FirstName: "Angel", LastName: "Ruiz" }
* ];
* var birthdayDE = DataExtension.Init("birthdayDE");
* birthdayDE.Rows.Add(arrContacts);
*/
Add(rowData: any[] | object): number;
/**
* Returns rows where the specified columns equal the specified values (AND-joined). Optionally limits results and orders by a field. When initializing a data extension for `Lookup()` from an email message, you must use the data extension Name; on landing pages, either Name or external key works — make them identical to be safe.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension-rows/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a CloudPage: returns typed values (Number and Decimal columns come back as number, Boolean as boolean), unlike Retrieve which returns every field as a string. Date columns are the exception: they come back as an ISO-8601 string (e.g. "2024-01-15T00:00:00.000"), NOT a Date object — the same behaviour as Platform.Function.LookupRows. On no match, returns `null` (not an empty array). The result is a host array where `instanceof Array` is `false`, but `.length` and index access work.
* @param searchFieldNames - Array of column names to match against.
* @param searchValues - Array of values to match (one per column, in order). Heterogeneous simple values; Number columns accept a number or a numeric string.
* @param limit - Maximum number of rows to return.
* @param orderByFieldName - Field to order results by.
* @returns Rows matching the lookup criteria with typed Number/Decimal/Boolean values; Date columns are ISO-8601 strings. Returns null when no row matches.
* @example
* Platform.Load("core", "1.1.5");
* var testDE = DataExtension.Init("testDE");
* var data = testDE.Rows.Lookup(["Age"], [25], 2, "LastName");
*/
Lookup(searchFieldNames: string[], searchValues: any[], limit?: string | number, orderByFieldName?: string): object[] | null;
/**
* Deletes rows from the previously initialized data extension where the specified columns equal the specified values (AND-joined). For large deletion requests, batch the work — this method times out on long-running deletes.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension-rows/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param columnNames - Array of column names to match against.
* @param columnValues - Array of values to match (one per column, in order). Heterogeneous simple values; Number columns accept a number or a numeric string.
* @returns The number of rows that were modified (deleted).
* @example
* Platform.Load("Core", "1.1.5");
* var memberDE = DataExtension.Init("MembershipRewards");
* var result = memberDE.Rows.Remove(["Area"], ["Kensington"]);
*/
Remove(columnNames: string[], columnValues: any[]): number;
/**
* Retrieves up to 2500 rows from the previously initialized data extension. When called without a filter, returns all rows (subject to the 2500-row cap). Cannot be used in the context of an email message or email preview.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension-rows/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a CloudPage: calling `Retrieve()` without a filter DOES work on CloudPages and returns all rows — the widely-repeated "returns empty on CloudPages" bug could not be reproduced. A ComplexFilterPart with LogicalOperator "OR" also works and returns the union of both operands (it is NOT silently collapsed to AND) — the community claim that DE WHERE is AND-only is incorrect. All field values are returned as strings (even Number/Boolean/Date columns), unlike Lookup which returns typed Number/Decimal/Boolean values (Lookup Date columns are ISO-8601 strings, not Date objects). On no match, returns an empty host array (`.length === 0`), not `null`. The result is a host array where `instanceof Array` is `false`, but `.length` and index access work.
* @param filter - WSProxy-style filter object — simple `{Property, SimpleOperator, Value}` or compound with `LeftOperand`/`LogicalOperator`/`RightOperand`. Optional per the example, despite the doc table marking `Required: Yes`.
* @returns Rows from the data extension matching the filter (or all rows when no filter is supplied). Field values are strings.
* @example
* Platform.Load("core", "1.1.5");
* var birthdayDE = DataExtension.Init("birthdayDE");
* var data = birthdayDE.Rows.Retrieve();
* var filter = { Property: "Age", SimpleOperator: "greaterThan", Value: 20 };
* var moredata = birthdayDE.Rows.Retrieve(filter);
*/
Retrieve(filter?: object): object[];
/**
* Updates the columns of rows where `whereFieldNames` equal `whereValues` (AND-joined). Returns 0 (does not throw) when no row matches.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension-rows/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a CloudPage: returns a number (the count of rows updated), not the string "OK". When no row matches the WHERE clause, it returns `0` and does NOT throw.
* @param rowData - Object whose keys are columns to update and values are the new values.
* @param whereFieldNames - Array of column names to match against.
* @param whereValues - Array of values to match (one per column, in order). Heterogeneous simple values; Number columns accept a number or a numeric string.
* @returns The number of rows that were updated (0 when no row matches).
* @example
* Platform.Load("Core", "1");
* var dataExt = DataExtension.Init("NTO Customer List");
* var fieldsToUpdate = { StateProvince: "QC", PreferredActivity: "Sailing" };
* var result = dataExt.Rows.Update(fieldsToUpdate, ["MemberId", "Country"], [9868600, "CA"]);
*/
Update(rowData: object, whereFieldNames: string[], whereValues: any[]): number;
}
interface DataExtensionInstance {
Fields: DataExtensionFields;
Rows: DataExtensionRows;
}
// ── Core Library sub-namespace instance interfaces ───────────────────────────
interface ListSubscribersTrackingInstance {
/**
* Returns an array of tracking data for subscribers matching the filter.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - PascalCase WSProxy-style filter object identifying the subscribers.
* @returns List of tracking records matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var myList = List.Init("MyList");
* var results = myList.Subscribers.Tracking.Retrieve({ Property: "SubscriberKey", SimpleOperator: "equals", Value: "MyKey" });
*/
Retrieve(filter: object): object[];
}
interface ListSubscribersInstance {
/**
* Adds a subscriber to the previously initialized list.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Official docs say Add returns "OK" or throws on failure. Runtime returns the plain string "Error" for invalid payloads and does not throw.
* @param properties - Object containing subscriber properties (EmailAddress, SubscriberKey, optionally list status).
* @returns Returns "OK" on success. Invalid or incomplete properties return the plain string "Error" (does not throw).
* @example
* Platform.Load("core", "1");
* var list = List.Init("MY_LIST_KEY");
* var result = list.Subscribers.Add({
* EmailAddress: "test@example.com",
* SubscriberKey: "test@example.com"
* });
* Write(Stringify(result));
*/
Add(properties: object): string;
/**
* Returns the subscribers belonging to the previously initialized list. Pass an optional filter to narrow the results; omit it to return all subscribers on the list. Filter on SubscriberKey; a filter on EmailAddress returns an empty array.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Optional WSProxy-style filter object. SubscriberKey works; EmailAddress returns no rows.
* @returns List of subscriber objects on the list (filtered when a filter is supplied).
* @example
* Platform.Load("core", "1");
* var list = List.Init("MY_LIST_KEY");
* var subscribers = list.Subscribers.Retrieve();
*/
Retrieve(filter?: object): object[];
/**
* Sets the subscriber Status on the list to Unsubscribed. The membership row remains; it is not deleted.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Official docs say Unsubscribe returns "OK" or throws on failure. Runtime returns the plain string "Error" for a missing subscriber and does not throw.
* @param emailAddress - Email address of the subscriber, or a `{EmailAddress, SubscriberKey}` object identifying the subscriber.
* @returns Returns "OK" on success. A missing subscriber returns the plain string "Error" (does not throw).
* @example
* Platform.Load("core", "1.1.5");
* var myList = List.Init("myList");
* var status = myList.Subscribers.Unsubscribe("aruiz@example.com");
*/
Unsubscribe(emailAddress: string | object): string;
/**
* Updates the status of the specified subscriber on the previously initialized list. A bare email string works when EmailAddress equals SubscriberKey; otherwise pass `{EmailAddress, SubscriberKey}`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Official docs say Update returns "OK" or throws on failure. Runtime returns the plain string "Error" instead of throwing. A bare email string also returns "Error" when SubscriberKey differs from EmailAddress — use the object form in that case.
* @param emailAddress - Email address of the subscriber, or a `{EmailAddress, SubscriberKey}` object identifying the subscriber.
* @param status - New status of the subscriber on the list (e.g. "Active", "Unsubscribed").
* @returns Returns "OK" on success. A missing subscriber or unresolved string identity returns the plain string "Error" (does not throw).
* @example
* Platform.Load("core", "1.1.5");
* var myList = List.Init("myList");
* var status = myList.Subscribers.Update("aruiz@example.com", "Active");
*/
Update(emailAddress: string | object, status: string): string;
/**
* Adds the subscriber if not on the list, otherwise updates the supplied attributes. If `attributes.Status` is supplied, the subscriber's list status is updated.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Official docs say Upsert returns "OK" or throws on failure. Runtime returns the plain string "Error" for failed calls and does not throw.
* @param emailAddress - Email address of the subscriber, or a `{EmailAddress, SubscriberKey}` object identifying the subscriber.
* @param attributes - Additional subscriber attributes to set or update.
* @returns Returns "OK" on success. Invalid calls return the plain string "Error" (does not throw).
* @example
* Platform.Load("core", "1.1.5");
* var myList = List.Init("myList");
* var status = myList.Subscribers.Upsert("aruiz@example.com", { ZipCode: "46202" });
*/
Upsert(emailAddress: string | object, attributes: object): string;
readonly Tracking: ListSubscribersTrackingInstance;
}
interface SubscriberAttributesInstance {
/**
* Returns an array of attributes associated with the previously initialized subscriber.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns List of attribute objects for the subscriber.
* @example
* Platform.Load("core", "1.1.5");
* var subObj = Subscriber.Init("SubKey");
* var attributes = subObj.Attributes.Retrieve();
*/
Retrieve(): object[];
}
interface SubscriberListsInstance {
/**
* Returns the lists the previously initialized subscriber is a member of.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns List of list objects the subscriber belongs to.
* @example
* Platform.Load("core", "1.1.5");
* var subObj = Subscriber.Init("SubKey");
* var listArray = subObj.Lists.Retrieve();
*/
Retrieve(): object[];
}
interface SendTrackingClicksInstance {
/**
* Returns click tracking data for the previously initialized send.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Salesforce docs (and older references) document click tracking as `.Tracking.ClickRetrieve(filter)`. At runtime that name is `undefined`; the working member is `.Tracking.Clicks.Retrieve(filter)` (a `Clicks` sub-object with a `Retrieve` method), matching the TriggeredSend.Tracking.Clicks pattern.
* @param filter - WSProxy-style filter restricting results.
* @returns List of click tracking records matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var singleSend = Send.Init(12345);
* var results = singleSend.Tracking.Clicks.Retrieve({ Property: "ID", SimpleOperator: "equals", Value: 12345 });
*/
Retrieve(filter: object): object[];
}
interface SendTrackingTotalByIntervalInstance {
/**
* Returns aggregated tracking data for the previously initialized send. Aggregates by `type` over the date range, grouped by `groupBy`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Salesforce docs (and older references) document interval aggregation as `.Tracking.TotalByIntervalRetrieve(type, startDate, endDate, groupBy)`. At runtime that name is `undefined`; the working member is `.Tracking.TotalByInterval.Retrieve(type, startDate, endDate, groupBy)` (a `TotalByInterval` sub-object with a `Retrieve` method), matching the TriggeredSend.Tracking.TotalByInterval pattern.
* @param type - Type of data to aggregate.
* @param startDate - Start date of the data period (MM-DD-YYYY string or Date).
* @param endDate - End date of the data period (MM-DD-YYYY string or Date).
* @param groupBy - Interval used to aggregate data.
* @returns List of aggregated tracking records.
* @example
* Platform.Load("core", "1.1.5");
* var singleSend = Send.Init(12345);
* var results = singleSend.Tracking.TotalByInterval.Retrieve("Click", "07-01-2010", "07-31-2010", "day");
*/
Retrieve(type: string, startDate: string | Date, endDate: string | Date, groupBy: string): object[];
}
interface TriggeredSendTrackingClicksInstance {
/**
* Returns click tracking information for the previously initialized triggered send definition.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - WSProxy-style filter restricting click results.
* @returns List of click tracking records matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var tsd = TriggeredSend.Init("MyTSDKey");
* var results = tsd.Tracking.Clicks.Retrieve({ Property: "SendUrlID", SimpleOperator: "equals", Value: 12345 });
*/
Retrieve(filter: object): object[];
}
interface TriggeredSendTrackingTotalByIntervalInstance {
/**
* Returns aggregated tracking data for the previously initialized triggered send. Aggregates by `type` over the date range, grouped by `groupBy`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param type - Type of data to aggregate.
* @param startDate - Start date of the data period (MM-DD-YYYY string or Date).
* @param endDate - End date of the data period (MM-DD-YYYY string or Date).
* @param groupBy - Interval used to aggregate data.
* @returns List of aggregated tracking records.
* @example
* Platform.Load("core", "1.1.5");
* var tsd = TriggeredSend.Init("MyTSDKey");
* var results = tsd.Tracking.TotalByInterval.Retrieve("Click", "07-01-2010", "07-31-2010", "day");
*/
Retrieve(type: string, startDate: string | Date, endDate: string | Date, groupBy: string): object[];
}
interface SendTrackingInstance {
readonly Clicks: SendTrackingClicksInstance;
readonly TotalByInterval: SendTrackingTotalByIntervalInstance;
}
interface TriggeredSendTrackingInstance {
/**
* Returns tracking data for the previously initialized triggered send definition.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Optional WSProxy-style filter object.
* @returns List of tracking records.
* @example
* Platform.Load("core", "1.1.5");
* var tsd = TriggeredSend.Init("MyTSDKey");
* var tsdTracking = tsd.Tracking.Retrieve();
*/
Retrieve(filter?: object): object[];
readonly Clicks: TriggeredSendTrackingClicksInstance;
readonly TotalByInterval: TriggeredSendTrackingTotalByIntervalInstance;
}
// ── Core Library namespaces ──────────────────────────────────────────────────
declare namespace Account {
/**
* Initializes an Account instance bound to the specified external key. Required before invoking any other Account method on the returned instance.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/account/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Proven at runtime on the parent BU: Account.Init returns the same instance regardless of the key passed — a CustomerKey GUID, a numeric MID, a Name ("SFMC2Slack"), or a nonsense key all yield an identical stub exposing only an Update function ({"Update":"function"}). No account properties are readable from the instance (ID/Name/CustomerKey return undefined), so Init does not itself confirm whether the key resolves to a real account.
* @param key - External key of the account.
* @returns An Account instance. Proven at runtime on the parent BU: the returned object exposes a single enumerable member, the Update method (Stringifies as {"Update":"function"}). It carries no readable account fields — inst.ID, inst.Name and inst.CustomerKey all read back undefined — and the same stub is returned for any key value (the running account's CustomerKey GUID, a numeric MID, a Name such as "SFMC2Slack", or a nonsense string). Use the returned instance to call .Update(...); use Account.Retrieve to read account fields.
* @example
* Platform.Load("core", "1.1.5");
* var myAccount = Account.Init("MyCustomerKey");
*/
function Init(key: string): AccountInstance;
/**
* Retrieves accounts based on the specified filter criteria.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/account/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Proven at runtime on the parent BU: Account.Retrieve resolves only the running session's own account, and it does so via Property "Name", "ID", or "CustomerKey". For "ID", both the numeric form and the string form of the running account's MID resolved. Requests for any other (child) business unit returned a zero-length collection for every property and value tried — by Name ("Retail Test"), by ID (7316951), and by CustomerKey (both GUID keys and plain-string keys such as "DEV"). The properties "MID", "AccountID" and "BusinessUnitID" are not recognized and always returned empty. Neither the matched nor the empty collection is an instanceof Array in this engine, so guard with a truthy .length check before indexing.
* @param filter - Criteria used to search for the account. Use a filter expression or a JSON object containing filter and additional search parameters.
* @returns On a match returns an array-like collection of account rows (proven at runtime: exposes .length and .push and Stringifies as a JSON array with length 1), though it is not an instanceof Array in this engine. On no match returns the same array-like shape with .length of 0 (it still exposes .push, Stringifies as [] and has no enumerable keys); that zero-length collection is itself falsy in this engine, so both a truthy check and a .length check reject it. Proven at runtime on the parent BU: filtering by Property "Name" (equals "Accenture SFMC Global"), "ID" (equals the running account MID or greaterThan 0), or "CustomerKey" (equals the account CustomerKey GUID) each returned the running BU's own account row. Filtering for any child BU — by Name, by ID, or by CustomerKey (GUID or plain-string key) — returned the empty [] shape, as did unrecognized properties "MID" and "AccountID". Only the running session's own account resolves. A matched row exposes the full Account SOAP object; observed fields include AccountType, ParentID, BrandID, PrivateLabelID, ReportingParentID, Name, Email, FromName, BusinessName, Phone, Address, Fax, City, State, Zip, Country, IsActive, IsTestAccount, OrgID, DBID, ParentName, CustomerID, DeletedDate, EditionID, Children, Subscription, PrivateLabels, BusinessRules, AccountUsers, InheritAddress, IsTrialAccount, Locale, ParentAccount, TimeZone (a nested object with ID/Name/CustomerKey), Roles, StackID, SalesForceID, LanguageLocale, IndustryCode, Edition, SalesforceOrgID, AccountState, SubscriptionRestrictionFlags, Client, PartnerKey, PartnerProperties, CreatedDate, ModifiedDate, ID, ObjectID, CustomerKey, Owner, CorrelationID, ObjectState and IsPlatformObject, plus a *Specified boolean companion for many numeric/date fields.
* @example
* Platform.Load("core", "1.1.5");
* // Resolves the running session's own account by Name, ID, or CustomerKey
* var getAcct = Account.Retrieve({Property:"CustomerKey",SimpleOperator:"equals",Value:"MyAccountCustomerKey"});
* if (getAcct && getAcct.length) { Platform.Response.Write(getAcct[0].Name); }
*/
function Retrieve(filter: object): object[];
}
interface AccountInstance {
/**
* Updates the account with the supplied attributes. If `properties` includes `TimeZoneID`, the call uses that value to update the account time zone.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/account/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Proven at runtime on the parent BU against the running session's own account, resolved via Account.Init(): .Update(...) returned the plain string "Error" (typeof "string") for every real single-field payload tried — { CustomerKey }, { FromName }, { BusinessName }, a CustomerKey-only object, an empty object {}, and an { ID, CustomerKey } object. Set/verify/restore cycles confirmed none of these writes persisted: reading each field back by ID after the call showed the original value unchanged (CustomerKey stayed "D61BC7A3-E557-4ABD-B8E0-B73B7202C1BC", FromName stayed "Accenture SFMC Global", BusinessName stayed "Accenture"). The user confirmed CustomerKey is a safe, IsUpdatable field, yet updating it via the Init stub still returned "Error" and did not persist. The only object that carries an Update method is the Account.Init(...) stub; the row objects returned by Account.Retrieve have no Update method (typeof row.Update is "undefined"), and calling row.Update(...) throws a Jint "Object expected: Update" exception. A { Description } payload throws the plain string "Error Updating Account." instead of returning "Error" (Description is not a real SOAP Account field). The official-doc "OK" success return was not reproduced for any payload. Separately, a child BU could not be resolved from the current session (Account.Retrieve returned the empty [] shape) and Account.Init().Update(...) also returned "Error".
* @deprecated
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @param properties - Account attributes to change.
* @returns Returns a string. On failure it returns the plain string "Error"; for one payload shape it instead throws the plain string "Error Updating Account." (both proven at runtime; which one occurs depends on the payload). The documented success return is the string "OK"; a success return was not reproduced at runtime in this project, and set/re-read cycles on the running BU showed no field change persisted. Because it can throw a plain string, wrap the call in try/catch and treat any non-"OK" return — and any throw — as failure.
* @example
* Platform.Load("core", "1.1.5");
* var myAccount = Account.Init("MyCustomerKey");
* var status = myAccount.Update({ "FromName" : "Demo From Name" });
*/
Update(properties: object): string;
}
declare namespace Account.Tracking {
/**
* Returns an array of tracking data related to the accounts specified by the passed filter argument.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/account/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Criteria used to search for the account.
* @returns Array-like collection of tracking rows (proven at runtime with .length and JSON like [{"Sends":{"Total":0},"Bounces":{"Total":0,"HardBounces":0,"SoftBounces":0,"BlockBounces":0,"TechnicalBounces":0,"UnknownBounces":0},"Clicks":{"Total":0,"Unique":0},"Opens":{"Total":0,"Unique":0},"Unsubscribes":{"Unique":0}}]). Each row exposes Sends, Bounces, Clicks, Opens and Unsubscribes counter objects.
* @example
* Platform.Load("core", "1.1.5");
* var acctTracking = Account.Tracking.Retrieve({Property:"CustomerKey",SimpleOperator:"equals",Value:"MyAccount"});
*/
function Retrieve(filter: object): object[];
}
declare namespace AccountUser {
/**
* Initializes an AccountUser instance bound to the specified external key and client ID (MID). Required before invoking any other AccountUser method on the returned instance.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/accountuser/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (Parent BU CloudPage): the returned instance is an opaque stub, not the populated user record the docs imply. Reading ID, Name or CustomerKey off it yields undefined, and Init() does not validate targetUserKey — passing a key that matches no user still returns an object exposing Update/Activate/Deactivate that is indistinguishable from one built with a real key. A bad key therefore only surfaces when an instance method is called; use AccountUser.Retrieve() when you need to read user fields or check existence.
* @param targetUserKey - External key of the user.
* @param myClientID - MID of the business unit.
* @returns An initialized AccountUser bound to the specified external key and client ID.
* @example
* Platform.Load("core", "1.1.5");
* var acctUser = AccountUser.Init("myAccountUser", 123456789);
*/
function Init(targetUserKey: string, myClientID: string | number): AccountUserInstance;
/**
* Creates a new account user from the supplied properties object.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/accountuser/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs state Add returns "OK" on success or throws on failure. In our runtime tests the call was blocked by a tenant permission gate on AccountUser writes rather than by a defect in the method. Tested on a Parent BU session (the correct context for AccountUser edits): a short payload returned the plain string "Error" (it did NOT throw); a full payload (Name/UserID/Password/Email/CustomerKey/ClientID/DefaultBusinessUnit/AssociatedBusinessUnits) threw "Error adding AccountUser". A control WSProxy createItem("AccountUser", ...) on the same run named the cause explicitly: StatusCode "Error", ErrorCode 11001, StatusMessage "User 0 does not have permission to edit ACCOUNTUSERS on account ." On the same run Subscriber.Add and DataExtension.Retrieve both succeeded, so the run had a working write/read path for other object types. A session whose user carries the ACCOUNTUSERS edit permission was not available, so the success ("OK") path was never exercised. Treat any non-"OK" return as failure.
* @deprecated
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @param properties - JSON object describing the new account user (Name, UserID, Password, Email, ClientID, DefaultBusinessUnitKey, AssociatedBusinessUnits, ...).
* @returns Returns "OK" on success; returns the string "Error" (not a throw) on failure.
* @example
* Platform.Load("core", "1.1.5");
* var newUser = {
* "Name": "Andrea Cruz",
* "UserID": "acruz",
* "Password": "insert new password here",
* "Email": "acruz@example.com",
* "ClientID": 123456789,
* "DefaultBusinessUnitKey": "childBUKey",
* "AssociatedBusinessUnits": ["childBUKey", "grandchildBUKey"]
* };
* var status = AccountUser.Add(newUser);
*/
function Add(properties: object): string;
/**
* Retrieves account users based on the specified filter criteria.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/accountuser/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (Parent BU CloudPage): the documented object[] return value is not a real JavaScript Array — `result instanceof Array` is false both when the filter matches and when it matches nothing. It is index- and length-addressable, so a classic for loop works, but Array.prototype methods and instanceof checks must not be relied on; copy the entries into a real array first if you need them.
* @param filter - Criteria used to search for the account user.
* @returns List of results matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var accountUser = AccountUser.Retrieve({Property:"CustomerKey",SimpleOperator:"equals",Value:"MyAccount"});
*/
function Retrieve(filter: object): object[];
}
interface AccountUserInstance {
/**
* Updates the account user with the supplied attributes.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/accountuser/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. In our runtime tests the call was blocked by a tenant permission gate on AccountUser writes rather than by a defect in the method. Tested on a Parent BU session (the correct context for AccountUser edits): AccountUser.Init(key, ).Update({ Name: ... }) returned the plain string "Error" (it did NOT throw). A control WSProxy createItem("AccountUser", ...) on the same run named the cause explicitly: ErrorCode 11001, StatusMessage "User 0 does not have permission to edit ACCOUNTUSERS on account .", while Subscriber writes and DataExtension.Retrieve on the same run succeeded. A session whose user carries the ACCOUNTUSERS edit permission was not available, so the success ("OK") path was never exercised.
* @deprecated
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @param properties - Attributes of the account user to change.
* @returns Documented to return "OK" on success. Observed at runtime returning the plain string "Error" on failure (not a throw).
* @example
* Platform.Load("core", "1.1.5");
* var acctUser = AccountUser.Init("myAccountUser", 123456789);
* var status = acctUser.Update({ "Password": "XXXXX" });
*/
Update(properties: object): string;
/**
* Activates the account user.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/accountuser/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. In our runtime tests the call was blocked by a tenant permission gate on AccountUser writes rather than by a defect in the method. Tested on a Parent BU session (the correct context for AccountUser edits): AccountUser.Init(key, ).Activate() returned the plain string "Error" (it did NOT throw). A control WSProxy createItem("AccountUser", ...) on the same run named the cause explicitly: ErrorCode 11001, StatusMessage "User 0 does not have permission to edit ACCOUNTUSERS on account .", while Subscriber writes and DataExtension.Retrieve on the same run succeeded. A session whose user carries the ACCOUNTUSERS edit permission was not available, so the success ("OK") path was never exercised.
* @deprecated
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @returns Documented to return "OK" on success. Observed at runtime returning the plain string "Error" on failure (not a throw).
* @example
* Platform.Load("core", "1.1.5");
* var acctUser = AccountUser.Init("myAccountUser", 123456789);
* var status = acctUser.Activate();
*/
Activate(): string;
/**
* Deactivates the account user. Note: account users cannot be deleted via server-side JavaScript — deactivation is the only "removal" path.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/accountuser/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. In our runtime tests the call was blocked by a tenant permission gate on AccountUser writes rather than by a defect in the method. Tested on a Parent BU session (the correct context for AccountUser edits): AccountUser.Init(key, ).Deactivate() returned the plain string "Error" (it did NOT throw). A control WSProxy createItem("AccountUser", ...) on the same run named the cause explicitly: ErrorCode 11001, StatusMessage "User 0 does not have permission to edit ACCOUNTUSERS on account .", while Subscriber writes and DataExtension.Retrieve on the same run succeeded. A session whose user carries the ACCOUNTUSERS edit permission was not available, so the success ("OK") path was never exercised.
* @deprecated
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @returns Documented to return "OK" on success. Observed at runtime returning the plain string "Error" on failure (not a throw).
* @example
* Platform.Load("core", "1.1.5");
* var acctUser = AccountUser.Init("myAccountUser", 123456789);
* var status = acctUser.Deactivate();
*/
Deactivate(): string;
}
/**
* @deprecated
*/
declare namespace Portfolio {
/**
* Initializes a Portfolio instance bound to the specified external key. Required before invoking any other Portfolio method on the returned instance. DEPRECATED — Portfolio is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/portfolio/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the portfolio.
* @returns An initialized Portfolio bound to the specified external key.
* @example
* Platform.Load("core", "1.1.5");
* var portObj = Portfolio.Init("myPortfolioCK");
*/
function Init(key?: string): PortfolioInstance;
/**
* Creates a new portfolio (file) object from the supplied properties. DEPRECATED — Portfolio is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/portfolio/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. DEPRECATED — the Portfolio is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder (Classic Content reached end of life on 24 Apr 2023); prefer Content Builder Asset REST endpoints for new work. Runtime-verified: a full payload of DisplayName + CustomerKey + CategoryID + FileName + FileLocation creates the item and returns the string "OK". The docs say failures throw — they do NOT: calling Add with zero arguments returns the plain string "Error" instead of throwing, so always compare the return value against "OK" rather than relying on try/catch. CategoryID must reference an existing media/portfolio folder and FileLocation must be a reachable URL whose file type matches the FileName extension; a mismatched extension makes the call return "Error". A surplus second argument is accepted and ignored. Re-adding the same CustomerKey returns "OK" without creating a duplicate.
* @param properties - JSON object describing the new portfolio item (DisplayName, CustomerKey, CategoryID, FileName, FileLocation).
* @returns Returns "OK" on success; returns the string "Error" (not a throw) on failure.
* @example
* Platform.Load("core", "1.1.5");
* var newPortfolio = {
* DisplayName: "SSJS Portfolio Object",
* CustomerKey: "myPortfolioCK",
* CategoryID: 12345,
* FileName: "logo.png",
* FileLocation: "https://www.example.com/Portals/0/images/global/logo_main.png"
* };
* var status = Portfolio.Add(newPortfolio);
*/
function Add(properties: object): string;
/**
* Returns an array of portfolio objects matching the specified filter. DEPRECATED — Portfolio is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/portfolio/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. DEPRECATED — the Portfolio is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder (Classic Content reached end of life on 24 Apr 2023); prefer Content Builder Asset REST endpoints for new work. Runtime-verified: the return value is array-LIKE but NOT a real JS array — `instanceof Array` is false even though `.length`, `.push` and `.slice` are present and index access works, so avoid `instanceof` checks and iterate with a classic for-loop over `.length`. A filter matching nothing yields a zero-length collection (never null), so test `.length` rather than truthiness. Each item is a SOAP Portfolio object exposing Source, CategoryID, FileName, DisplayName, Description, FileSizeKB, FileURL, ThumbURL, Client, CreatedDate, ModifiedDate, ID, ObjectID, CustomerKey and the matching *Specified booleans. The filter argument is optional in practice — calling Retrieve with no arguments returns every item, and a surplus second argument is ignored — but passing a non-object (e.g. a string) throws "Error Retrieving Portfolios".
* @param filter - Criteria used to search for portfolio objects. PascalCase WSProxy-style filter object: `{Property, SimpleOperator, Value}`.
* @returns List of portfolio objects matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var portObjArr = Portfolio.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "PortfolioObjectKey" });
*/
function Retrieve(filter?: object): object[];
}
/**
* @deprecated
*/
interface PortfolioInstance {
/**
* Updates the portfolio object with the supplied attributes. DEPRECATED — Portfolio is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/portfolio/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. DEPRECATED — the Portfolio is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder (Classic Content reached end of life on 24 Apr 2023); prefer Content Builder Asset REST endpoints for new work. The official docs state Update returns "OK" on success or throws on failure. No working invocation was found at runtime, even though Init, Add, Retrieve and Remove all work on the same item: every attempt either returned the string "Error" or threw "Error Updating Portfolio", and the stored record never changed. Attempts covered instances created via Init(CustomerKey) and Init(ObjectID), payloads with a single field ({DisplayName} / {Description}), payloads repeating the identifying fields ({CustomerKey, DisplayName, CategoryID}), payloads carrying the ObjectID, the full Add-shaped payload including FileName + FileLocation, an array-wrapped payload, and a no-op update writing the current DisplayName back onto a pre-existing (non-probe) portfolio item. There is no static Portfolio.Update — that identifier is undefined. Treat the method as non-functional: to change a portfolio item, Remove it and Add it again, or use the Content Builder Asset REST endpoints.
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @param properties - Attributes to change on the portfolio object.
* @returns Returns "OK" on success; returns the string "Error" (not a throw) on failure.
* @example
* Platform.Load("core", "1.1.5");
* var portObj = Portfolio.Init("myPortfolioCK");
* var status = portObj.Update({ DisplayName: "Updated SSJS Image" });
*/
Update(properties: object): string;
/**
* Removes the previously initialized portfolio object. DEPRECATED — Portfolio is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/portfolio/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. DEPRECATED — the Portfolio is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder (Classic Content reached end of life on 24 Apr 2023); prefer Content Builder Asset REST endpoints for new work. Runtime-verified: deleting an existing item returns "OK" and a follow-up Retrieve confirms it is gone. The return value is not a reliable success signal, however — calling Remove again on the already-deleted item still returns "OK" instead of "Error" or a throw, so verify deletion with a Retrieve rather than trusting the return value. An instance built from a key that never existed returns the plain string "Error" (it does not throw). A surplus argument is accepted and ignored.
* @returns Returns "OK" on success; returns the string "Error" (not a throw) on failure.
* @example
* Platform.Load("core", "1.1.5");
* var portObj = Portfolio.Init("myPortfolioCK");
* var status = portObj.Remove();
*/
Remove(): string;
}
/**
* @deprecated
*/
declare namespace ContentAreaObj {
/**
* Initializes a ContentAreaObj instance bound to the specified external key. DEPRECATED — Content Areas are a legacy Classic Content feature; prefer Content Builder assets for new work.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/contentareaobj/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the content area.
* @returns An initialized ContentAreaObj bound to the specified external key.
* @example
* Platform.Load("core", "1.1.1");
* var area = ContentAreaObj.Init("myCA");
*/
function Init(key: string): ContentAreaObjInstance;
/**
* Creates a new content area from the supplied properties and returns an initialized ContentAreaObj instance bound to it. DEPRECATED — Content Areas are a legacy Classic Content feature.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/contentareaobj/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official `Add` reference lists `@returns {Enum("OK")}`, but runtime returns an initialized ContentAreaObj instance (an object exposing `Update`/`Remove`, identical in shape to `Init`) — matching the doc's own H1 summary ("returns an initialized object") rather than the `@returns` annotation.
* @param properties - JSON object describing the new content area (CustomerKey, Name, CategoryID, Layout, LayoutSpecified, Content).
* @returns An initialized ContentAreaObj instance bound to the newly created content area (exposes Update/Remove). Note: contrary to the `@returns {Enum("OK")}` annotation in the official docs, runtime returns an instance object, not the string "OK".
* @example
* Platform.Load("core", "1.1.1");
* var exampleArea = {
* CustomerKey: "exampleArea",
* Name: "SSJS Content Area Example",
* CategoryID: 123456,
* Layout: "RawText",
* LayoutSpecified: true,
* Content: "This is example content"
* };
* var area = ContentAreaObj.Add(exampleArea);
*/
function Add(properties: object): ContentAreaObjInstance;
/**
* Returns an array of content areas matching the specified filter. DEPRECATED — Content Areas are a legacy Classic Content feature.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/contentareaobj/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - PascalCase WSProxy-style filter object: `{Property, SimpleOperator, Value}`.
* @returns A host array of content areas matching the filter (empty array when none match). Reports as `[object Array]` and exposes `.length`, but `instanceof Array` is false (host-backed collection).
* @example
* Platform.Load("core", "1.1.1");
* var results = ContentAreaObj.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "myCA" });
*/
function Retrieve(filter: object): object[];
}
/**
* @deprecated
*/
interface ContentAreaObjInstance {
/**
* Updates the content area with the supplied attributes. WARNING: when the initialized external key does not resolve, the call returns "Error" and still creates an empty content area under that key — confirm the key via ContentAreaObj.Retrieve before updating. DEPRECATED — Content Areas are a legacy Classic Content feature.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/contentareaobj/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - Attributes to change on the content area.
* @returns Returns "OK" on success and "Error" on failure; the call returns a status string rather than throwing.
* @example
* Platform.Load("core", "1.1.1");
* var obj = ContentAreaObj.Init("myCA");
* var status = obj.Update({ Name: "Name Updated By SSJS" });
*/
Update(properties: object): string;
/**
* Removes the previously initialized content area. DEPRECATED — Content Areas are a legacy Classic Content feature.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/contentareaobj/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns Returns "OK" on success and "Error" on failure (for example when the external key does not resolve); the call returns a status string rather than throwing and, unlike Update, creates nothing when it fails.
* @example
* Platform.Load("core", "1.1.1");
* var obj = ContentAreaObj.Init("myCA");
* var status = obj.Remove();
*/
Remove(): string;
}
declare namespace Folder {
/**
* Initializes a Folder instance, optionally bound to the specified external key. When called without arguments, a subsequent `.SetID(id)` call is required to bind the instance to a specific folder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/folder/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the folder. Optional — pass nothing and use `SetID()` when the folder has no external key.
* @returns An initialized Folder; bound to the specified external key when one is supplied.
* @example
* Platform.Load("core", "1");
* var myFolder = Folder.Init("myFolder");
* // or, when the folder has no external key:
* var myIDFolder = Folder.Init();
* myIDFolder.SetID(12345);
*/
function Init(key?: string): FolderInstance;
/**
* Creates a new folder as a child of an existing folder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/folder/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - JSON object describing the new folder (Name, CustomerKey, Description, ContentType, IsActive, IsEditable, AllowChildren, ParentFolderID).
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var newFolder = {
* Name: "Test Add Folder",
* CustomerKey: "test_folder_key",
* Description: "Test added",
* ContentType: "email",
* IsActive: "true",
* IsEditable: "true",
* AllowChildren: "false",
* ParentFolderID: 123456
* };
* var status = Folder.Add(newFolder);
*/
function Add(properties: object): string;
/**
* Returns an array of folders matching the specified filter. Supports simple `{Property, SimpleOperator, Value}` filters and complex filters with `LeftOperand`, `LogicalOperator`, `RightOperand`. Use dot notation (e.g. `ParentFolder.Name`) to filter on child fields.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/folder/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - WSProxy-style filter object — simple or compound with `AND`/`OR`.
* @returns Array of folder objects (including nested `ParentFolder` info).
* @example
* Platform.Load("core", "1");
* var folders = Folder.Retrieve({
* Property: "ParentFolder.Name",
* SimpleOperator: "equals",
* Value: "RewardsProgram"
* });
* Write(Stringify(folders));
*/
function Retrieve(filter: object): object[];
}
interface FolderInstance {
/**
* Updates the folder with the supplied attributes.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/folder/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - Attributes to change on the folder.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var myFolder = Folder.Init("myFolder");
* var status = myFolder.Update({ Name: "Updated Folder Name" });
*/
Update(properties: object): string;
/**
* Removes the previously initialized folder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/folder/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var myFolder = Folder.Init("myFolder");
* myFolder.Remove();
*/
Remove(): string;
/**
* Binds a previously initialized Folder instance to a specific folder ID. Use this when the folder has no external key, after calling `Folder.Init()` without arguments.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/folder/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param id - The folder ID to bind to this Folder instance.
* @returns No return value.
* @example
* Platform.Load("core", "1.1.5");
* var myIDFolder = Folder.Init();
* myIDFolder.SetID(12345);
*/
SetID(id: string | number): void;
}
/**
* @deprecated
*/
declare namespace Template {
/**
* Initializes a Template instance bound to the specified external key. Required before invoking any other Template method on the returned instance. Deprecated — Template is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/template/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the template.
* @returns An initialized Template bound to the specified external key.
* @example
* Platform.Load("core", "1");
* var t = Template.Init("myTemplate");
*/
function Init(key: string): TemplateInstance;
/**
* Creates a new template from the supplied properties. Deprecated — Template is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/template/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - JSON object describing the new template (CustomerKey, TemplateName, LayoutHTML).
* @returns Returns "OK" on success or "Error" on failure (does not throw).
* @example
* Platform.Load("core", "1");
* var myTemp = {
* CustomerKey: "test_template",
* TemplateName: "SSJS Test Template",
* LayoutHTML: "this is some HTML"
* };
* var status = Template.Add(myTemp);
*/
function Add(properties: object): string;
/**
* Returns an array of templates matching the specified filter. Pass `{ Filter: { Property, SimpleOperator, Value }, QueryAllAccounts: true }` to query across all accessible accounts. Deprecated — Template is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/template/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - PascalCase WSProxy-style filter object, optionally wrapped with `QueryAllAccounts: true`.
* @returns List of templates matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var getTemplate = Template.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "MyTemplate" });
*/
function Retrieve(filter: object): object[];
}
/**
* @deprecated
*/
interface TemplateInstance {
/**
* Updates the template with the supplied attributes. Deprecated — Template is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/template/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - Attributes to change on the template.
* @returns Returns "OK" on success or "Error" on failure (does not throw).
* @example
* Platform.Load("core", "1.1.5");
* var myTemplate = Template.Init("myTemplateCK");
* var status = myTemplate.Update({ TemplateName: "Edited Template" });
*/
Update(properties: object): string;
}
declare namespace DeliveryProfile {
/**
* Initializes a DeliveryProfile instance bound to the specified external key. Required before invoking any other DeliveryProfile method on the returned instance.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/deliveryprofile/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the delivery profile.
* @returns An initialized DeliveryProfile bound to the specified external key.
* @example
* Platform.Load("core", "1");
* var myProfile = DeliveryProfile.Init("myDeliveryProfile");
*/
function Init(key: string): DeliveryProfileInstance;
/**
* Creates a new delivery profile from the supplied properties.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/deliveryprofile/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a CloudPage: returns a CLR object (`ExactTarget.Integration.WSDL.DeliveryProfile`), not the string "OK". The returned object stringifies to its .NET type name and its properties are NOT readable from SSJS ("Use of Common Language Runtime (CLR) is not allowed"). Treat a non-throwing return as success.
* @param properties - JSON object describing the new delivery profile (Name, CustomerKey, Description, SourceAddressType, ...).
* @returns A CLR DeliveryProfile object on success (its properties are not readable from SSJS). Treat a non-throwing return as success.
* @example
* Platform.Load("core", "1.1.5");
* var newDP = {
* Name: "SSJS Added Delivery Profile",
* CustomerKey: "test_delivery_profile",
* Description: "An SSJS Added Profile",
* SourceAddressType: "DefaultPrivateIPAddress"
* };
* var status = DeliveryProfile.Add(newDP);
*/
function Add(properties: object): object;
}
interface DeliveryProfileInstance {
/**
* Updates the delivery profile with the supplied attributes.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/deliveryprofile/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - Attributes to change on the delivery profile.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var myProfile = DeliveryProfile.Init("myDeliveryProfile");
* var status = myProfile.Update({ Name: "SSJS Updated Delivery Profile" });
*/
Update(properties: object): string;
/**
* Removes the previously initialized delivery profile.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/deliveryprofile/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var myProfile = DeliveryProfile.Init("myDeliveryProfile");
* var status = myProfile.Remove();
*/
Remove(): string;
}
declare namespace SenderProfile {
/**
* Initializes a SenderProfile instance bound to the specified external key. Note: SenderProfile methods only work on landing pages — they cannot run inside email messages at send time.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senderprofile/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the sender profile.
* @returns An initialized SenderProfile bound to the specified external key.
* @example
* Platform.Load("core", "1");
* var myProfile = SenderProfile.Init("mySenderProfile");
*/
function Init(key: string): SenderProfileInstance;
/**
* Creates a new sender profile from the supplied properties.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senderprofile/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs annotate Add as returning the string "OK". Runtime-verified on a live CloudPage: it returns a CLR object (`typeof` is `clr`; it stringifies to `ExactTarget.Integration.WSDL.SenderProfile`), not "OK". Reading any property off it throws "Use of Common Language Runtime (CLR) is not allowed", so the object is opaque from SSJS — treat any non-throwing return as success. This mirrors DeliveryProfile.Add.
* @param properties - JSON object describing the new sender profile (Name, CustomerKey, Description, FromName, FromAddress, ...).
* @returns Returns a CLR SenderProfile object (opaque from SSJS) on success; throws on failure. Not the "OK" string the docs imply.
* @example
* 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);
*/
function Add(properties: object): object;
}
interface SenderProfileInstance {
/**
* Updates the sender profile with the supplied attributes.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senderprofile/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - Attributes to change on the sender profile.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var myProfile = SenderProfile.Init("mySenderProfile");
* var status = myProfile.Update({ Name: "SSJS Updated Sender Profile" });
*/
Update(properties: object): string;
/**
* Removes the previously initialized sender profile.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senderprofile/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var myProfile = SenderProfile.Init("mySenderProfile");
* var status = myProfile.Remove();
*/
Remove(): string;
}
declare namespace SendClassification {
/**
* Initializes a SendClassification instance bound to the specified external key. Required before invoking any other SendClassification method on the returned instance.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/sendclassification/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the send classification.
* @returns An initialized SendClassification bound to the specified external key.
* @example
* Platform.Load("core", "1");
* var sc = SendClassification.Init("mySendClassification");
*/
function Init(key: string): SendClassificationInstance;
/**
* Creates a new send classification from the supplied properties.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/sendclassification/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified working on a live CloudPage against real, owned SenderProfile (`ssjs-senderprofile`) and DeliveryProfile (`ssjs-deliveryprofile`) keys: `SendClassification.Add()` creates the object and returns a CLR object (`typeof` is `clr`; it stringifies to `ExactTarget.Integration.WSDL.SenderProfile`), NOT the string "OK" the docs imply. The returned CLR object is opaque from SSJS — enumerating its keys with `for..in` yields none — so treat any non-throwing return as success and read the created record back with `SendClassification.Retrieve` (a Retrieve immediately after Add returned the new record). The `SenderProfileKey` and `DeliveryProfileKey` in `properties` must reference existing profiles by external key; an unresolvable profile key makes the Add fail. This mirrors DeliveryProfile.Add and SenderProfile.Add.
* @param properties - JSON object describing the new send classification (CustomerKey, Name, Description, SenderProfileKey, DeliveryProfileKey).
* @returns Returns a CLR SenderProfile object (opaque from SSJS) on success; throws on failure. Not the "OK" string the docs imply.
* @example
* Platform.Load("core", "1.1.5");
* var newSC = {
* CustomerKey: "mySCKey",
* Name: "SSJS Test SC",
* Description: "Test SSJS description",
* SenderProfileKey: "mySPKey",
* DeliveryProfileKey: "myDPKey"
* };
* SendClassification.Add(newSC);
*/
function Add(properties: object): object;
/**
* Returns an array of send classifications matching the specified filter.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/sendclassification/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - PascalCase WSProxy-style filter object: `{Property, SimpleOperator, Value}`.
* @returns List of send classifications matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var results = SendClassification.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "mySendClassification" });
*/
function Retrieve(filter: object): object[];
}
interface SendClassificationInstance {
/**
* Updates the send classification with the supplied attributes. You must include both `SenderProfileKey` and `DeliveryProfileKey` in `properties` for the update to succeed.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/sendclassification/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - Attributes to change. Must include `SenderProfileKey` and `DeliveryProfileKey`.
* @returns Returns "OK" on success; returns the string "Error" (not a throw) on failure.
* @example
* Platform.Load("core", "1.1.5");
* var sc = SendClassification.Init("mySendClassification");
* var updatedSC = {
* Name: "Updated Send Classification",
* SenderProfileKey: "mySPKey",
* DeliveryProfileKey: "myDPKey"
* };
* var status = sc.Update(updatedSC);
*/
Update(properties: object): string;
/**
* Removes the previously initialized send classification.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/sendclassification/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns Returns "OK" on success; returns the string "Error" (not a throw) on failure.
* @example
* Platform.Load("core", "1.1.5");
* var sc = SendClassification.Init("mySendClassification");
* var status = sc.Remove();
*/
Remove(): string;
}
declare namespace FilterDefinition {
/**
* Initializes a FilterDefinition instance bound to the specified external key. Required before invoking any other FilterDefinition method on the returned instance.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/filterdefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the filter definition.
* @returns An initialized FilterDefinition bound to the specified external key.
* @example
* Platform.Load("core", "1");
* var fd = FilterDefinition.Init("myFilterDef");
*/
function Init(key: string): FilterDefinitionInstance;
/**
* Creates a new filter definition from the supplied properties. No working Core `Add` invocation was found at runtime against an owned source DE — the documented simple-filter payload returns the string `"Error"` and does not create a row. A `DataFilter` property (instead of `Filter`) throws the raw string `"Error adding FilterDefinition"`. Prefer creating definitions via mcdev/`dataFilter` or SOAP when Core Add returns `"Error"`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/filterdefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. No working invocation of `FilterDefinition.Add` was found on the QA CloudPage: with the owned source DE `SSJSGUIDE_TYPES` present, the documented simple-filter payload (`Filter: {Property, SimpleOperator, Value}` + `DataSource: { Type: "DataExtension", CustomerKey }`) returns the plain string `"Error"` (`typeof === "string"`) and does not create a retrievable definition (Core `Retrieve` and WSProxy `retrieve` both stay empty for the probe key). The same `"Error"` return was observed under Core `"1"`, `"1.1.1"`, and `"1.1.5"`, and with CategoryID / alternate DataSource shapes. A LeftOperand/LogicalOperator/RightOperand complex `Filter` also returns `"Error"` (does not throw). Using a `DataFilter` property instead of `Filter` throws the raw string `"Error adding FilterDefinition"` (`typeof e === "string"`). Observed WSProxy facts (reported, not interpreted as a cause): `createItem("FilterDefinition", …)` failed and `deleteItem` reported a permission error. Filters can still be created outside Core (e.g. mcdev `dataFilter` deploy). The official docs imply Add returns `"OK"` or throws; the success (`"OK"`) path could not be reproduced. Note: `Add` is a STATIC method on `FilterDefinition`; the instance returned by `Init()` exposes only `Update` and `Remove`.
* @deprecated
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @param properties - JSON object describing the new filter definition (Name, CustomerKey, a simple `Filter: {Property, SimpleOperator, Value}`, and a `DataSource: {Type, CustomerKey}`).
* @returns Documented as `"OK"` on success. At runtime the documented simple-filter payload returns `"Error"` and creates nothing; a `DataFilter` property throws the raw string `"Error adding FilterDefinition"`.
* @example
* Platform.Load("core", "1");
* var newFD = {
* Name: "SSJS Filter Definition",
* CustomerKey: "myFilterDef",
* Filter: { Property: "Pk", SimpleOperator: "equals", Value: "test" },
* DataSource: { Type: "DataExtension", CustomerKey: "SSJSGUIDE_TYPES" }
* };
* var status = FilterDefinition.Add(newFD);
*/
function Add(properties: object): string;
/**
* Returns an array of filter definitions matching the specified filter.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/filterdefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - PascalCase WSProxy-style filter object: `{Property, SimpleOperator, Value}`.
* @returns Array of filter definitions matching the filter; an empty array when none match.
* @example
* Platform.Load("core", "1.1.5");
* var results = FilterDefinition.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "myFilterDef" });
*/
function Retrieve(filter: object): object[];
}
interface FilterDefinitionInstance {
/**
* Updates the filter definition with the supplied attributes. On failure the Core library either returns the string "Error" (metadata-only payload) or throws the raw string "Error updating FilterDefinition" (when a `Filter` is included).
*
* [ssjs.guide reference](https://ssjs.guide/core-library/filterdefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Read path verified: `FilterDefinition.Init("ssjs-datafilter-test")` returns an instance that exposes `Update` (`typeof === "function"`). No working invocation of `Update` was found: in our runtime tests the write method does not work. Runtime-tested against the OWNED, existing filter `ssjs-datafilter-test` with three payload shapes — so the failure is not a single malformed/incomplete payload; the method simply did not succeed with any shape tried: (1) a FULL Add-style payload (Name + CustomerKey + Description + `Filter: {Property, SimpleOperator, Value}` + `DataSource: {Type, CustomerKey}`) THREW the raw string "Error updating FilterDefinition" (`typeof === "string"`); (2) the same payload WITHOUT `DataSource` also THREW the raw string "Error updating FilterDefinition"; (3) a metadata-only payload (Name + CustomerKey + Description, no Filter/DataSource) returned the string "Error" (`typeof === "string"`, no throw). After each attempt a follow-up `FilterDefinition.Retrieve` confirmed Description was NOT changed (stayed empty) and the ObjectID was unchanged. Observed WSProxy fact (reported, not interpreted as a cause): the equivalent `updateItem("FilterDefinition", { CustomerKey: "ssjs-datafilter-test", Description: "..." })` returned `Status="Error"`. Note the SOAP describe (`mcdev soap FilterDefinition`) reports Name/Description/CustomerKey/DataFilter as `IsUpdatable: true`, i.e. the SOAP schema marks these fields editable, yet no working `Update` invocation was reproduced at runtime. The official docs imply Update returns "OK" or throws; the success ("OK") path could not be reproduced in our tests. On failure the return form varies: a payload containing `Filter` throws the raw string "Error updating FilterDefinition", while a metadata-only payload returns the string "Error".
* @deprecated
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @param properties - Attributes to change on the filter definition.
* @returns Returns "OK" on success. On failure the Core library returns the string "Error" for a metadata-only payload, or throws the raw string "Error updating FilterDefinition" when the payload includes a `Filter`.
* @example
* Platform.Load("core", "1.1.5");
* var fd = FilterDefinition.Init("ssjs-datafilter-test");
* // Full definition shape (Name + CustomerKey + Filter + DataSource, plus any fields to change):
* var status = fd.Update({
* Name: "ssjs-datafilter-test",
* CustomerKey: "ssjs-datafilter-test",
* Description: "Updated description",
* Filter: { Property: "Pk", SimpleOperator: "equals", Value: "test" },
* DataSource: { Type: "DataExtension", CustomerKey: "SSJSGUIDE_TYPES" }
* });
*/
Update(properties: object): string;
/**
* Deletes the previously initialized filter definition. On failure the Core library returns the string "Error" rather than throwing.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/filterdefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Read path verified: `FilterDefinition.Init("ssjs-datafilter-test")` returns an instance that exposes `Remove` (`typeof === "function"`). No working invocation of `Remove` was found: in our runtime tests the write method does not work. Runtime-tested against the OWNED, existing filter `ssjs-datafilter-test`: `.Remove()` returns the string "Error" (`typeof === "string"`) and does NOT throw, and a follow-up `FilterDefinition.Retrieve` confirms the object was NOT deleted (still returned, same ObjectID). The object was then restored from mcdev source to its original `Pk Equals "test"` condition. Observed WSProxy fact (reported, not interpreted as a cause): the equivalent `deleteItem("FilterDefinition", …)` returned `Status="Error"`. The success ("OK") path could not be reproduced in our tests. Consistent with the sibling write methods, failure surfaces as the string "Error" rather than the docs' "OK"/throw.
* @deprecated
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @returns Returns "OK" on success. On failure the Core library returns the string "Error" (it does not throw).
* @example
* Platform.Load("core", "1.1.5");
* var myFD = FilterDefinition.Init("ssjs-datafilter-test");
* myFD.Remove();
*/
Remove(): string;
}
declare namespace QueryDefinition {
/**
* Initializes a QueryDefinition instance bound to the specified external key. Required before invoking any other QueryDefinition method on the returned instance.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/querydefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the query definition.
* @returns An initialized QueryDefinition bound to the specified external key.
* @example
* Platform.Load("core", "1");
* var qd = QueryDefinition.Init("myQueryDef");
*/
function Init(key: string): QueryDefinitionInstance;
/**
* Creates a new query definition from the supplied properties. Pass an optional `CategoryID` to place the query inside a specific folder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/querydefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a live CloudPage: a valid payload returns the string "OK". The official docs say failures throw — they do not: invalid payloads (including the docs' Overwrite sample that SELECTs from the same Data Extension used as Target) return the plain string "Error" instead of throwing. Overwrite requires the target DE to be absent from the QueryText FROM clause (use a different source DE, or use TargetUpdateType "Update" when reading and writing the same DE — Update also requires the target DE to have at least one non-primary-key field). Compare the return value against "OK"; do not rely on try/catch alone.
* @param properties - JSON object describing the new query definition (Name, CustomerKey, optional CategoryID, TargetUpdateType, TargetType, Target, QueryText).
* @returns Returns "OK" on success; returns the string "Error" (not a throw) on failure.
* @example
* Platform.Load("core", "1.1.5");
* var queryDef = {
* Name: "Example Query Definition",
* CustomerKey: "myQueryDef",
* TargetUpdateType: "Overwrite",
* TargetType: "DE",
* Target: { Name: "Example Target DE", CustomerKey: "example_target_de" },
* QueryText: "SELECT Pk FROM [SSJSGUIDE_TYPES]"
* };
* var status = QueryDefinition.Add(queryDef);
*/
function Add(properties: object): string;
/**
* Returns an array of query definitions matching the specified filter. Supports simple `{Property, SimpleOperator, Value}` filters and complex filters with `LeftOperand`, `LogicalOperator`, `RightOperand`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/querydefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - WSProxy-style filter object — simple or compound with `AND`/`OR`.
* @returns Array of query definition objects (with nested `DataExtensionTarget` info when applicable).
* @example
* Platform.Load("Core", "1");
* var result = QueryDefinition.Retrieve({
* Property: "Status",
* SimpleOperator: "equals",
* Value: "Active"
* });
* Write(Stringify(result));
*/
function Retrieve(filter: object): object[];
}
interface QueryDefinitionInstance {
/**
* Updates the query definition with the supplied attributes.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/querydefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: updating an existing definition returns "OK" and the change is visible via Retrieve. The official docs say failures throw — they do not: Update on a key that does not resolve returns the plain string "Error" instead of throwing. Always compare the return value against "OK".
* @param properties - Attributes to change on the query definition.
* @returns Returns "OK" on success; returns the string "Error" (not a throw) on failure.
* @example
* Platform.Load("core", "1.1.5");
* var qd = QueryDefinition.Init("myQueryDef");
* var status = qd.Update({
* Name: "Updated Query Definition Name",
* QueryText: "SELECT Pk FROM [SSJSGUIDE_TYPES]"
* });
*/
Update(properties: object): string;
/**
* Removes the previously initialized query definition.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/querydefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: deleting an existing definition returns "OK" and a follow-up Retrieve confirms it is gone. The official docs say failures throw — they do not: Remove on a key that never existed returns the plain string "Error" instead of throwing. Always compare the return value against "OK" and confirm with Retrieve.
* @returns Returns "OK" on success; returns the string "Error" (not a throw) on failure.
* @example
* Platform.Load("core", "1.1.5");
* var qd = QueryDefinition.Init("myQueryDef");
* var status = qd.Remove();
*/
Remove(): string;
/**
* Executes the query definition. Runs the SQL and writes results into the configured target Data Extension.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/querydefinition/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs annotate Perform as `@returns {Enum("OK")}` and say failures throw. Runtime-verified on a live CloudPage: Perform("start") returns the string "QueryDefinition perform called successfully" (not "OK") when the run is accepted. It queues the query asynchronously and returns immediately — the string only confirms acceptance, not completion. On an invalid / non-existent key it does NOT throw: it returns a failure string of the form "Exception occurred during [Schedule::Start] ErrorID = ". Detect failure by inspecting the returned string, not by string-matching "OK" and not by relying on try/catch.
* @param action - The action to perform. Use `"start"` to execute the query.
* @returns Returns the string "QueryDefinition perform called successfully" when the run is accepted. On failure returns an Exception string (does not throw).
* @example
* Platform.Load("core", "1");
* var qd = QueryDefinition.Init("MY_QUERY_KEY");
* var result = qd.Perform("start");
* Write(Stringify(result));
*/
Perform(action: string): string;
}
declare namespace List {
/**
* Initializes a List instance bound to the specified external key. Required before invoking any other List method on the returned instance.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/list/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the list.
* @returns An initialized List bound to the specified external key.
* @example
* Platform.Load("core", "1");
* var myList = List.Init("myList");
*/
function Init(key: string): ListInstance;
/**
* Creates a new list from the supplied properties and returns an initialized list instance. Note: unlike most static `Add` methods, this returns a `ListInstance`, not `"OK"`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/list/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - JSON object describing the new list (CustomerKey, Name, Description, ...).
* @returns An initialized List bound to the newly-created list.
* @example
* Platform.Load("core", "1.1.5");
* var myNewList = List.Add({ CustomerKey: "libList", Name: "testLib", Description: "desc" });
*/
function Add(properties: object): ListInstance;
/**
* Returns an array of lists matching the specified filter.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/list/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - PascalCase WSProxy-style filter object: `{Property, SimpleOperator, Value}`.
* @returns List of list objects matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var lists = List.Retrieve({ Property: "ListName", SimpleOperator: "equals", Value: "BirthdayList" });
*/
function Retrieve(filter: object): object[];
}
interface ListInstance {
/**
* Removes the previously initialized list.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/list/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Official docs say Remove returns "OK" or throws on failure. Runtime returns the plain string "Error" for a nonexistent key and does not throw.
* @returns Returns "OK" on success. A nonexistent key returns the plain string "Error" (does not throw).
* @example
* Platform.Load("core", "1.1.5");
* var myList = List.Init("myList");
* var status = myList.Remove();
*/
Remove(): string;
readonly Subscribers: ListSubscribersInstance;
}
declare namespace Subscriber {
/**
* Initializes a Subscriber instance bound to the specified subscriber key. Required before invoking any instance method on the returned object.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - Subscriber key.
* @returns An initialized Subscriber bound to the specified key.
* @example
* Platform.Load("core", "1");
* var sub = Subscriber.Init("mySubscriber");
*/
function Init(key: string): SubscriberInstance;
/**
* Creates a new subscriber from the supplied properties.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - JSON object describing the new subscriber (EmailAddress, SubscriberKey, EmailTypePreference, Attributes, Lists, ...).
* @returns Returns the string "OK" on success. Returns the string "Error" when the create is rejected, for example an EmailAddress on a spam-blocked domain (WSProxy reports ErrorCode 12002 "TriggeredSpamFilter").
* @example
* Platform.Load("core", "1.1.5");
* var newSubscriber = {
* EmailAddress: "test.008@example.com",
* SubscriberKey: "20100730001",
* EmailTypePreference: "Text",
* Attributes: { "First Name": "test.008", "Last Name": "test.008" },
* Lists: { Status: "Active", ID: 12345, Action: "Create" }
* };
* var status = Subscriber.Add(newSubscriber);
*/
function Add(properties: object): string;
/**
* Returns an array of subscribers matching the specified filter.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - PascalCase WSProxy-style filter object: `{Property, SimpleOperator, Value}`.
* @returns List of subscribers matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var results = Subscriber.Retrieve({ Property: "SubscriberKey", SimpleOperator: "equals", Value: "MySubscriberKey" });
*/
function Retrieve(filter: object): object[];
}
interface SubscriberInstance {
/**
* Creates a new subscriber, or updates the initialized one matched by EmailAddress / SubscriberKey. Instance-only: there is no static Subscriber.Upsert — calling it throws "Object expected: Upsert".
*
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Attributes must be a plain object keyed by attribute name ({ "First Name": "Jane" }); the array-of-pairs form shown in the official example ([ { Name: ..., Value: ... } ]) also returns "OK" but writes nothing at all — a read-back through Attributes.Retrieve() shows the value unchanged, so the failure is silent. Runtime-proven: .Upsert({ EmailAddress: ... }) on a new key returned typeof "string" value "OK" and the subscriber was read back afterwards. Use a real deliverable EmailAddress; a spam-blocked domain returns "Error".
* @param properties - JSON object describing the subscriber (EmailAddress, SubscriberKey, Attributes, ...).
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var subObj = Subscriber.Init("test@example.com");
* var result = subObj.Upsert({
* EmailAddress: "test@example.com",
* SubscriberKey: "test@example.com",
* Attributes: { "First Name": "Jane" }
* });
*/
Upsert(properties: object): string;
/**
* Retrieves statistical data for the initialized subscriber (sends, opens, clicks). Instance-only: there is no static Subscriber.Statistics — calling it throws "Object expected: Statistics".
*
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns A single object (not an array) with string-valued fields: OpenEmailName, SendEmailName, ClickCount, ClickLinkAlias, SendCount, OpenCount, ClickURL.
* @example
* Platform.Load("core", "1.1.5");
* var subObj = Subscriber.Init("test@example.com");
* var stats = subObj.Statistics();
*/
Statistics(): object;
/**
* Updates the previously initialized subscriber with the supplied attributes.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - Subscriber properties to change.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var subObj = Subscriber.Init("SubKey");
* var status = subObj.Update({ EmailTypePreference: "HTML", Attributes: { "First Name": "Test", "Last Name": "User" } });
*/
Update(properties: object): string;
/**
* Deletes the previously initialized subscriber.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-proven: .Remove() returned typeof "string" value "OK", and a subsequent Subscriber.Retrieve by SubscriberKey returned no rows, confirming the subscriber was deleted. Contrary to the official docs, a failure does not throw: removing a key that does not exist returns the plain string "Error".
* @returns Returns the string "OK" on success. Returns the string "Error" without throwing when the delete is rejected, for example when no subscriber matches the initialized key.
* @example
* Platform.Load("core", "1.1.5");
* var subObj = Subscriber.Init("SubKey");
* var status = subObj.Remove();
*/
Remove(): string;
/**
* Sets the previously initialized subscriber's status to `"Unsubscribed"`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var subObj = Subscriber.Init("SubKey");
* var status = subObj.Unsubscribe();
*/
Unsubscribe(): string;
readonly Attributes: SubscriberAttributesInstance;
readonly Lists: SubscriberListsInstance;
}
/**
* @deprecated
*/
declare namespace Email {
/**
* Initializes an Email instance bound to the specified external key. Required before invoking any other Email method on the returned instance. External keys cannot be set in the UI — set one via SOAP API, or look up the value via `Email.Retrieve()`. Deprecated — operates on classic Email Studio emails; prefer Content Builder assets for new work.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/email/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the email message.
* @returns An initialized Email bound to the specified external key.
* @example
* Platform.Load("core", "1");
* var myEmail = Email.Init("myEmail");
*/
function Init(key: string): EmailInstance;
/**
* Creates a new classic email message from the supplied properties and returns an initialized email instance. Note: unlike most static `Add` methods, this returns an `EmailInstance`, not `"OK"`. Deprecated — operates on classic Email Studio emails; prefer Content Builder assets for new work.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/email/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - JSON object describing the new email (CustomerKey, Name, optional CategoryID, HTMLBody, TextBody, Subject, EmailType, ...).
* @returns An initialized Email bound to the newly-created email message.
* @example
* Platform.Load("core", "1.1.5");
* var newMail = {
* CustomerKey: "test_email_key",
* Name: "Test Email",
* HTMLBody: "This is a test email",
* TextBody: "This is a test email",
* Subject: "Test Email Subject",
* EmailType: "HTML",
* CharacterSet: "US-ASCII"
* };
* var myEmail = Email.Add(newMail);
*/
function Add(properties: object): EmailInstance;
/**
* Returns an array of classic email messages matching the specified filter. Deprecated — operates on classic Email Studio emails; prefer Content Builder assets for new work.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/email/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - PascalCase WSProxy-style filter object: `{Property, SimpleOperator, Value}`.
* @returns List of email messages matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var results = Email.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "myEmail" });
*/
function Retrieve(filter: object): object[];
}
/**
* @deprecated
*/
interface EmailInstance {
/**
* Updates the classic email message with the supplied attributes. Deprecated — operates on classic Email Studio emails; prefer Content Builder assets for new work.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/email/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - Attributes to change on the email message.
* @returns Returns "OK" on success. A nonexistent key returns the plain string "Error" (does not throw).
* @example
* Platform.Load("core", "1.1.5");
* var myEmail = Email.Init("myEmail");
* var status = myEmail.Update({ Name: "Updated Name", Subject: "Updated Email Subject" });
*/
Update(properties: object): string;
/**
* Removes the previously initialized classic email message. Deprecated — operates on classic Email Studio emails; prefer Content Builder assets for new work.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/email/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns Returns "OK" on success. A nonexistent key returns the plain string "Error" (does not throw).
* @example
* Platform.Load("core", "1.1.5");
* var myEmail = Email.Init("myEmail");
* myEmail.Remove();
*/
Remove(): string;
/**
* Runs validation checks on the previously initialized classic email message. Returns a `{Task: {ValidationStatus: string, ValidationMessages: object[]|null}}` object. Initialize with the email CustomerKey string — Init with a numeric ID throws before returning a Task. Deprecated — operates on classic Email Studio emails; prefer Content Builder assets for new work.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/email/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): `Task.ValidationStatus` is a STRING (e.g. "Pass" / "Fail"), not the boolean the official docs describe. `Task.ValidationMessages` is `null` on Pass or an array of `{Location, Message, Description}` objects on Fail — not the single string the docs describe. Initialize with the CustomerKey string; `Email.Init(numericID).Validate()` throws "Error Validating Email".
* @returns Validation result with `Task.ValidationStatus` (string, e.g. "Pass" / "Fail") and `Task.ValidationMessages` (`null` on Pass, or an array of `{Location, Message, Description}` on Fail).
* @example
* Platform.Load("core", "1.1.5");
* var myEmail = Email.Init("myEmail");
* var results = myEmail.Validate();
* Write(results.Task.ValidationStatus);
* Write(results.Task.ValidationMessages);
*/
Validate(): object;
/**
* Runs content checks on the previously initialized classic email message. Returns a `{Task: {CheckPassed: boolean, ResultMessage: string}}` object. Deprecated — operates on classic Email Studio emails; prefer Content Builder assets for new work.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/email/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns Content-check result with `Task.CheckPassed` (boolean) and `Task.ResultMessage` (string).
* @example
* Platform.Load("core", "1.1.5");
* var myEmail = Email.Init("myEmail");
* var results = myEmail.CheckContent();
* Write(results.Task.CheckPassed);
* Write(results.Task.ResultMessage);
*/
CheckContent(): object;
}
/**
* @deprecated
*/
declare namespace Send {
/**
* Initializes a Send instance bound to the specified send ID. Required before invoking any other Send method on the returned instance. Deprecated — Send is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param id - Numeric ID of the send (number or numeric string).
* @returns An initialized Send bound to the specified send ID.
* @example
* Platform.Load("core", "1");
* var s = Send.Init(12345);
*/
function Init(id: string | number): SendInstance;
/**
* Creates a new send to the specified email and list(s). Pass an `options` object to override From name, From address, subject, send time, etc. Deprecated — Send is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param emailKey - CustomerKey of the email message to associate with the send.
* @param listIds - Target list IDs (numeric or numeric-string elements; mixed arrays accepted).
* @param options - Optional send options (FromName, FromAddress, Subject, SendDate, ...).
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var status = Send.Add("test_email", [12345, 12346]);
* var options = { FromName: "JSON Specified Name", FromAddress: "aruiz@example.com", Subject: "JSON Test Mail" };
* var status2 = Send.Add("test_email", [12345, 12346], options);
*/
function Add(emailKey: string, listIds: string[] | number[], options?: object): string;
/**
* Returns an array of sends matching the specified filter. Deprecated — Send is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - PascalCase WSProxy-style filter object — simple or compound with `LeftOperand`/`LogicalOperator`/`RightOperand`.
* @returns List of sends matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var sends = Send.Retrieve({ Property: "ID", SimpleOperator: "equals", Value: 12345 });
*/
function Retrieve(filter: object): object[];
/**
* Returns information about the lists targeted by a send. Filter must restrict results to specific send ID(s). Deprecated — Send is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - WSProxy-style filter restricting results to specific send ID(s).
* @returns List of list objects associated with matching sends; throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var listsSentTo = Send.RetrieveLists({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
*/
function RetrieveLists(filter: object): object[];
}
/**
* @deprecated
*/
interface SendInstance {
/**
* Cancels/removes the previously initialized send: returns "OK" and sets Status to "Canceled". The row remains Retrievable afterward (not a hard delete). Deprecated — Send is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): `Remove()` returns "OK" and sets Status to "Canceled", but the send row remains Retrievable — it is not hard-deleted. A missing ID returns "Error" (does not throw).
* @returns Returns "OK" on success (Status becomes "Canceled"; row stays Retrievable). Returns "Error" when the ID is missing — does not throw.
* @example
* Platform.Load("core", "1.1.5");
* var s = Send.Init(12345);
* s.Remove();
*/
Remove(): string;
/**
* Attempts to cancel the previously initialized send. Deprecated — Send is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): `CancelSend()` returns the literal string "status" on success, not the "OK" the official docs describe. Do not compare its return value against "OK". Failure returns an error string (for example "not found" / "cannot be cancelled") and does not throw.
* @returns Returns the literal string "status" on success (not "OK"). On failure returns an error string — does not throw.
* @example
* Platform.Load("core", "1.1.5");
* var mySend = Send.Init(12345);
* var status = mySend.CancelSend();
*/
CancelSend(): string;
readonly Tracking: SendTrackingInstance;
}
declare namespace Send.Tracking {
/**
* Returns tracking data for sends matching the filter. This is a static call on `Send.Tracking.*` — no `Send.Init()` is required.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - WSProxy-style filter object.
* @returns List of tracking records matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var sendTracking = Send.Tracking.Retrieve({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
*/
function Retrieve(filter: object): object[];
}
/**
* @deprecated
*/
declare namespace Send.Definition {
/**
* Initializes a SendDefinition instance bound to the specified external key. Required before invoking any instance method on the returned object. Deprecated — Send.Definition is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senddefinition/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the send definition.
* @returns An initialized SendDefinition bound to the specified external key.
* @example
* Platform.Load("core", "1.1.5");
* var esd = Send.Definition.Init("myESD");
*/
function Init(key: string): SendDefinitionInstance;
/**
* Creates a new send definition. Deprecated — Send.Definition is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senddefinition/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-proven working. A successful call returns a CLR object, not the string `"OK"` the docs imply: `typeof` is `"clr"` and `String(result)` is `"ExactTarget.Integration.WSDL.EmailSendDefinition"`. The created send definition is immediately retrievable via `Send.Definition.Retrieve`. All four documented arguments are required and `listIds` must be an array of real list IDs — passing a list ID that does not exist makes the call throw the string `"Error adding EmailSendDefinition."` and nothing is created. The thrown value is a plain string (`typeof ex === "string"`), so `ex.message` is undefined; catch it as a string.
* @param esdParams - Object with CustomerKey, Name, EmailSubject for the new send definition.
* @param sendClassificationKey - CustomerKey of the related send classification.
* @param emailKey - CustomerKey of the email message to use.
* @param listIds - Array of list IDs targeted by the send definition (numeric or numeric-string elements; mixed arrays accepted).
* @returns Returns a CLR EmailSendDefinition object on success (`typeof` `"clr"`, stringifies to `"ExactTarget.Integration.WSDL.EmailSendDefinition"`). Throws the string `"Error adding EmailSendDefinition."` on failure.
* @example
* Platform.Load("core", "1");
* var esdParams = { CustomerKey: "example_esd", Name: "Example Send Definition", EmailSubject: "Sent By Example Send Definition" };
* Send.Definition.Add(esdParams, "example_sc_key", "example_email_key", [12345, 12346]);
*/
function Add(esdParams: object, sendClassificationKey: string, emailKey: string, listIds: string[] | number[]): object;
/**
* Creates a new send definition that targets a sendable Data Extension. Deprecated — Send.Definition is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senddefinition/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-proven working, but only with **four** arguments — the documented fifth `publicationListKey` argument breaks the call. `AddWithDE(esdParams, sendClassificationKey, emailKey, sendableDataExtensionKey)` succeeds and the send definition is immediately retrievable via `Send.Definition.Retrieve`. Supplying a fifth argument throws the string `"Error adding EmailSendDefinition."` and creates nothing — this was observed with a publication list name, a numeric list ID, and the Data Extension key repeated. A successful call returns a CLR object, not the string `"OK"` the docs imply: `typeof` is `"clr"` and `String(result)` is `"ExactTarget.Integration.WSDL.EmailSendDefinition"`. The thrown failure value is a plain string (`typeof ex === "string"`), so `ex.message` is undefined.
* @param esdParams - Object with CustomerKey, Name, EmailSubject for the new send definition.
* @param sendClassificationKey - CustomerKey of the related send classification.
* @param emailKey - CustomerKey of the email message to use.
* @param sendableDataExtensionKey - CustomerKey of the sendable Data Extension.
* @param publicationListKey - CustomerKey of the publication list to associate. Documented as required, but supplying it makes the call fail at runtime — omit it.
* @returns Returns a CLR EmailSendDefinition object on success (`typeof` `"clr"`, stringifies to `"ExactTarget.Integration.WSDL.EmailSendDefinition"`). Throws the string `"Error adding EmailSendDefinition."` on failure.
* @example
* Platform.Load("core", "1.1.5");
* var esdParams = { CustomerKey: "ssjs_de_esd_1c", Name: "SSJS DE Test ESD3", EmailSubject: "Third send By Test DE Send Definition" };
* // omit the documented publicationListKey - passing it makes the call throw
* var esd = Send.Definition.AddWithDE(esdParams, "scKey", "test_email", "deKey");
*/
function AddWithDE(esdParams: object, sendClassificationKey: string, emailKey: string, sendableDataExtensionKey: string, publicationListKey?: string): object;
/**
* Creates a new send definition that targets the audience defined by a filter definition. Deprecated — Send.Definition is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senddefinition/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime behaviour differs sharply from the docs: the call **always throws** the string `"Error adding EmailSendDefinition."`, yet the send definition **is created anyway** and is immediately retrievable via `Send.Definition.Retrieve` on the same page. This was reproduced with a valid filter definition key plus a real list ID, with the list ID passed as a number and as a single-element array, with a publication list name, with a Data Extension key, and with the fifth argument omitted — every shape threw, and the shapes using a valid list ID still created the object. Because the throw is indistinguishable from a genuine failure, the only reliable success check is to call `Send.Definition.Retrieve` for the new key after catching. No invocation shape was found that returns normally.
* @param esdParams - Object with CustomerKey, Name, EmailSubject for the new send definition.
* @param sendClassificationKey - CustomerKey of the related send classification.
* @param emailKey - CustomerKey of the email message to use.
* @param filterDefinitionKey - CustomerKey of the filter definition.
* @param listId - ID of the list targeted by the filter.
* @returns Never returns normally — always throws the string `"Error adding EmailSendDefinition."`, even when the send definition is created successfully. Verify by retrieving the new key afterwards.
* @example
* Platform.Load("core", "1.1.5");
* var esdParams = { CustomerKey: "filterDef_esd", Name: "Example Filtered Send Definition", EmailSubject: "Sent By Filtered Send Definition" };
* try {
* Send.Definition.AddWithFilterDefinition(esdParams, "scKey", "test_email", "fdKey", 144);
* } catch (ex) {
* // always throws "Error adding EmailSendDefinition." - check whether it was created anyway
* }
* var created = Send.Definition.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "filterDef_esd" }).length > 0;
*/
function AddWithFilterDefinition(esdParams: object, sendClassificationKey: string, emailKey: string, filterDefinitionKey: string, listId?: string | number): any;
/**
* Returns an array of send definitions, optionally filtered. When no filter is supplied, all send definitions are returned. Deprecated — Send.Definition is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senddefinition/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Optional WSProxy-style filter object: `{Property, SimpleOperator, Value}`.
* @returns List of send definitions matching the filter (or all when no filter is supplied). Returns an empty array when nothing matches — it does not throw and does not return null.
* @example
* Platform.Load("core", "1.1.5");
* var esd = Send.Definition.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "ssjs_test_esd" });
*/
function Retrieve(filter?: object): object[];
}
/**
* @deprecated
*/
interface SendDefinitionInstance {
/**
* Updates the previously initialized send definition. Deprecated — Send.Definition is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senddefinition/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-proven working for scalar properties only. Updating simple values such as `Description` or `TestEmailAddr` returns the string `"OK"` and the change persists (confirmed by re-reading the record). Updating nested/complex properties fails: `Update({ Email: { ID: } })` and `Update({ SendDefinitionList: [...] })` both throw `"Error Updating ESD."`. The equivalent WSProxy `updateItem` calls for those same nested properties return `Status: "OK"` with StatusMessage `"EmailSendDefinition updated"`, so the limitation is specific to this Core method rather than to the operation itself.
* @param properties - Properties to update. Only scalar properties work; nested objects such as `Email` or `SendDefinitionList` throw.
* @returns Returns "OK" when scalar properties are updated. Throws `"Error Updating ESD."` when the payload contains nested properties such as `Email` or `SendDefinitionList`.
* @example
* Platform.Load("core", "1.1.5");
* var sendDef = Send.Definition.Init("MY_SEND_DEF_KEY");
* var result = sendDef.Update({ Name: "Updated Send Definition Name" });
*/
Update(properties: object): string;
/**
* Deletes the previously initialized send definition. Deprecated — Send.Definition is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senddefinition/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns Returns "OK" on success; the record is no longer returned by `Send.Definition.Retrieve` afterwards.
* @example
* Platform.Load("core", "1.1.5");
* var esd = Send.Definition.Init("myESD");
* var status = esd.Remove();
*/
Remove(): string;
/**
* Sends email messages to the lists associated with the previously initialized send definition. Deprecated — Send.Definition is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senddefinition/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-proven to reach the send pipeline: the call returns a multi-line **error string** rather than throwing, so a caller that only wraps it in `try/catch` will treat a rejected send as success. Observed returns include `"An EmailSendDefinition must have an audience to be sent."` when no audience is attached, and `"The following email validation errors need addressed before the email can be sent."` followed by the offending tokens once an audience is present. Always compare the returned string to `"OK"` instead of relying on `try/catch`. A WSProxy `performItem("EmailSendDefinition", …, "start")` control returned the identical validation text, confirming the Core method dispatches the same operation. A fully clean `"OK"` return was not observed here because the test email itself never passed content validation.
* @returns Returns "OK" when the send is accepted. Returns a descriptive error string (it does not throw) when the send definition has no audience or the email fails content validation.
* @example
* Platform.Load("core", "1.1.5");
* var esd = Send.Definition.Init("myESD");
* var status = esd.Send();
* if (status !== "OK") {
* // Send() returns the error text instead of throwing
* Write("send rejected: " + status);
* }
*/
Send(): string;
/**
* Sends a test version of the previously initialized send definition. Undocumented and non-functional in testing. Deprecated — Send.Definition is a legacy Classic Content / Classic Email Studio feature superseded by Content Builder.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/senddefinition/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Undocumented instance method that exists at runtime on the object returned by `Send.Definition.Init(key)`. No working invocation was found. Calling it with no arguments returns `"An EmailSendDefinition cannot be used in a test send to a list or group without a test email address."` even after a test address was stored on the record — set both through this object's own `Update({ TestEmailAddr: … })` (which returned `"OK"`) and through a WSProxy `updateItem("EmailSendDefinition", …)` control (which returned `Status: "OK"`, StatusMessage `"EmailSendDefinition updated"`). Passing an address directly as an argument bypasses that message but then returns the same email content validation error string as `Send()`. Like `Send()`, it returns error text rather than throwing.
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @param emailAddress - Address to receive the test send.
* @returns Expected to return "OK". In testing it only ever returned error text describing a missing test email address or failed email content validation.
* @example
* Platform.Load("core", "1.1.5");
* var esd = Send.Definition.Init("myESD");
* var status = esd.TestSend("test@example.com");
*/
TestSend(emailAddress?: string): string;
}
declare namespace TriggeredSend {
/**
* Initializes a TriggeredSend instance bound to the specified external key. Required before invoking any instance method on the returned object. Note: TriggeredSend methods cannot be used in the context of an email message or email preview.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External key of the triggered send definition.
* @returns An initialized TriggeredSend bound to the specified external key.
* @example
* Platform.Load("core", "1");
* var triggeredSend = TriggeredSend.Init("support");
*/
function Init(key: string): TriggeredSendInstance;
/**
* Creates a new triggered send definition from the supplied properties and returns an initialized TriggeredSend instance. Note: unlike most static `Add` methods, this returns a `TriggeredSendInstance`, not `"OK"`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Exists and resolves (`typeof TriggeredSend.Add === "function"`) but no working invocation was found. Every invocation of `TriggeredSend.Add` throws the string `Error adding TSD.`; `TriggeredSend.LastMessage` is then always `An error occurred when attempting to evaluate a SetObjectProperty function call. See inner exception for details.` for every payload shape (including flat-only payloads, where `LastErrorCode` is left `undefined`). Proven with a fully valid, publishable definition on the QA BU (Email.ID 769268, List.ID 72164, SendClassification "Default Transactional" / ObjectID 2147aac4-35f1-ec11-b846-48df37d1dcc7, CategoryID 734919). Payload shapes swept without a single success: nested SOAP shape (`Email: {ID}`, `List: {ID}`, `SendClassification: {CustomerKey|ObjectID}`), the documented flat shape (`EmailID`, `ListID`, `SendClassificationID`), dotted keys (`"Email.ID"`), flat-scalar-only payloads, typed Core Library objects (`Email.Init()`, `List.Init()`, `SendClassification.Init()`), and the CLR object returned by `TriggeredSend.Retrieve` with its `CustomerKey` mutated. String and two-argument forms also throw the string `Error adding TSD.` (not the `Invalid cast from 'Char' to 'Double'.` cast seen on `Update("x")`). Decisive control: in the same request, `Script.Util.WSProxy().createItem("TriggeredSendDefinition", payload)` with the identical payload returns `Status: "OK"`, `ErrorCode: 0`, `StatusMessage: "TriggeredSendDefinition created"`, and the resulting definition then publishes, starts, sends, pauses and updates normally. Use WSProxy `createItem` instead; no working invocation of `TriggeredSend.Add` was found.
* @deprecated
* @remarks ⚠️ Exists at runtime but has no known working invocation (every tested call fails).
* @param properties - JSON object describing the new triggered send definition (Name, CustomerKey, FromName, FromAddress, EmailID, SendClassificationID, ...).
* @returns An initialized TriggeredSend bound to the newly-created triggered send definition.
* @example
* Platform.Load("core", "1.1.5");
* var newTSD = {
* Name: "Test TSD",
* CustomerKey: "ssjs_tsd_key",
* FromName: "Test From Name",
* FromAddress: "me@example.com",
* EmailID: 12345,
* SendClassificationID: 54321
* };
* var tsd = TriggeredSend.Add(newTSD);
*/
function Add(properties: object): TriggeredSendInstance;
/**
* Returns an array of triggered send definitions matching the specified filter.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - PascalCase WSProxy-style filter object: `{Property, SimpleOperator, Value}`.
* @returns List of triggered send definitions matching the filter.
* @example
* Platform.Load("core", "1.1.5");
* var results = TriggeredSend.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "ssjs_tsd_key" });
*/
function Retrieve(filter: object): object[];
}
interface TriggeredSendInstance {
/**
* Updates the previously initialized triggered send definition.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Confirmed at runtime: returns the string `"OK"` and `LastMessage` `TriggeredSendDefinition updated` when the definition is NOT Active. Undocumented state requirement: calling it on an Active definition returns the string `"Error"` with `LastMessage` `An active TriggeredSendDefinition can not be updated or have it's content refreshed` and `LastErrorCode` 17003 — call `Pause()` first. Also undocumented: the `properties` argument is effectively optional — `Update()` with no arguments returns `"OK"`. Passing a non-object (e.g. a string) throws `Error Updating TSD.` with `LastMessage` `Invalid cast from 'Char' to 'Double'.".
* @param properties - Attributes to change on the triggered send definition. Optional at runtime — omitting it returns "OK" without changes.
* @returns Returns "OK" on success, or "Error" when the definition is Active (LastErrorCode 17003).
* @example
* Platform.Load("core", "1.1.5");
* var tsd = TriggeredSend.Init("triggeredSend");
* var status = tsd.Update({ Name: "Updated TSD Name" });
*/
Update(properties?: object): string;
/**
* Starts (reactivates) a paused triggered send definition.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Confirmed at runtime: returns the string `"OK"` with `LastMessage` `TriggeredSendDefinition updated`, and the definition moves to `TriggeredSendStatus: "Active"` (verified by a follow-up WSProxy retrieve). Undocumented: extra arguments are ignored rather than rejected — `Start("x")` also returns `"OK"`.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var ts = TriggeredSend.Init("MY_TRIGGERED_SEND_KEY");
* var result = ts.Start();
*/
Start(): string;
/**
* Pauses an active triggered send definition.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Confirmed at runtime: returns the string `"OK"` with `LastMessage` `TriggeredSendDefinition updated`, and the definition moves to `TriggeredSendStatus: "Inactive"` (verified by a follow-up WSProxy retrieve) — note the resulting status is `Inactive`, not `Paused`. Undocumented: extra arguments are ignored rather than rejected — `Pause("x")` also returns `"OK"`.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var ts = TriggeredSend.Init("MY_TRIGGERED_SEND_KEY");
* var status = ts.Pause();
*/
Pause(): string;
/**
* Publishes a triggered send definition, making it active and ready to accept sends. Use this to move a definition from Draft / Inactive to Active.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Confirmed at runtime: returns the string `"OK"` with `LastMessage` `TriggeredSendDefinition updated`. Undocumented behaviour: `Publish()` does NOT by itself move the definition to Active — a follow-up WSProxy retrieve showed the status still `New` after `Publish()` returned `"OK"`; the subsequent `Start()` is what set `TriggeredSendStatus: "Active"`. Extra arguments are ignored rather than rejected — `Publish("x")` also returns `"OK"`.
* @returns Returns "OK" on success or throws on failure.
* @example
* Platform.Load("core", "1.1.5");
* var ts = TriggeredSend.Init("MY_TRIGGERED_SEND_KEY");
* var result = ts.Publish();
*/
Publish(): string;
/**
* Sends an email using the previously initialized triggered send definition. On failure, inspect `.LastMessage` for error details.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Confirmed at runtime with real sends: returns the string `"OK"` with `LastMessage` `Created TriggeredSend`. Several undocumented details. (1) A third argument is accepted — `Send(emailAddress, sendTimeAttributes, subscriberKey)` returns `"OK"`; surplus arguments beyond that are ignored (a 4-argument call also returns `"OK"`). (2) The definition does not have to be Active: a `Send` against an `Inactive` definition still returned `"OK"` / `Created TriggeredSend`. (3) An invalid address does not throw — it returns the string `"Error"` with `LastMessage` `Unable to queue Triggered Send request. There are no valid subscribers.`. (4) Calling `Send()` with no arguments throws the usage string `Usage: Send(EmailAddress [, sendTimeAttributes])`. (5) `LastRequestID` was `0` after a successful send.
* @param emailAddress - Email address to send to. SubscriberKey is **not** supported.
* @param sendTimeAttributes - Optional object with dynamic attributes to include in the send.
* @param subscriberKey - Undocumented third argument accepted at runtime — subscriber key to associate with the send.
* @returns Returns "OK" on success or "Error" when the request cannot be queued; throws on a hard failure.
* @example
* Platform.Load("core", "1.1.5");
* var ts = TriggeredSend.Init("triggeredSend");
* var status = ts.Send("aruiz@example.com", { FirstName: "Angel", CouponCode: "AA1AF" });
* if (status != "OK") { var message = ts.LastMessage; }
*/
Send(emailAddress: string, sendTimeAttributes?: object, subscriberKey?: string): string;
readonly Tracking: TriggeredSendTrackingInstance;
}
declare namespace DataExtension {
/**
* Initializes a DataExtension instance bound to the specified data extension by its External Key (`CustomerKey`). Binding is lazy — Init never throws for a missing DE; the error surfaces on the first Rows/Fields operation. Passing the display Name when it differs from CustomerKey does not bind Fields or Rows.Retrieve (empty results / `"Error"`); use the External Key. Required before invoking any `Fields` or `Rows` sub-namespace method on the returned instance. A shared data extension owned by the parent Business Unit resolves from a child BU only with the `ENT.` prefix; writes and `Platform.Function` lookups then work. The prefix itself, however, silences the two read methods: on an `ENT.`-prefixed key `Fields.Retrieve()` and `Rows.Retrieve()` return an empty array on every Business Unit, including the one that owns the data extension, where the unprefixed key returns the real fields and rows.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param key - External Key (`CustomerKey`) of the data extension.
* @returns An initialized DataExtension (exposing `Rows`, `Fields`, `Update`, `Remove`) bound to the specified data extension.
* @example
* Platform.Load("core", "1.1.5");
* var birthdayDE = DataExtension.Init("birthdayDE");
*/
function Init(key: string): DataExtensionInstance;
/**
* Creates a new data extension from the supplied properties and returns an initialized DataExtension instance (the same shape as `DataExtension.Init`, exposing `Rows`, `Fields`, `Update`, `Remove`). Note: unlike most static `Add` methods, this returns a `DataExtensionInstance`, not `"OK"`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param properties - JSON object describing the new data extension (CustomerKey, Name, Fields[], optional SendableInfo).
* @returns An initialized DataExtension bound to the newly-created data extension.
* @example
* Platform.Load("core", "1.1.5");
* var deObj = {
* CustomerKey: "SendableDE",
* Name: "Sendable Data Extension",
* Fields: [
* { Name: "SubKey", FieldType: "Text", IsPrimaryKey: true, MaxLength: 50, IsRequired: true },
* { Name: "SecondField", FieldType: "Text", MaxLength: 50 }
* ],
* SendableInfo: {
* Field: { Name: "SubKey", FieldType: "Text" },
* RelatesOn: "Subscriber Key"
* }
* };
* var de = DataExtension.Add(deObj);
*/
function Add(properties: object): DataExtensionInstance;
/**
* Returns an array of data extensions matching the specified filter. Pass `queryAllAccounts: true` to search all accounts accessible to the authenticated user. The `filter` is documented as required but is optional at runtime — omitting it returns all data extensions.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/dataextension/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official Salesforce docs document `filter` as required, but at runtime it is optional: calling `DataExtension.Retrieve()` with no arguments does not throw and returns the full list of data extensions. A filter that matches nothing returns a real empty array (`[object Array]`, `length: 0`).
* @param filter - PascalCase WSProxy-style filter object: `{Property, SimpleOperator, Value}`. Documented as required, but optional at runtime (omitting it returns all data extensions).
* @param queryAllAccounts - When `true`, search across all accounts accessible to the authenticated user. Defaults to `false`. Also accepts number `1` / `0` with the same meaning.
* @returns List of data extensions matching the filter. Limit data extension external keys to 36 characters for downstream compatibility.
* @example
* Platform.Load("core", "1.1.5");
* var results = DataExtension.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "myDEKey" });
*/
function Retrieve(filter?: object, queryAllAccounts?: boolean | number): object[];
}
declare namespace DateTime {
/**
* Converts a date-time value from Marketing Cloud system time (CST) to the local time of the account or user. Returns a Date object.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/datetime/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the `DateTime.SystemDateToLocalDate` bare-name form behaves IDENTICALLY to `Platform.Function.SystemDateToLocalDate` (same value, same type). The official docs type the return as a string, but the runtime returns a genuine Date object: typeof "object", `Object.prototype.toString` reports "[object Date]", `.constructor === Date`, and `getFullYear()`/`getHours()`/`getTime()` all work (identical to `new Date()`). The only anomaly is that `instanceof Date` returns false, due to the engine-wide `instanceof`-on-builtins bug — detect via `.constructor === Date`, not `instanceof`. It coerces to an ISO-like string when written or stringified. SCOPE RULE: bare-name Core globals exist ONLY after Platform.Load("core", ...) has run — call the load first.
* @param dateString - Date-time value in system time (CST); string or Date
* @example
* Platform.Load("core", "1.1.5");
* var localTime = DateTime.SystemDateToLocalDate(Platform.Function.Now());
* Write(localTime);
*/
function SystemDateToLocalDate(dateString: string | Date): Date;
/**
* Converts a date-time value from the local time of the account or user to Marketing Cloud system time (CST). Returns a Date object.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/datetime/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): the `DateTime.LocalDateToSystemDate` bare-name form behaves IDENTICALLY to `Platform.Function.LocalDateToSystemDate` (same value, same type). The official docs type the return as a string, but the runtime returns a genuine Date object: typeof "object", `Object.prototype.toString` reports "[object Date]", `.constructor === Date`, and `getFullYear()`/`getHours()`/`getTime()` all work (identical to `new Date()`). The only anomaly is that `instanceof Date` returns false, due to the engine-wide `instanceof`-on-builtins bug — detect via `.constructor === Date`, not `instanceof`. It coerces to an ISO-like string when written or stringified. SCOPE RULE: bare-name Core globals exist ONLY after Platform.Load("core", ...) has run — call the load first.
* @param dateString - Date-time value in local account/user time; string or Date
* @example
* Platform.Load("core", "1.1.5");
* var systemTime = DateTime.LocalDateToSystemDate("8/5/2025 12:34 PM");
* Write(systemTime);
*/
function LocalDateToSystemDate(dateString: string | Date): Date;
}
declare namespace DateTime.TimeZone {
/**
* Retrieves an array of time zones matching the specified filter criteria. If no filter is supplied the function returns all available time zones.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/datetime/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Filter criteria object with properties: `Property`, `SimpleOperator`, `Value`. Omit it to retrieve every time zone.
* @example
* Platform.Load("core", "1.1.5");
* var timezones = DateTime.TimeZone.Retrieve({ Property: "ID", SimpleOperator: "equals", Value: 1 });
* Write(Stringify(timezones));
*/
function Retrieve(filter?: object): object[];
}
// ── Standalone Core Library globals ──────────────────────────────────────────
declare namespace Attribute {
/**
* Returns the value of the specified subscriber attribute or sendable data extension field for the current recipient. Preferred over Platform.Recipient.GetAttributeValue() — both methods are equivalent. Available in CloudPages after Platform.Load("Core", ...); returns an empty string when no recipient/attribute context is present.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/attribute/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified on a published CloudPage: after Platform.Load("Core", ...) the Attribute object exists and Attribute.GetValue(name) executes and returns a string — it is NOT unavailable in CloudPages. When no subscriber/attribute is in context (e.g. a plain CloudPage GET) it returns an empty string rather than throwing. In email/triggered-send/personalized contexts it returns the actual attribute value.
* @param name - Name of the subscriber attribute or sendable DE field to retrieve.
* @example
* Platform.Load("Core", "1.1.1");
* var email = Attribute.GetValue("EmailAddress");
* Write(email);
*/
function GetValue(name: string): string;
}
declare namespace ErrorUtil {
/**
* Inspects a WSProxy result object and throws when its `Status` property indicates an error. WSProxy methods never raise exceptions on SOAP-level errors — instead they return a result object whose `Status` field signals the outcome. DEPRECATED: only available under `Platform.Load("Core", "1")`; unavailable in newer Core versions. Prefer checking `result.Status` and throwing `new Error(...)` yourself.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/errorutil/)
*
* @deprecated
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): `ErrorUtil` (and its only member `ThrowWSProxyError`) is provided ONLY by `Platform.Load("Core", "1")`. Under any newer Core version ("1.1.1", "1.1.5", …) `ErrorUtil` is `undefined`, so this call throws a TypeError ("Object expected: ThrowWSProxyError") — it is effectively deprecated in Core > 1. A preceding `new Script.Util.WSProxy()` is NOT required to make ErrorUtil available (disproven at runtime). When it does throw on a real WSProxy error result, it throws a plain STRING (e.g. "Error: Data extension does not exist: …") — not an Error object — so the caught value has no `.message`/`.description` (both `undefined`); read the string itself via `String(ex)`. On the success path it does not return `undefined`: it returns the result `Status` string ("OK"). Recommended replacement (works on any Core version): inspect `result.Status` and `throw new Error(...)` (or handle inline) instead of calling ErrorUtil.ThrowWSProxyError.
* @param result - Result object returned by any WSProxy method. Minimum shape: `{ Status: string, RequestID: string, Results: object[] }`. Retrieve and perform variants may include additional fields.
* @returns The `Status` string of the passed result (e.g. `"OK"`) when it indicates success. Throws instead of returning when `Status` indicates an error.
* @example
* // Only works under Platform.Load("Core", "1"); prefer the result.Status check below.
* Platform.Load("Core", "1");
* var api = new Script.Util.WSProxy();
* var customerKey = "0b744ffa-bab5-458d-9e7d-fb05a7873380";
* try {
* var result = api.retrieve(
* "DataExtensionObject[" + customerKey + "]",
* ["FirstName", "LastName", "EmailAddress"]
* );
* // Preferred, version-independent replacement:
* if (String(result.Status).indexOf("Error") === 0) {
* throw new Error(String(result.Status));
* }
* // process successful results
* } catch (ex) {
* Write(String(ex));
* }
*/
function ThrowWSProxyError(result: object): string;
}
// ── Event namespaces ─────────────────────────────────────────────────────────
declare namespace BounceEvent {
/**
* Retrieves bounce event data for message sends matching the specified filter.
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Filter criteria object with properties: `Property`, `SimpleOperator`, `Value`.
* @example
* Platform.Load("core", "1.1.5");
* var bounces = BounceEvent.Retrieve({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
* Write(Stringify(bounces));
*/
function Retrieve(filter: object): object[];
}
declare namespace ClickEvent {
/**
* Retrieves click tracking event data for message sends matching the specified filter.
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Filter criteria object with properties: `Property`, `SimpleOperator`, `Value`.
* @example
* Platform.Load("core", "1.1.5");
* var clicks = ClickEvent.Retrieve({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
* Write(Stringify(clicks));
*/
function Retrieve(filter: object): object[];
}
declare namespace ForwardedEmailEvent {
/**
* Retrieves forwarded email event data for message sends matching the specified filter.
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Filter criteria object with properties: `Property`, `SimpleOperator`, `Value`.
* @example
* Platform.Load("core", "1.1.5");
* var forwards = ForwardedEmailEvent.Retrieve({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
* Write(Stringify(forwards));
*/
function Retrieve(filter: object): object[];
}
declare namespace ForwardedEmailOptInEvent {
/**
* Retrieves forwarded email opt-in event data for message sends matching the specified filter.
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Filter criteria object with properties: `Property`, `SimpleOperator`, `Value`.
* @example
* Platform.Load("core", "1.1.5");
* var optIns = ForwardedEmailOptInEvent.Retrieve({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
* Write(Stringify(optIns));
*/
function Retrieve(filter: object): object[];
}
declare namespace NotSentEvent {
/**
* Retrieves not-sent event data for message sends matching the specified filter.
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Filter criteria object with properties: `Property`, `SimpleOperator`, `Value`.
* @example
* Platform.Load("core", "1.1.5");
* var notSent = NotSentEvent.Retrieve({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
* Write(Stringify(notSent));
*/
function Retrieve(filter: object): object[];
}
declare namespace OpenEvent {
/**
* Retrieves open tracking event data for message sends matching the specified filter.
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Filter criteria object with properties: `Property`, `SimpleOperator`, `Value`.
* @example
* Platform.Load("core", "1.1.5");
* var opens = OpenEvent.Retrieve({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
* Write(Stringify(opens));
*/
function Retrieve(filter: object): object[];
}
declare namespace SentEvent {
/**
* Retrieves sent event data for message sends matching the specified filter.
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Filter criteria object with properties: `Property`, `SimpleOperator`, `Value`.
* @example
* Platform.Load("core", "1.1.5");
* var sent = SentEvent.Retrieve({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
* Write(Stringify(sent));
*/
function Retrieve(filter: object): object[];
}
declare namespace SurveyEvent {
/**
* Retrieves survey response event data for message sends matching the specified filter.
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Filter criteria object with properties: `Property`, `SimpleOperator`, `Value`.
* @example
* Platform.Load("core", "1.1.5");
* var surveys = SurveyEvent.Retrieve({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
* Write(Stringify(surveys));
*/
function Retrieve(filter: object): object[];
}
declare namespace UnsubEvent {
/**
* Retrieves unsubscribe event data for message sends matching the specified filter.
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param filter - Filter criteria object with properties: `Property`, `SimpleOperator`, `Value`.
* @example
* Platform.Load("core", "1.1.5");
* var unsubs = UnsubEvent.Retrieve({ Property: "SendID", SimpleOperator: "equals", Value: 12345 });
* Write(Stringify(unsubs));
*/
function Retrieve(filter: object): object[];
}
// ── HTTP / HTTPHeader ────────────────────────────────────────────────────────
declare namespace HTTP {
/**
* Performs an HTTP GET request and returns the response body. When supplying `headerNames` and `headerValues`, both arrays must have equal length and parallel ordering.
*
* [ssjs.guide reference](https://ssjs.guide/http/get/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param url - URL to request.
* @param headerNames - Array of header names (co-required with headerValues).
* @param headerValues - Array of header values, one per entry in headerNames (co-required).
* @example
* Platform.Load("core", "1.1.5");
* var body = HTTP.Get("https://api.example.com/data");
* var obj = Platform.Function.ParseJSON(String(body));
*/
function Get(url: string, headerNames?: any[], headerValues?: any[]): { Status: number, Content: string };
/**
* Performs an HTTP POST request with a content type and payload. Returns an object whose `StatusCode` is a number and whose `Response` is an array-like whose first element (`Response[0]`) is the response body string. Custom headers are optional; when supplied, `headerNames` and `headerValues` must be paired (equal length) — passing only one of the two throws a mismatch error.
*
* [ssjs.guide reference](https://ssjs.guide/http/post/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param url - URL to post to.
* @param contentType - MIME type of the request body.
* @param payload - Request body content.
* @param headerNames - Array of header names to include in the request (co-required with headerValues).
* @param headerValues - Array of header values, one per entry in headerNames (co-required).
* @example
* Platform.Load("core", "1.1.5");
* var payload = Stringify({ email: "jane@example.com" });
* var response = HTTP.Post("https://api.example.com/items", "application/json", payload);
* if (response.StatusCode == 200) { var body = response.Response[0]; }
*/
function Post(url: string, contentType: string, payload: string, headerNames?: string[], headerValues?: any[]): { StatusCode: number, Response: string[] };
}
declare namespace HTTPHeader {
/**
* Retrieves the value of the specified INBOUND HTTP request header (e.g. Host, User-Agent). Returns `null` for headers that are not present on the request.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/httpheader/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): reads INBOUND request headers (e.g. `Host`, `User-Agent`) and returns their string value. It does NOT read back a header you set earlier with `HTTPHeader.SetValue(...)` — GetValue for a just-set custom header returns `null`. Treat GetValue and SetValue as operating on separate (inbound vs outbound) header collections.
* @param name - Name of the HTTP header to read
* @example
* Platform.Load("core", "1");
* var host = HTTPHeader.GetValue("Host");
* Write(host);
*/
function GetValue(name: string): string | null;
/**
* Sets the value of the specified OUTBOUND HTTP header. The content-length header cannot be changed; host can be set despite official docs. Note: values set here are not readable via `HTTPHeader.GetValue`, which reads inbound headers.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/httpheader/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): `content-length` cannot be changed (response keeps the real body length). Official docs also claim `host` is protected, but `SetValue("Host", …)` emits an outbound `Host` header. Boolean `value` is accepted but stringified with CLR capitalization (`True`/`False`).
* @param name - Name of the header to set
* @param value - Value to assign to the header
* @example
* Platform.Load("core", "1");
* HTTPHeader.SetValue("From", "aruiz@example.com");
*/
function SetValue(name: string, value: string | number | boolean): void;
/**
* Removes the specified entry from the HTTP header. Returns `undefined`.
*
* [ssjs.guide reference](https://ssjs.guide/core-library/httpheader/)
*
* @remarks Requires `Platform.Load("Core", "1")` before use.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified (CloudPage): returns `undefined` (typeof "undefined"), NOT the `"OK"` string implied by some docs. Do not rely on the return value; call it for its side effect only.
* @param headerName - Name of the header to remove
* @example
* Platform.Load("core", "1");
* HTTPHeader.Remove("X-Custom-Header"); // no useful return value
*/
function Remove(headerName: string): void;
}
// ── Script.Util ──────────────────────────────────────────────────────────────
declare namespace Script {
namespace Util {
/**
* Creates a WSProxy instance for making SOAP API calls against the Marketing Cloud web service. No Platform.Load is required.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns An authenticated WSProxy object bound to the current execution context.
* @example
* var api = new Script.Util.WSProxy();
* var result = api.retrieve("DataExtension", ["Name", "CustomerKey"]);
* if (result.Status === "OK") {
* Write(Stringify(result.Results));
* }
*/
class WSProxy {
/**
* Creates a WSProxy instance for making SOAP API calls against the Marketing Cloud web service. No Platform.Load is required.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @returns An authenticated WSProxy object bound to the current execution context.
* @example
* var api = new Script.Util.WSProxy();
* var result = api.retrieve("DataExtension", ["Name", "CustomerKey"]);
* if (result.Status === "OK") {
* Write(Stringify(result.Results));
* }
*/
constructor();
/**
* Creates a new Marketing Cloud object via the SOAP API. Collection properties must be flat arrays: a DataExtension takes Fields: [...] and a DataExtensionObject takes Properties: [{ Name, Value }]. The nested SOAP wrappers Fields: { Field: [...] } and Properties: { Property: [...] } throw "Error executing create call.", and createItem does not accept the bracketed DataExtensionObject[key] object type — name the data extension through CustomerKey instead. It never upserts: an existing primary key returns Status "Error" and leaves the stored row unchanged.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/createitem/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param objectType - SOAP API object type name
* @param properties - Object properties to set
* @param createOptions - Optional SOAP CreateOptions object (e.g. RequestType, QueuePriority).
* @returns Object with Status ("OK" or "Error"), RequestID, and a Results array holding one per-item result with StatusCode, StatusMessage and Object.
* @example
* var api = new Script.Util.WSProxy();
* var result = api.createItem("DataExtensionObject", {
* CustomerKey: "MyDE_Key",
* Properties: [{ Name: "Email", Value: "jane@example.com" }]
* });
* if (result.Status === "OK") { Write("Created"); }
*/
createItem(objectType: string, properties: object, createOptions?: object): WSProxyResult;
/**
* Updates a single existing Marketing Cloud object via the SOAP API.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/updateitem/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param objectType - SOAP API object type name
* @param properties - Object properties to update
* @param updateOptions - Optional SOAP UpdateOptions object (e.g. { SaveOptions: [...] })
* @returns Object with Status, RequestID, and a single-entry Results array. The one Results entry carries StatusCode, StatusMessage, OrdinalID, ErrorCode, and an Object wrapper.
* @example
* var api = new Script.Util.WSProxy();
* var result = api.updateItem("DataExtensionObject", {
* CustomerKey: "MyDE",
* Keys: [{ Name: "Email", Value: "a@example.com" }],
* Properties: [{ Name: "Status", Value: "inactive" }]
* });
* if (result.Status === "OK") { Write("Updated"); }
*/
updateItem(objectType: string, properties: object, updateOptions?: object): WSProxyResult;
/**
* Deletes a Marketing Cloud object via the SOAP API.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/deleteitem/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param objectType - SOAP API object type name
* @param properties - Object properties identifying the item to delete. For a DataExtensionObject row use a CustomerKey property plus a FLAT Keys array of { Name, Value } pairs — the nested Keys: { Key: [...] } form and the bracketed objectType "DataExtensionObject[key]" both throw.
* @param deleteOptions - Optional SOAP DeleteOptions object (e.g. RequestType, QueuePriority).
* @returns Object with Status, RequestID, and a Results array of per-item results (StatusCode, StatusMessage, ErrorCode). The top-level object has no StatusMessage.
* @example
* var api = new Script.Util.WSProxy();
* var result = api.deleteItem("DataExtensionObject", {
* CustomerKey: "MyDE",
* Keys: [{ Name: "Email", Value: "jane@example.com" }]
* });
* if (result.Status === "OK") { Write("Deleted"); }
*/
deleteItem(objectType: string, properties: object, deleteOptions?: object): WSProxyResult;
/**
* Retrieves Marketing Cloud objects matching an optional filter via the SOAP API. The third parameter is a simple or complex filter; the fourth sets RetrieveOptions; the fifth sets additional request properties such as QueryAllAccounts.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/retrieve/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param objectType - SOAP API object type name
* @param columns - Array of property names to retrieve
* @param filter - Simple or complex filter object
* @param retrieveOptions - Properties to set on the SOAP RetrieveOptions object. Set BatchSize (1..2500) here to force paged results; a value above 2500 is ignored and the default page size applies.
* @param requestProps - Additional request properties, e.g. QueryAllAccounts (boolean) and ContinueRequest (a RequestID string). Setting ContinueRequest to the RequestID from a prior paged retrieve fetches the next page — a retrieve-based alternative to getNextBatch.
* @returns Object with Status, HasMoreRows, RequestID, and Results array. When a result set is paged, Status is "MoreDataAvailable" and HasMoreRows is true; the final page returns Status "OK" and HasMoreRows false.
* @example
* var api = new Script.Util.WSProxy();
* var cols = ["Name", "CustomerKey", "Status"];
* var filter = {
* Property: "Status",
* SimpleOperator: "equals",
* Value: "Active"
* };
* var result = api.retrieve("DataExtension", cols, filter);
* if (result.Status === "OK") {
* var rows = result.Results;
* for (var i = 0; i < rows.length; i++) {
* Write(rows[i].Name + "
");
* }
* }
*/
retrieve(objectType: string, columns: any[], filter?: object, retrieveOptions?: object, requestProps?: object): WSProxyResult;
/**
* Retrieves the next page of results from a previous retrieve call that returned HasMoreRows = true.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/getnextbatch/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param objectType - SOAP API object type name used in the original retrieve call
* @param requestId - RequestID returned by the previous retrieve response
* @returns Object with Status, HasMoreRows, RequestID, and Results array.
* @example
* var api = new Script.Util.WSProxy();
* var result = api.retrieve("DataExtension", ["Name"], {});
* while (result.HasMoreRows) {
* result = api.getNextBatch("DataExtension", result.RequestID);
* for (var i = 0; i < result.Results.length; i++) {
* Write(result.Results[i].Name + "
");
* }
* }
*/
getNextBatch(objectType: string, requestId: string): WSProxyResult;
/**
* Executes a perform action on a single Marketing Cloud object.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/performitem/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime (CloudPage) confirmed the (objectType, properties, action[, performOptions]) signature and the WSProxyResult return shape: Status/StatusMessage/RequestID plus a single-entry Results array. Against a freshly-created active QueryDefinition, both "Start" and lowercase "start" returned Status "OK" with Results[0].StatusMessage "QueryDefinition perform called successfully" — the action verb is case-insensitive, so the docs' Enum('Start') is not case-sensitive as the page previously claimed. The Results[0] element exposes StatusCode, StatusMessage, OrdinalID, ErrorCode, an Object wrapper and a Task sub-object (with InteractionObjectID); the official docs do not detail this per-item structure.
* @param objectType - SOAP API object type name.
* @param properties - Object properties identifying the target item (e.g. { ObjectID: "..." }).
* @param action - Action to perform, typically "Start". The verb is case-insensitive at runtime ("start" works identically to "Start").
* @param performOptions - Properties of the SOAP PerformOptions object.
* @returns Object with Status (string, "OK" on success), StatusMessage (string, empty on success), RequestID (string) and Results (Array with a single entry for the acted-on item). The Results[0] element carries StatusCode, StatusMessage ("QueryDefinition perform called successfully"), OrdinalID, ErrorCode plus an Object (the acted-on API object) and a Task sub-object (StatusCode, StatusMessage, ID, TblAsyncID, InteractionObjectID).
* @example
* var api = new Script.Util.WSProxy();
* var result = api.performItem("QueryDefinition", { ObjectID: queryObjectId }, "Start");
* Write(result.Status);
*/
performItem(objectType: string, properties: object, action: string, performOptions?: object): WSProxyResult;
/**
* Executes a perform action on multiple Marketing Cloud objects in a single SOAP API call.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/performbatch/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime (CloudPage) confirmed the (objectType, propertiesArray, action[, performOptions]) signature and the WSProxyResult return shape: Status/StatusMessage/RequestID plus a Results array with one entry per input item. Against a freshly-created active QueryDefinition, both "Start" and lowercase "start" returned Status "OK" with Results[0].StatusMessage "QueryDefinition perform called successfully" — the action verb is case-insensitive, so the docs' Enum('Start') is not case-sensitive as previously assumed. Each Results element exposes StatusCode, StatusMessage, OrdinalID, ErrorCode, an Object wrapper and a Task sub-object (with InteractionObjectID); the official docs do not detail this per-item structure.
* @param objectType - SOAP API object type name
* @param propertiesArray - Array of property objects identifying the target items
* @param action - Action to perform, typically "Start". The verb is case-insensitive at runtime ("start" works identically to "Start").
* @param performOptions - Properties of the SOAP PerformOptions object
* @returns Object with Status (string, "OK" on success), StatusMessage (string, empty on success), RequestID (string) and Results (Array with one entry per input item). Each Results element carries StatusCode, StatusMessage, OrdinalID, ErrorCode plus an Object (the acted-on API object) and a Task sub-object (StatusCode, StatusMessage, InteractionObjectID, etc.).
* @example
* var api = new Script.Util.WSProxy();
* var items = [{ ObjectID: id1 }, { ObjectID: id2 }];
* var result = api.performBatch("QueryDefinition", items, "Start");
* Write(result.Status);
*/
performBatch(objectType: string, propertiesArray: any[], action: string, performOptions?: object): WSProxyResult;
/**
* Returns structural metadata for one or more SOAP API object types, one ObjectDefinition per requested type.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/describe/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs place field details at Results[0].ObjectDefinition.Properties, but at runtime each Results element is directly the ObjectDefinition (Results[0].Properties); there is no nested ObjectDefinition wrapper, and the return object exposes RequestID (not Status).
* @param objectType - Object type name, or an array of type names, to describe
* @returns Object with RequestID (string) and Results (Array). Each Results element is itself the ObjectDefinition — properties like ObjectType, Name, IsCreatable and the Properties field-definition array sit directly on Results[i], NOT under a nested Results[i].ObjectDefinition.
* @example
* var api = new Script.Util.WSProxy();
* var result = api.describe("DataExtension");
* Write(Stringify(result.Results[0].Properties));
*/
describe(objectType: string | string[]): WSProxyResult;
/**
* Runs a SOAP Execute request (e.g. LogUnsubEvent), passing an array of Name/Value parameter objects and the request name.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/execute/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param parameters - Array of Name/Value parameter objects to include in the Execute call.
* @param requestName - Name of the Execute request to run.
* @returns Object with Status (string), RequestID (string), and a Results array of per-item ExecuteResponse objects (StatusCode, StatusMessage, OrdinalID, Results, ErrorCode).
* @example
* var api = new Script.Util.WSProxy();
* var props = [
* { Name: "SubscriberKey", Value: "sample@sample.com" },
* { Name: "EmailAddress", Value: "sample@sample.com" },
* { Name: "JobID", Value: 0 },
* { Name: "ListID", Value: 0 },
* { Name: "BatchID", Value: 0 }
* ];
* var result = api.execute(props, "LogUnsubEvent");
* Write(result.Status);
*/
execute(parameters: object[], requestName: string): WSProxyResult;
/**
* Sets a ClientId (impersonation) context on the WSProxy instance so subsequent operations run against another business unit. Pass an object with the MID under the "ID" key (and optionally "UserID"). The call itself is never rejected; whether the following operation is allowed depends on where the script runs. From a parent BU every business unit of the account can be targeted. From a child BU only its own MID works — neither the parent nor a sibling child is reachable, and the next operation fails with a "does not have access to ClientID" status naming the executing MID and the requested one. Cross-BU work therefore has to run from a parent BU.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/setclientid/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs document setClientId() as returning void, but at runtime it returns a genuine null (=== null), not undefined.
* @param options - Object with the target ClientId properties; at least the "ID" key (target BU MID) is expected, "UserID" is optional.
* @example
* var api = new Script.Util.WSProxy();
* api.setClientId({ ID: 12345 }); // target child BU by MID
* var result = api.retrieve("DataExtension", ["Name"], {});
*/
setClientId(options: object): null;
/**
* Clears all client IDs set on the WSProxy instance, reverting to the default execution context credentials.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/resetclientids/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs document resetClientIds() as returning void, but at runtime it returns a genuine null (=== null), not undefined.
* @example
* var api = new Script.Util.WSProxy();
* api.setClientId({ ID: 12345 });
* // ... perform cross-BU operations ...
* api.resetClientIds(); // revert to default context
* var result = api.retrieve("DataExtension", ["Name"], {});
*/
resetClientIds(): null;
/**
* Creates multiple Marketing Cloud objects in a single SOAP API call.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/createbatch/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param objectType - SOAP API object type name
* @param propertiesArray - Array of property objects to create
* @param createOptions - Optional SOAP CreateOptions object (e.g. RequestType, QueuePriority).
* @returns Object with Status (string, e.g. "OK"), RequestID (string GUID), and a Results array holding one entry per input object (each with StatusCode, StatusMessage, NewObjectID, Object, etc.).
* @example
* var api = new Script.Util.WSProxy();
* var items = [
* { CustomerKey: "MyDE", Properties: { Property: [{ Name: "Email", Value: "a@example.com" }] } },
* { CustomerKey: "MyDE", Properties: { Property: [{ Name: "Email", Value: "b@example.com" }] } }
* ];
* var result = api.createBatch("DataExtensionObject", items);
* Write(result.Status);
*/
createBatch(objectType: string, propertiesArray: any[], createOptions?: object): WSProxyResult;
/**
* Updates multiple Marketing Cloud objects in a single SOAP API call.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/updatebatch/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param objectType - SOAP API object type name
* @param propertiesArray - Array of property objects to update
* @param updateOptions - Optional SOAP UpdateOptions object (e.g. { SaveOptions: [...] })
* @returns Object with Status, RequestID, and a Results array (one entry per input item). Each Results entry carries StatusCode, StatusMessage, OrdinalID, ErrorCode, and an Object wrapper.
* @example
* var api = new Script.Util.WSProxy();
* var items = [
* { CustomerKey: "MyDE", Keys: [{ Name: "Email", Value: "a@example.com" }], Properties: [{ Name: "Status", Value: "active" }] }
* ];
* var result = api.updateBatch("DataExtensionObject", items);
* Write(result.Status);
*/
updateBatch(objectType: string, propertiesArray: any[], updateOptions?: object): WSProxyResult;
/**
* Deletes multiple Marketing Cloud objects in a single SOAP API call.
*
* [ssjs.guide reference](https://ssjs.guide/wsproxy/deletebatch/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param objectType - SOAP API object type name
* @param propertiesArray - Array of property objects identifying each object to delete. For DataExtensionObject use CustomerKey plus a flat Keys array of { Name, Value } pairs — the nested Keys.Key form accepted by deleteItem throws here.
* @param deleteOptions - Optional SOAP DeleteOptions object (e.g. RequestType, QueuePriority).
* @returns Object with Status (string, e.g. "OK"), RequestID (string GUID), and a Results array holding one entry per input object (each with StatusCode, StatusMessage, ErrorCode, Object, etc.). There is no top-level StatusMessage.
* @example
* var api = new Script.Util.WSProxy();
* var items = [
* { CustomerKey: "MyDE", Keys: [{ Name: "Email", Value: "old@example.com" }] }
* ];
* var result = api.deleteBatch("DataExtensionObject", items);
* Write(result.Status);
*/
deleteBatch(objectType: string, propertiesArray: any[], deleteOptions?: object): WSProxyResult;
}
/**
* Creates an HTTP request handler that supports any HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS). Unlike Platform.Function.HTTPGet/HTTPPost, this handler supports custom methods and headers. Call send() to execute the request and receive a Script.Util.HttpResponse object.
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httprequest/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param url - The destination URL for the request
* @example
* var url = "https://api.example.com/items/123";
* var req = new Script.Util.HttpRequest(url);
* req.emptyContentHandling = 0;
* req.retries = 2;
* req.continueOnError = true;
* req.contentType = "application/json";
* req.method = "PUT";
* req.setHeader("Authorization", "Bearer " + accessToken);
* req.postData = Stringify({ status: "active" });
* var resp = req.send();
* var result = Platform.Function.ParseJSON(String(resp.content));
*/
class HttpRequest {
/**
* Creates an HTTP request handler that supports any HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS). Unlike Platform.Function.HTTPGet/HTTPPost, this handler supports custom methods and headers. Call send() to execute the request and receive a Script.Util.HttpResponse object.
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httprequest/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param url - The destination URL for the request
* @example
* var url = "https://api.example.com/items/123";
* var req = new Script.Util.HttpRequest(url);
* req.emptyContentHandling = 0;
* req.retries = 2;
* req.continueOnError = true;
* req.contentType = "application/json";
* req.method = "PUT";
* req.setHeader("Authorization", "Bearer " + accessToken);
* req.postData = Stringify({ status: "active" });
* var resp = req.send();
* var result = Platform.Function.ParseJSON(String(resp.content));
*/
constructor(url: string);
/**
* Executes the HTTP request and returns a Script.Util.HttpResponse object. The response object has a `statusCode` property and a `content` property. Use String(resp.content) to convert the CLR content to a JavaScript string before parsing with Platform.Function.ParseJSON().
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httprequest/#send)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var req = new Script.Util.HttpRequest("https://api.example.com/data");
* req.method = "GET";
* req.setHeader("Authorization", "Bearer " + accessToken);
* var resp = req.send();
* if (resp.statusCode == 200) {
* var result = Platform.Function.ParseJSON(String(resp.content));
* }
*/
send(): HttpResponseInstance;
/**
* Sets a request header on the Script.Util HTTP request. Note: setting a custom header disables content caching for Script.Util.HttpGet.
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httprequest/#setheader)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param name - Header name (e.g. "Authorization", "Content-Type")
* @param value - Header value
* @example
* var req = new Script.Util.HttpRequest("https://api.example.com/data");
* req.setHeader("Authorization", "Bearer " + accessToken);
* req.setHeader("Content-Type", "application/json");
* var resp = req.send();
*/
setHeader(name: string, value: string): void;
/**
* Removes all custom headers previously set on the request.
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httprequest/#clearheaders)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var req = new Script.Util.HttpRequest("https://api.example.com/data");
* req.setHeader("Authorization", "Bearer " + accessToken);
* req.clearHeaders(); // removes Authorization and all other custom headers
* var resp = req.send();
*/
clearHeaders(): void;
/**
* Removes a specific header from the request by name.
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httprequest/#removeheader)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param name - Name of the header to remove
* @example
* var req = new Script.Util.HttpRequest("https://api.example.com/data");
* req.setHeader("Authorization", "Bearer " + accessToken);
* req.setHeader("X-Custom", "value");
* req.removeHeader("X-Custom");
* var resp = req.send();
*/
removeHeader(name: string): void;
/**
* Number of times a failed request is retried before it gives up (default 1).
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
retries: number;
/**
* If true, a failed request lets the script carry on instead of throwing an error.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
continueOnError: boolean;
/**
* What to do when the request returns no content: 0 = continue, 1 = stop, 2 = continue to next subscriber (email sends only).
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type this as a boolean, but both request handlers accept only the numeric modes 0/1/2 at runtime and reject true/false.
*/
emptyContentHandling: number;
/**
* Timeout in seconds (default 30).
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs do not list this as a configuration property on either request handler — they only state that send() gives up after 30 seconds. The property does exist and is applied end-to-end at runtime, and its default of 30 lines up with that 30-second limit, so the unit is seconds.
*/
timeout: number;
/**
* HTTP method (GET, POST, PUT, PATCH, DELETE).
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
method: string;
/**
* Content-Type header for the request body, e.g. "application/json".
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
contentType: string;
/**
* Character encoding for the request. The runtime default is "Windows-1252", not "UTF-8" — set it explicitly when the body is UTF-8. An assigned value is read back lower-cased ("UTF-8" reads back as "utf-8").
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
encoding: string;
/**
* Request body for POST/PUT/PATCH requests. Write-only: assignment works and the body reaches the server, but reading the property throws "Property Get method was not found." — outside a try/catch that throw aborts the whole CloudPage.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs list postData among the readable configuration properties, but the runtime exposes no getter: every read throws "Property Get method was not found." while assignment works normally.
*/
postData: string;
}
/**
* Creates an HTTP GET request handler. Unlike Platform.Function.HTTPGet, this handler caches content for use in mail sends and supports custom headers. Only works with HTTP on port 80 and HTTPS on port 443. Call send() to execute the request and receive a Script.Util.HttpResponse object.
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httpget/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param url - The URL to retrieve content from
* @example
* var req = new Script.Util.HttpGet("https://api.example.com/data");
* req.setHeader("Authorization", "Bearer " + accessToken);
* req.retries = 2;
* req.continueOnError = true;
* var resp = req.send();
* if (resp.statusCode == 200) {
* var result = Platform.Function.ParseJSON(String(resp.content));
* Platform.Response.Write(Platform.Function.Stringify(result));
* }
*/
class HttpGet {
/**
* Creates an HTTP GET request handler. Unlike Platform.Function.HTTPGet, this handler caches content for use in mail sends and supports custom headers. Only works with HTTP on port 80 and HTTPS on port 443. Call send() to execute the request and receive a Script.Util.HttpResponse object.
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httpget/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param url - The URL to retrieve content from
* @example
* var req = new Script.Util.HttpGet("https://api.example.com/data");
* req.setHeader("Authorization", "Bearer " + accessToken);
* req.retries = 2;
* req.continueOnError = true;
* var resp = req.send();
* if (resp.statusCode == 200) {
* var result = Platform.Function.ParseJSON(String(resp.content));
* Platform.Response.Write(Platform.Function.Stringify(result));
* }
*/
constructor(url: string);
/**
* Executes the HTTP request and returns a Script.Util.HttpResponse object. The response object has a `statusCode` property and a `content` property. Use String(resp.content) to convert the CLR content to a JavaScript string before parsing with Platform.Function.ParseJSON().
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httprequest/#send)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var req = new Script.Util.HttpRequest("https://api.example.com/data");
* req.method = "GET";
* req.setHeader("Authorization", "Bearer " + accessToken);
* var resp = req.send();
* if (resp.statusCode == 200) {
* var result = Platform.Function.ParseJSON(String(resp.content));
* }
*/
send(): HttpResponseInstance;
/**
* Sets a request header on the Script.Util HTTP request. Note: setting a custom header disables content caching for Script.Util.HttpGet.
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httprequest/#setheader)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param name - Header name (e.g. "Authorization", "Content-Type")
* @param value - Header value
* @example
* var req = new Script.Util.HttpRequest("https://api.example.com/data");
* req.setHeader("Authorization", "Bearer " + accessToken);
* req.setHeader("Content-Type", "application/json");
* var resp = req.send();
*/
setHeader(name: string, value: string): void;
/**
* Removes all custom headers previously set on the request.
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httprequest/#clearheaders)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var req = new Script.Util.HttpRequest("https://api.example.com/data");
* req.setHeader("Authorization", "Bearer " + accessToken);
* req.clearHeaders(); // removes Authorization and all other custom headers
* var resp = req.send();
*/
clearHeaders(): void;
/**
* Removes a specific header from the request by name.
*
* [ssjs.guide reference](https://ssjs.guide/http/script-util-httprequest/#removeheader)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param name - Name of the header to remove
* @example
* var req = new Script.Util.HttpRequest("https://api.example.com/data");
* req.setHeader("Authorization", "Bearer " + accessToken);
* req.setHeader("X-Custom", "value");
* req.removeHeader("X-Custom");
* var resp = req.send();
*/
removeHeader(name: string): void;
/**
* Number of times a failed request is retried before it gives up (default 1).
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
retries: number;
/**
* If true, a failed request lets the script carry on instead of throwing an error.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
continueOnError: boolean;
/**
* What to do when the request returns no content: 0 = continue, 1 = stop, 2 = continue to next subscriber (email sends only).
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs type this as a boolean, but both request handlers accept only the numeric modes 0/1/2 at runtime and reject true/false.
*/
emptyContentHandling: number;
/**
* Timeout in seconds (default 30).
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs do not list this as a configuration property on either request handler — they only state that send() gives up after 30 seconds. The property does exist and is applied end-to-end at runtime, and its default of 30 lines up with that 30-second limit, so the unit is seconds.
*/
timeout: number;
}
}
}
// ── Script.Util HTTP response instance ──────────────────────────────────────
interface HttpResponseInstance {
/**
* Response body as a CLR string — wrap with String() before use. Reading .length directly on it always yields -1 no matter how long the body is, and typeof reports "number" so the usual CLR tell is absent; measure with String(content).length instead.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
readonly content: any;
/**
* Content type returned in the response. Always empty when the request was made with Script.Util.HttpGet — use Script.Util.HttpRequest to get it.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
readonly contentType: string;
/**
* Documented as the encoding type returned in the response, but it is always an empty string at runtime — on Script.Util.HttpRequest as well as on Script.Util.HttpGet, even when the response Content-Type carries a charset. Read the charset from the content-type header instead.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official docs list encoding as a populated response property, but it comes back empty for every request handler — the charset is only obtainable from the content-type header.
*/
readonly encoding: string;
/**
* Response headers as a CLR object. Direct access (headers["X"], .Get(), .Item(), String(headers[key])) throws "Use of CLR is not allowed". To read values, enumerate with for..in: each key is the string "Name, Value" (wrapped in [ ]) — strip the brackets and split on the first ", " to build a plain header map. The enumeration is always empty when the request was made with Script.Util.HttpGet — use Script.Util.HttpRequest to read headers.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. The official example reads a single header via headers["..."], but that access throws at runtime. Individual values are only readable by parsing the for..in enumeration keys (shaped "[Name, Value]"), not by indexing.
*/
readonly headers: object;
/**
* Status value: 0 = OK, 1 = empty URL, 2 = call failed, 3 = succeeded with empty content. Returned as a CLR value: === against a number literal is never true and switch/case silently falls through to default, so convert once with Number() and compare the result. Do not use == — loose equality against a CLR value backed by a .NET null throws "Value cannot be null. Parameter name: value", while === returns false safely. Relational operators (<, <=, >, >=) already evaluate correctly on the raw value.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
readonly returnStatus: number;
/**
* HTTP status code. Returned as a CLR value: === against a number literal is never true and switch/case silently falls through to default, so convert once with Number() and compare the result. Do not use == — loose equality against a CLR value backed by a .NET null throws "Value cannot be null. Parameter name: value", while === returns false safely. Relational operators (<, <=, >, >=) already evaluate correctly on the raw value.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
*/
readonly statusCode: number;
}
// ── WSProxy per-item result entry ───────────────────────────────────────────
interface WspResult {
/** Per-item status: "OK" on success, "Error" on failure. Present on create/update/delete/perform entries; absent on rows returned by retrieve()/getNextBatch(). */
readonly StatusCode?: string;
/** Per-item human-readable message. Populated on success too (e.g. "QueryDefinition deleted"), not only on failure. This — not the top-level StatusMessage — carries the real error text. */
readonly StatusMessage?: string;
/** Zero-based index of the input item this entry corresponds to. Always 0 for the single-item methods (createItem/updateItem/deleteItem/performItem). */
readonly OrdinalID?: number;
/** Numeric error code. Present as 0 on success AND on many failures — it is not a reliable failure signal; use StatusCode instead. */
readonly ErrorCode?: number;
/** Numeric ID assigned to a newly created object. Only present on create results; undefined on update, delete, perform and retrieve entries. */
readonly NewID?: number;
/** GUID assigned to a newly created object. Only present on create results for object types that use ObjectID keys; undefined on update, delete, perform and retrieve entries. */
readonly NewObjectID?: string;
/** Echo of the affected object as returned by the API — the payload you sent plus server-populated fields (ObjectID, CreatedDate, ModifiedDate, Client, PartnerKey, ObjectState, …). Present on both success and failure entries. */
readonly Object?: object;
/** perform-only: async task descriptor with StatusCode, StatusMessage, OrdinalID, ErrorCode, ID, TblAsyncID and InteractionObjectID. Present for performItem()/performBatch(); undefined elsewhere. */
readonly Task?: object;
/** Per-entry request identifier. Observed as null on every result entry at runtime — read the top-level RequestID instead. */
readonly RequestID?: string;
/** retrieve()/getNextBatch(): retrieved-row fields keyed by column name. */
readonly [column: string]: any;
}
// ── WSProxy result object ───────────────────────────────────────────────────
interface WSProxyResult {
/** Overall result status. More than the documented two values: "OK", "MoreDataAvailable" (paged retrieve), "InvalidRequest" (request rejected), "Error", or a full sentence carrying the failure text. */
readonly Status: string;
/** Server-assigned request identifier (GUID). Always present, including on failed calls; getNextBatch() echoes the same value for every page of one retrieve. */
readonly RequestID: string;
/** Array-like collection of per-object result entries (or retrieved rows for retrieve()). Null when the request itself was rejected. */
readonly Results: WspResult[];
/** retrieve()/getNextBatch() only: true when more rows exist — call getNextBatch() with the same RequestID. Absent (undefined) on create/update/delete/perform results. */
readonly HasMoreRows?: boolean;
/** Human-readable status message. Rarely populated at the top level — usually undefined even on failures, where the real message sits on Results[i].StatusMessage. */
readonly StatusMessage?: string;
}
// ── ECMAScript built-ins (SFMC-supported subset only) ───────────────────────
interface Array {
/**
* Joins all array elements into a string, separated by the specified delimiter.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param separator - Delimiter string (default: ",")
* @example
* var arr = ["a", "b", "c"];
* var str = arr.join(", "); // "a, b, c"
*/
join(separator?: string): string;
/**
* Appends one or more elements to the end of an array and returns the new length.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param element - Element to append (repeat for multiple)
* @example
* var arr = [1, 2];
* arr.push(3);
* // arr is now [1, 2, 3]
*/
push(...elements: T[]): number;
/**
* Removes and returns the last element from an array.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var arr = [1, 2, 3];
* var last = arr.pop(); // 3
*/
pop(): T;
/**
* Removes and returns the first element from an array.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var arr = [1, 2, 3];
* var first = arr.shift(); // 1
*/
shift(): T;
/**
* Inserts one or more elements at the start of an array and returns the new length.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param element - Element to prepend (repeat for multiple)
* @example
* var arr = [2, 3];
* arr.unshift(1);
* // arr is now [1, 2, 3]
*/
unshift(...elements: T[]): number;
/**
* Returns a new array formed by merging this array with other arrays or values.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param value - Array or value to concatenate
* @example
* var a = [1, 2];
* var b = [3, 4];
* var c = a.concat(b); // [1, 2, 3, 4]
*/
concat(...values: T[]): T[];
/**
* Returns a shallow copy of a portion of an array.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ⚠️ The no-argument form arr.slice() throws in the SFMC engine. Always pass at least a start index, e.g. arr.slice(0), to copy the whole array.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies arr.slice() with no arguments returns a shallow copy of the whole array. In the SFMC SSJS engine the no-argument form throws "Index was outside the bounds of the array."; pass an explicit start index (arr.slice(0)) instead. Positive and negative indices otherwise behave per spec.
* @param start - Start index (0-based, negative counts from end)
* @param end - End index (exclusive)
* @example
* var arr = [1, 2, 3, 4, 5];
* var sub = arr.slice(1, 3); // [2, 3]
*/
slice(start?: number, end?: number): T[];
/**
* Sorts the array in place and returns it. Default sort is lexicographic.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ⚠️ The no-argument form arr.sort() throws in the SFMC engine. Always pass an explicit compare function, e.g. arr.sort(function (a, b) { return a < b ? -1 : a > b ? 1 : 0; }).
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies arr.sort() with no comparator sorts elements as strings. In the SFMC SSJS engine the no-argument form throws "Failed to compare two elements in the array."; always pass an explicit compare function. A supplied comparator otherwise sorts per spec.
* @param compareFn - Optional comparison function (a, b) returning negative, 0, or positive
* @example
* var arr = [3, 1, 2];
* arr.sort(function(a, b) { return a - b; }); // [1, 2, 3]
*/
sort(compareFn?: any): T[];
/**
* Reverses the elements of an array in place.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var arr = [1, 2, 3];
* arr.reverse(); // [3, 2, 1]
*/
reverse(): T[];
/**
* Returns the number of elements in the array.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var arr = [1, 2, 3];
* Write(arr.length); // 3
*/
readonly length: number;
/**
* Returns a string representing the array elements, joined by a locale-specific separator.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/array-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var arr = [1, 2, 3];
* Write(arr.toLocaleString()); // "1,2,3"
*/
toLocaleString(): string;
}
interface String {
/**
* Returns the character at the specified index.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ⚠️ Out-of-range indices are broken in the SFMC engine: instead of the spec-mandated empty string "", str.charAt(i) for i >= str.length returns the LAST character of the string (e.g. "Hello".charAt(99) returns "o"). Guard the index against str.length before calling. Bracket access str[i] for an out-of-range index throws "Index was outside the bounds of the array" rather than returning undefined.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies str.charAt(index) returns an empty string when index is out of range. In the SFMC Jint engine an out-of-range index returns the LAST character instead of "" (e.g. "abc".charAt(99) returns "c"). Guard the index against str.length before calling.
* @param index - Zero-based character index
* @example
* var str = "Hello";
* Write(str.charAt(1)); // "e"
*/
charAt(index: number): string;
/**
* Returns the UTF-16 code unit at the specified index.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param index - Zero-based character index
* @example
* var str = "A";
* Write(str.charCodeAt(0)); // 65
*/
charCodeAt(index: number): number;
/**
* Returns the index of the first occurrence of a substring, or -1 if not found.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param searchValue - Substring to search for
* @param fromIndex - Index to start the search from
* @example
* var str = "Hello, world!";
* Write(str.indexOf("world")); // 7
*/
indexOf(searchValue: string, fromIndex?: number): number;
/**
* Returns the index of the last occurrence of a substring, or -1 if not found.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param searchValue - Substring to search for
* @param fromIndex - Index to search backwards from
* @example
* var str = "abcabc";
* Write(str.lastIndexOf("b")); // 4
*/
lastIndexOf(searchValue: string, fromIndex?: number): number;
/**
* Matches a string against a regular expression and returns the matches array.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies str.match(regex) returns null when there is no match, and match objects carry an .index property. In the SFMC Jint engine a no-match returns an empty array [] (not null), and returned matches expose no .index. Test result.length rather than comparing against null.
* @param regexp - Regular expression to match against
* @example
* var str = "test@example.com";
* var matches = str.match(/[\w.]+@[\w.]+/);
* if (matches) { Write(matches[0]); }
*/
match(regexp: RegExp): any[];
/**
* Returns a new string with matches replaced by a replacement string or function.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param searchValue - Substring or RegExp to find
* @param replaceValue - Replacement string
* @example
* var str = "Hello, world!";
* Write(str.replace("world", "SSJS")); // "Hello, SSJS!"
*/
replace(searchValue: any, replaceValue: string): string;
/**
* Searches for a match and returns the index of the first match, or -1.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ⚠️ String.search is unreliable in the SFMC engine: a no-match returns 0 instead of the spec-mandated -1, and some real matches return the wrong index (observed returning 0 or -1 where the match is elsewhere). Use String.match or RegExp.test to detect a match, or apply the search polyfill.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies str.search(regex) returns -1 when there is no match. In the SFMC Jint engine a no-match returns 0 (not -1) and some real matches return the wrong index, so search is unreliable for locating substrings. Use indexOf or a match-based approach instead.
* @param regexp - Regular expression to search for
* @example
* var str = "foo123bar";
* Write(str.search(/\d+/)); // 3
*/
search(regexp: RegExp): number;
/**
* Extracts a section of a string and returns it as a new string.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param start - Start index (negative counts from end)
* @param end - End index (exclusive)
* @example
* var str = "Hello, world!";
* Write(str.slice(7, 12)); // "world"
*/
slice(start: number, end?: number): string;
/**
* Splits a string into an array of substrings using a separator.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ⚠️ The empty-separator form str.split("") does NOT split into characters in the SFMC engine (it returns the whole string as a single element). To get characters, loop with charAt.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies str.split("") splits a string into an array of its individual characters. In the SFMC Jint engine the empty-separator form does NOT split into characters ("abc".split("") returns ["abc"]). Split on a real separator, or iterate with charAt for per-character access.
* @param separator - String or RegExp to split on
* @param limit - Maximum number of substrings to return
* @example
* var str = "a,b,c";
* var parts = str.split(","); // ["a", "b", "c"]
*/
split(separator: any, limit?: number): any[];
/**
* Returns the characters between two indices of a string.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param start - Start index (inclusive)
* @param end - End index (exclusive)
* @example
* var str = "Hello, world!";
* Write(str.substring(7, 12)); // "world"
*/
substring(start: number, end?: number): string;
/**
* Returns the string converted to lowercase.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var str = "Hello World";
* Write(str.toLowerCase()); // "hello world"
*/
toLowerCase(): string;
/**
* Returns the string converted to lowercase. Runtime-verified in SFMC; it behaves like toLowerCase() (locale mappings are not applied).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ⚠️ The locale argument is ignored — it behaves exactly like toLowerCase(). "ABC".toLocaleLowerCase() returns "abc" with no locale-specific casing.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: "ABC".toLocaleLowerCase() === "abc". The SFMC Jint engine applies no locale-specific mappings, so this is a plain toLowerCase() alias rather than the locale-aware method the spec describes.
* @example
* var str = "AbC";
* Write(str.toLocaleLowerCase()); // "abc"
*/
toLocaleLowerCase(): string;
/**
* Returns the string converted to uppercase. Runtime-verified in SFMC; it behaves like toUpperCase() (locale mappings are not applied).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ⚠️ The locale argument is ignored — it behaves exactly like toUpperCase(). "abc".toLocaleUpperCase() returns "ABC" with no locale-specific casing.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: "abc".toLocaleUpperCase() === "ABC". The SFMC Jint engine applies no locale-specific mappings, so this is a plain toUpperCase() alias rather than the locale-aware method the spec describes.
* @example
* var str = "abc";
* Write(str.toLocaleUpperCase()); // "ABC"
*/
toLocaleUpperCase(): string;
/**
* Returns the string converted to uppercase.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var str = "Hello World";
* Write(str.toUpperCase()); // "HELLO WORLD"
*/
toUpperCase(): string;
/**
* Returns a new string formed by concatenating this string with one or more additional strings.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param string - String to append (repeat for multiple)
* @example
* var str = "Hello";
* Write(str.concat(", ", "world!")); // "Hello, world!"
*/
concat(...strings: string[]): string;
/**
* Compares this string with another and returns a negative number if it sorts before, a positive number if it sorts after, or 0 if they are equivalent.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param compareString - The string to compare against
* @example
* Write('a'.localeCompare('b')); // -1
*/
localeCompare(compareString: string): number;
/**
* Returns the number of characters in the string.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/string-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var str = "Hello";
* Write(str.length); // 5
*/
readonly length: number;
}
interface Number {
/**
* Returns a string representing the number in fixed-point notation with the given number of decimal places.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param fractionDigits - Number of digits after the decimal point (0–20, default 0)
* @example
* var price = 9.99;
* Write(price.toFixed(2)); // "9.99"
* Write((1.5).toFixed(0)); // "2"
*/
toFixed(fractionDigits?: number): string;
/**
* Returns a string representing the number in exponential notation. When fractionDigits is omitted the SFMC Jint engine pads the significand with trailing zeros (e.g. (3.14159).toExponential() → "3.1415900000000000e+0") instead of the minimal form standard JS produces. Always pass an explicit fractionDigits argument for predictable output.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies toExponential() with no argument uses the minimal number of significand digits needed. In the SFMC Jint engine the no-argument form pads the significand with trailing zeros (e.g. (3.14159).toExponential() returns "3.1415900000000000e+0"). Always pass an explicit fractionDigits count.
* @param fractionDigits - Digits after the decimal point in the significand (0–20)
* @example
* Write((123456).toExponential(2)); // "1.23e+5"
*/
toExponential(fractionDigits?: number): string;
/**
* Returns a string representing the number. In the SFMC Jint engine the precision argument selects DECIMAL PLACES, not significant digits: the result carries max(1, precision - 1) decimals, making it equivalent to toFixed(precision - 1). The argument is mandatory (omitting it throws "precision missing") and must be 1–21 (otherwise "precision must be between 1 and 21" is thrown).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies toPrecision(precision) formats the number to that many SIGNIFICANT digits, switching to exponential notation when needed ((123.456).toPrecision(5) is "123.46", (123.456).toPrecision(2) is "1.2e+2"). The SFMC Jint engine instead formats to a fixed number of DECIMAL PLACES equal to max(1, precision - 1), identical to toFixed(precision - 1) — (123.456).toPrecision(5) returns "123.4560" and (123.456).toPrecision(2) returns "123.5". It never switches to exponential notation. The argument is also mandatory here (omitting it throws "precision missing", whereas MDN specifies the no-argument form behaves like toString()).
* @param precision - Required in SFMC, 1–21. Selects max(1, precision - 1) decimal places rather than significant digits.
* @example
* Write((123.456).toPrecision(5)); // "123.4560" in SFMC (spec: "123.46")
*/
toPrecision(precision: number): string;
/**
* Returns a string representing the number. In the SFMC Jint engine the optional radix only supports 2, 8, 10, and 16 — any other base throws "Invalid Base." (standard JS supports 2–36). Fractional values are truncated to their integer part before non-decimal conversion.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies Number.prototype.toString(radix) accepts any radix from 2 to 36. In the SFMC Jint engine only radixes 2, 8, 10, and 16 work; any other base throws "Invalid Base." (e.g. (35).toString(36)). Fractional values are also truncated to their integer part before non-decimal conversion ((3.5).toString(2) returns "100", not "11.1").
* @param radix - Base for the conversion. SFMC only accepts 2, 8, 10, or 16; other values throw "Invalid Base."
* @example
* Write((255).toString(16)); // "ff"
* Write((255).toString(2)); // "11111111"
* // (35).toString(36) throws "Invalid Base." in SFMC
*/
toString(radix?: number): string;
/**
* Returns the primitive number value of a Number object.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* Write((42).valueOf()); // 42
*/
valueOf(): number;
/**
* Returns a string representation of the number. Runtime-verified in SFMC: the locale argument is ignored and no grouping separators are applied — it behaves like a plain toString(). Use AMPscript FormatNumber via Platform.Function.TreatAsContent for real locale formatting.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ⚠️ The locale argument is ignored — (123456.789).toLocaleString("de-DE") returns "123456.789", not the grouped "123.456,789".
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN specifies locale-aware formatting with grouping separators; the SFMC Jint engine ignores the locale/options arguments and returns the plain number string (no grouping).
* @param locales - Ignored in SFMC
* @param options - Ignored in SFMC
* @example
* Write((123456.789).toLocaleString("de-DE")); // "123456.789" (locale ignored)
*/
toLocaleString(locales?: string, options?: object): string;
}
interface Boolean {
/**
* Defined on Boolean.prototype, but it does NOT unwrap a boxed Boolean in the SFMC engine — it returns the boxed object itself. Called through .call() on a primitive it returns that primitive.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/boolean/)
*
* @remarks ⚠️ new Boolean(false).valueOf() returns the boxed object (typeof "object"), not the primitive. There is no reliable way to unwrap a boxed Boolean — avoid creating one and use Boolean(value) or !!value instead.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN specifies valueOf() returns the primitive boolean wrapped by the object. In the SFMC Jint engine box.valueOf() === box is true and typeof box.valueOf() is "object", so it does not unwrap. Boolean.prototype.valueOf.call(true) does return the primitive true.
* @example
* var b = new Boolean(false);
* Write(typeof b.valueOf()); // "object" in SFMC (spec: "boolean")
* Write(b.valueOf() === b); // true in SFMC — it does not unwrap
* Write(Boolean.prototype.valueOf.call(true)); // true
*/
valueOf(): boolean;
/**
* Returns the string form of a boolean. In the SFMC engine the first letter is capitalized ("True" / "False") instead of the lowercase form the spec requires.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/boolean/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified via String(new Boolean(true)): MDN specifies the lowercase "true"/"false"; on a boxed instance the SFMC Jint engine capitalizes the first letter ("True"/"False") — in String(), in "" + x concatenation and in an explicit .toString(). Called through .call() on a PRIMITIVE it returns the correct lowercase form, which is the reliable workaround (a primitive has no .toString() of its own because there is no auto-boxing).
* @example
* var b = new Boolean(true);
* Write(b.toString()); // "True" in SFMC (spec: "true")
* Write(Boolean.prototype.toString.call(true)); // "true" (correct, lowercase)
*/
toString(): string;
}
interface Object {
/**
* Returns true if the object has the specified property as its own (not inherited) property. Commonly used to safely iterate for...in loops.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/object-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param v - Property name to test
* @example
* var obj = {a: 1};
* for (var key in obj) {
* if (obj.hasOwnProperty(key)) { Write(key); }
* }
*/
hasOwnProperty(v: string): boolean;
/**
* Returns a string representation of the object. An EXPLICIT call on a plain object returns "[object Object]". Object.prototype.toString.call(value) is the standard type-tag test (e.g. "[object Array]"). Implicit coercion does NOT go through this method in the SFMC engine: String({}) throws "Object reference not set to an instance of an object." and ("" + {}) yields "" — always call toString() explicitly, or use Platform.Function.Stringify(value).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/object-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var obj = {a: 1};
* Write(obj.toString()); // "[object Object]"
* Write(Object.prototype.toString.call([])); // "[object Array]"
*/
toString(): string;
/**
* Returns the primitive value of the object. For a plain object it returns the object itself.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/object-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var obj = {a: 1};
* Write(obj.valueOf() === obj); // true
*/
valueOf(): object;
}
interface Date {
/**
* Returns the four-digit year of the date according to local time.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date();
* Write(d.getFullYear()); // e.g. 2026
*/
getFullYear(): number;
/**
* Returns the month (0 = January … 11 = December) of the date according to local time.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(2026, 5, 1);
* Write(d.getMonth()); // 5 (June, 0-based)
*/
getMonth(): number;
/**
* Returns the day of the month (1–31) of the date according to local time.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(2026, 0, 15);
* Write(d.getDate()); // 15
*/
getDate(): number;
/**
* Returns the hour (0–23) of the date according to local time.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(2026, 0, 1, 13);
* Write(d.getHours()); // 13
*/
getHours(): number;
/**
* Returns the numeric timestamp (milliseconds since 1970-01-01T00:00:00 UTC) for the date.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(2021, 0, 1);
* Write(d.getTime()); // milliseconds since epoch
*/
getTime(): number;
/**
* Returns the difference, in minutes, between this date evaluated in UTC and in the host local time zone.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date();
* Write(d.getTimezoneOffset()); // minutes offset from UTC
*/
getTimezoneOffset(): number;
/**
* Returns the minutes (0–59) of the date according to local time.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date();
* Write(d.getMinutes());
*/
getMinutes(): number;
/**
* Returns the seconds (0–59) of the date according to local time.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date();
* Write(d.getSeconds());
*/
getSeconds(): number;
/**
* Returns the day of the week (0 = Sunday … 6 = Saturday) according to local time.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date();
* Write(d.getDay()); // 0–6
*/
getDay(): number;
/**
* Returns the milliseconds (0–999) of the date according to local time.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ⚠️ In the SFMC engine this is frequently off by one (e.g. a date constructed with 123 ms reports 122). Do not rely on millisecond precision; round or avoid sub-second comparisons.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies getMilliseconds() returns the exact milliseconds (0-999) of the Date. In the SFMC Jint engine it is frequently off by one: constructing a date with 123 ms reports 122, 555 reports 554, 666 reports 665. Some values (0, 111, 888, 999) are exact. Never rely on sub-second precision; round or avoid milliseconds.
* @example
* var d = new Date();
* Write(d.getMilliseconds()); // may be off by one in SFMC
*/
getMilliseconds(): number;
/**
* Returns a human-readable string representing the date.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.toString());
*/
toString(): string;
/**
* Returns the date portion of the date as a human-readable string.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.toDateString()); // "Wed, 31 Dec 1969" (locale-dependent)
*/
toDateString(): string;
/**
* Returns the date as a string using the UTC time zone.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.toUTCString()); // "Thu, 01 Jan 1970 00:00:00 UTC"
*/
toUTCString(): string;
/**
* Returns the primitive value of the date as the number of milliseconds since the Unix epoch.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.valueOf()); // 0
*/
valueOf(): number;
/**
* Returns the four-digit year of the date according to universal time (UTC).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.getUTCFullYear()); // 1970
*/
getUTCFullYear(): number;
/**
* Returns the month (0 = January … 11 = December) of the date according to universal time (UTC).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.getUTCMonth()); // 0
*/
getUTCMonth(): number;
/**
* Returns the day of the month (1–31) of the date according to universal time (UTC).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.getUTCDate()); // 1
*/
getUTCDate(): number;
/**
* Returns the day of the week (0 = Sunday … 6 = Saturday) according to universal time (UTC).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.getUTCDay()); // 4 (Thursday)
*/
getUTCDay(): number;
/**
* Returns the hour (0–23) of the date according to universal time (UTC).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.getUTCHours()); // 0
*/
getUTCHours(): number;
/**
* Returns the minutes (0–59) of the date according to universal time (UTC).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.getUTCMinutes()); // 0
*/
getUTCMinutes(): number;
/**
* Returns the seconds (0–59) of the date according to universal time (UTC).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.getUTCSeconds()); // 0
*/
getUTCSeconds(): number;
/**
* Returns the milliseconds (0–999) of the date according to universal time (UTC).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.getUTCMilliseconds()); // 0
*/
getUTCMilliseconds(): number;
/**
* Returns the time portion of the date as a human-readable string.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var d = new Date(0);
* Write(d.toTimeString());
*/
toTimeString(): string;
/**
* Returns the date portion as a string. Runtime-verified in SFMC: the locale argument is ignored and a fixed English-style format is returned (e.g. "Wed, 15 Jan 2020"). Use AMPscript FormatDate via Platform.Function.TreatAsContent for locale-aware output.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ⚠️ The locale argument is ignored — output is a fixed English format like "Wed, 15 Jan 2020", not locale-specific.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN specifies locale-aware date formatting; the SFMC Jint engine ignores the locale/options arguments and returns a fixed English-style string (e.g. "Wed, 15 Jan 2020").
* @param locales - Ignored in SFMC
* @param options - Ignored in SFMC
* @example
* var d = new Date(2020, 0, 15);
* Write(d.toLocaleDateString()); // "Wed, 15 Jan 2020" (locale ignored)
*/
toLocaleDateString(locales?: string, options?: object): string;
}
declare namespace Math {
/**
* Returns the absolute value of a number.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - A number
* @example
* Write(Math.abs(-5)); // 5
*/
function abs(x: number): number;
/**
* Rounds a number up to the next integer.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - A number
* @example
* Write(Math.ceil(4.1)); // 5
*/
function ceil(x: number): number;
/**
* Rounds a number down to the nearest integer.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - A number
* @example
* Write(Math.floor(4.9)); // 4
*/
function floor(x: number): number;
/**
* Returns the largest of the supplied numbers.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ⚠️ The variadic form throws in the SFMC engine when passed 3+ arguments. With fewer than two arguments it does not throw: every missing argument is supplied as 0, so Math.max(x) behaves as Math.max(x, 0) — Math.max(-7) returns 0 instead of -7 — and the no-argument Math.max() returns 0 instead of -Infinity. Always pass exactly two values; compare two at a time, e.g. Math.max(Math.max(a, b), c), or fold with a loop.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param values - Numbers to compare (variadic)
* @example
* Write(Math.max(1, 5)); // 5
*/
function max(...values: number[]): number;
/**
* Returns the smallest of the supplied numbers.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ⚠️ The variadic form throws in the SFMC engine when passed 3+ arguments. With fewer than two arguments it does not throw: every missing argument is supplied as 0, so Math.min(x) behaves as Math.min(x, 0) — Math.min(5) returns 0 instead of 5 — and the no-argument Math.min() returns 0 instead of +Infinity. Always pass exactly two values; compare two at a time, e.g. Math.min(Math.min(a, b), c), or fold with a loop.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param values - Numbers to compare (variadic)
* @example
* Write(Math.min(1, 5)); // 1
*/
function min(...values: number[]): number;
/**
* Returns the base raised to the exponent power.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param base - The base number
* @param exponent - The exponent
* @example
* Write(Math.pow(2, 10)); // 1024
*/
function pow(base: number, exponent: number): number;
/**
* Returns a pseudo-random floating-point number in [0, 1).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var r = Math.random();
* Write(Math.floor(r * 100)); // random 0–99
*/
function random(): number;
/**
* Rounds a number to the nearest integer.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - A number
* @example
* Write(Math.round(4.5)); // 5
*/
function round(x: number): number;
/**
* Returns the square root of a number.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - A non-negative number
* @example
* Write(Math.sqrt(16)); // 4
*/
function sqrt(x: number): number;
/**
* Returns the sine of an angle given in radians.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - Angle in radians
* @example
* Write(Math.sin(Math.PI / 2)); // 1
*/
function sin(x: number): number;
/**
* Returns the cosine of an angle given in radians.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - Angle in radians
* @example
* Write(Math.cos(0)); // 1
*/
function cos(x: number): number;
/**
* Returns the tangent of an angle given in radians.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - Angle in radians
* @example
* Write(Math.tan(Math.PI / 4)); // ~1
*/
function tan(x: number): number;
/**
* Returns the arc sine (in radians) of a number in the range [-1, 1].
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - A number between -1 and 1
* @example
* Write(Math.asin(1)); // ~1.5708 (π/2)
*/
function asin(x: number): number;
/**
* Returns the arc cosine (in radians) of a number in the range [-1, 1].
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - A number between -1 and 1
* @example
* Write(Math.acos(1)); // 0
*/
function acos(x: number): number;
/**
* Returns the arc tangent (in radians) of a number.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - A number
* @example
* Write(Math.atan(1)); // ~0.7854 (π/4)
*/
function atan(x: number): number;
/**
* Returns the angle (in radians) from the positive x-axis to the point (x, y). Unlike atan, atan2 correctly handles all quadrants.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param y - Y coordinate
* @param x - X coordinate
* @example
* Write(Math.atan2(1, 1)); // ~0.7854 (π/4)
*/
function atan2(y: number, x: number): number;
/**
* Returns e raised to the power of x (e^x).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - The exponent
* @example
* Write(Math.exp(1)); // ~2.71828 (e)
*/
function exp(x: number): number;
/**
* Returns the natural logarithm (base e) of a number.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param x - A positive number
* @example
* Write(Math.log(Math.E)); // 1
*/
function log(x: number): number;
/**
* The ratio of a circle's circumference to its diameter (~3.14159).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var area = Math.PI * r * r;
*/
const PI: number;
/**
* Euler's number, the base of the natural logarithm (~2.71828).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* Write(Math.E); // ~2.71828
*/
const E: number;
/**
* The natural logarithm of 2 (~0.69315).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* Write(Math.LN2); // ~0.693
*/
const LN2: number;
/**
* The natural logarithm of 10 (~2.30259).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* Write(Math.LN10); // ~2.303
*/
const LN10: number;
/**
* The base-2 logarithm of e (~1.44270).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* Write(Math.LOG2E); // ~1.443
*/
const LOG2E: number;
/**
* The square root of 2 (~1.41421).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* Write(Math.SQRT2); // ~1.414
*/
const SQRT2: number;
/**
* The square root of 1/2 (~0.70711); equivalent to 1/Math.SQRT2.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/math/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* Write(Math.SQRT1_2); // ~0.707
*/
const SQRT1_2: number;
}
interface RegExp {
/**
* Tests whether the string matches the pattern. Returns true if the pattern is found, false otherwise. When the g flag is set, successive calls advance lastIndex.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/regular-expressions/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param string - The string to test against the regular expression
* @example
* var emailRe = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
* if (emailRe.test(subscriberEmail)) {
* Write("Valid email");
* }
*/
test(string: string): boolean;
/**
* Executes a search for a match in the string. Returns an array with the full match at index 0 and any capture groups at subsequent indices, or null if no match is found. The array also has index and input properties. When the g flag is set, successive calls advance lastIndex.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/regular-expressions/)
*
* @remarks ⚠️ In the SFMC engine capture groups are broken: result[0] (the full match), result.index, and result.input work, but result[1], result[2], … are undefined. result.length is always 3 regardless of group count, so it cannot be used to count captures. Likewise the g-flag lastIndex does not advance between calls. Use the full match plus String.split/substring to extract sub-parts instead of capture groups.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies exec() returns an array whose capture groups occupy result[1], result[2], ... and, with the g flag, advances lastIndex so a while-loop can iterate all matches. In the SFMC Jint engine result[0] (full match), result.index and result.input work, but capture groups result[1]+ are always undefined, result.length is always 3 regardless of group count, and lastIndex never advances (the g-flag exec loop never terminates). Use String.match(/.../g) to collect matches and non-global String.match to read capture groups.
* @param string - The string to search
* @example
* var re = /\d{4}-\d{2}-\d{2}/;
* var result = re.exec("Order placed on 2026-01-15");
* if (result) {
* Write("Match: " + result[0]); // "2026-01-15" (capture groups result[1]+ are broken)
* }
*/
exec(string: string): any[];
/**
* The text of the pattern, excluding the enclosing slashes and any flags.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/regular-expressions/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var re = /hello/gi;
* Write(re.source); // "hello"
*/
readonly source: string;
/**
* True if the g (global) flag was specified when creating the regular expression.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/regular-expressions/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* var re = /hello/g;
* Write(re.global); // true
*/
readonly global: boolean;
/**
* The index at which to start the next match. Only relevant when the g or y flag is set. Automatically updated by exec() and test().
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/regular-expressions/)
*
* @remarks ⚠️ In the SFMC engine lastIndex does NOT advance after exec()/test() with the g flag, so it cannot be used to iterate matches. Setting lastIndex manually is also ignored — the next exec() still matches from the start. Use String.match(/.../g) to get all matches at once instead.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies lastIndex is updated by exec()/test() when the g (or y) flag is set, enabling stateful iteration. In the SFMC Jint engine lastIndex NEVER advances after exec()/test() with the g flag (stays 0), and setting it manually is ignored (the next exec still matches from the start). Use String.match(/.../g) to get all matches at once.
* @example
* var re = /\d+/g;
* re.exec("abc 123 def 456");
* Write(re.lastIndex); // does not advance in SFMC
*/
readonly lastIndex: number;
}
interface Function {
(...args: any[]): any;
/**
* Calls the function with a given `this` value and arguments provided individually.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/function-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param thisArg - The value to use as `this` when calling the function
* @param arg - Argument passed to the function (repeat for multiple)
* @example
* function greet(greeting) { return greeting + ", " + this.name; }
* var r = greet.call({ name: "Sam" }, "Hi"); // "Hi, Sam"
*/
call(thisArg: any, ...args: any[]): any;
/**
* Calls the function with a given `this` value and arguments provided as an array.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/function-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param thisArg - The value to use as `this` when calling the function
* @param argsArray - Array of arguments to pass to the function
* @example
* function sum(a, b) { return a + b; }
* var r = sum.apply(null, [2, 3]); // 5
*/
apply(thisArg: any, argsArray?: any[]): any;
/**
* Returns a string representing the function. In the SFMC engine this returns the generic "[object Function]" tag, NOT the function source code the spec produces.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/function-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: unlike standard JavaScript (which returns the function source), fn.toString() returns the generic "[object Function]" object tag in the SFMC Jint engine. String(fn) / ("" + fn) yield "function" instead. Do not rely on function source introspection.
* @example
* function greet() {}
* Write(greet.toString()); // "[object Function]" in SFMC (not the source)
*/
toString(): string;
}
// Global ECMAScript functions
/**
* Parses a string and returns an integer in the specified radix (base). Leading whitespace is ignored. Returns NaN if no valid integer is found. Always specify a radix to avoid octal/hex ambiguity.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
*
* @remarks ⚠️ Unlike the spec, the SFMC engine returns NaN when the string has trailing non-numeric characters (e.g. parseInt("10px", 10) is NaN, not 10). Strip non-digits before parsing.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies the global parseInt(str[, radix]) parses the leading numeric portion and ignores trailing non-numeric characters (parseInt("10px", 10) is 10). In the SFMC Jint engine a string with trailing non-numeric characters returns NaN (parseInt("10px", 10) is NaN). Radix parsing otherwise follows the spec. Strip non-digits before parsing.
* @param string - The string to parse
* @param radix - Base of the numeral system (2–36); use 10 for decimal
* @example
* Write(parseInt("42", 10)); // 42
* Write(parseInt("abc", 10)); // NaN
* Write(parseInt("10px", 10)); // NaN in SFMC (spec would give 10)
*/
declare function parseInt(string: string, radix?: number): number;
/**
* Parses a string and returns a floating-point number. Stops parsing at the first character that is not part of a valid number. Returns NaN if no valid number is found.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat)
*
* @remarks ⚠️ Unlike the spec, the SFMC engine returns NaN when the string has trailing non-numeric characters (e.g. parseFloat("1.5kg") is NaN, not 1.5). Also note the returned value uses 32-bit float precision (parseFloat("3.14") === 3.14 is false); compare with a tolerance.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies the global parseFloat(str) parses the leading numeric portion and ignores trailing non-numeric characters. In the SFMC Jint engine a string with trailing non-numeric characters returns NaN (parseFloat("1.5kg") is NaN), and results use 32-bit precision (parseFloat("3.14") is 3.14000010490417, so parseFloat("3.14") === 3.14 is false). Compare parsed floats with a tolerance, never with ===.
* @param string - The string to parse
* @example
* Write(parseFloat("3.14")); // 3.14 (32-bit precision)
* Write(parseFloat("abc")); // NaN
* Write(parseFloat("1.5kg")); // NaN in SFMC (spec would give 1.5)
*/
declare function parseFloat(string: string): number;
/**
* Returns true if the value is NaN (Not-a-Number) after applying ToNumber conversion. Use this to guard against failed parseInt/parseFloat calls.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param value - Value to test
* @example
* Write(isNaN(NaN)); // true
* Write(isNaN(parseInt("abc", 10))); // true
* Write(isNaN(42)); // false
*/
declare function isNaN(value: any): boolean;
/**
* Returns true if the value is a finite number (not NaN, +Infinity, or -Infinity) after applying ToNumber conversion.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
*
* @remarks ⚠️ Unlike the spec, the SFMC engine returns true for a non-numeric string (isFinite("abc") and isFinite(Number("abc")) are both true). isFinite(NaN) itself is correct, and isFinite("") / isFinite(null) returning true is spec-correct. Test untrusted values with isNaN(Number(value)) instead.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies the global isFinite(value) applies ToNumber first and returns false when the conversion yields NaN, so isFinite("abc") is false. In the SFMC Jint engine a non-numeric string returns true — isFinite("abc") and isFinite(Number("abc")) are both true. isFinite(NaN), isFinite(undefined), isFinite(0/0) and isFinite(Infinity) are spec-correct (false). isFinite("") and isFinite(null) also return true, but that matches MDN, where ToNumber("") and ToNumber(null) are both 0. Coerce with Number() and test the result with isNaN() before relying on isFinite for an untrusted value.
* @param value - Value to test
* @example
* Write(isFinite(42)); // true
* Write(isFinite(1 / 0)); // false (Infinity)
* Write(isFinite(NaN)); // false
* Write(isFinite("abc")); // true in SFMC (spec would give false)
*/
declare function isFinite(value: any): boolean;
/**
* Parses a string of JavaScript source and executes it as a script, returning the completion value of the last evaluated expression (or undefined when there is nothing to complete). A non-string argument is returned unchanged. Runtime-verified to work in SFMC SSJS: direct eval sees the surrounding local scope, and bare-name Core globals loaded via Platform.Load are visible inside the evaluated string. Use sparingly — it runs arbitrary code and is a common injection risk; prefer Platform.Function.ParseJSON for parsing data.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param script - A string of JavaScript source to evaluate
* @example
* Write(eval("1 + 1")); // 2
* var x = 5;
* Write(eval("x + 10")); // 15
* Platform.Load("core","1.1.5");
* Write(eval("Stringify({a:1})")); // {"a":1}
*/
declare function eval(script: string): any;
/**
* Encodes a complete URI, leaving reserved characters (/ ? : @ & = + $ #) intact. Runtime-verified to work in SFMC SSJS, but the Jint engine encodes a space as "+" (not "%20") and emits lowercase hex escapes.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI)
*
* @remarks ⚠️ Space is encoded as "+" instead of "%20", and percent-escapes use lowercase hex, unlike the ECMAScript spec.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN specifies encodeURI encodes a space as "%20" with uppercase hex; the SFMC Jint engine encodes a space as "+" and emits lowercase hex escapes.
* @param uri - The URI string to encode
* @example
* Write(encodeURI("a b/c?d=1")); // "a+b/c?d=1" in SFMC (spec: "a%20b/c?d=1")
*/
declare function encodeURI(uri: string): string;
/**
* Encodes a URI component, escaping reserved characters as well. Runtime-verified to work in SFMC SSJS, but the Jint engine encodes a space as "+" (not "%20") and emits lowercase hex escapes (e.g. "/" becomes "%2f", not "%2F").
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
*
* @remarks ⚠️ Space -> "+" and lowercase hex (e.g. "/" -> "%2f") instead of the spec's "%20" / "%2F".
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN specifies a space encodes as "%20" with uppercase hex; the SFMC Jint engine encodes a space as "+" and emits lowercase hex (e.g. "/" -> "%2f").
* @param str - The component string to encode
* @example
* Write(encodeURIComponent("a b/c")); // "a+b%2fc" in SFMC (spec: "a%20b%2Fc")
*/
declare function encodeURIComponent(str: string): string;
/**
* Decodes a URI previously encoded by encodeURI, converting percent-escapes back to their characters. Runtime-verified to work in SFMC SSJS, but the Jint engine also decodes escapes for the URI-syntax characters the spec preserves, and turns a literal "+" into a space — making it behave like decodeURIComponent.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI)
*
* @remarks ⚠️ Escapes for the reserved set ; / ? : @ & = + $ , # are decoded (the spec preserves them), and a literal "+" becomes a space.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN specifies decodeURI leaves escapes for ; / ? : @ & = + $ , # intact and leaves a literal "+" unchanged; the SFMC Jint engine decodes those escapes and turns "+" into a space, so it is indistinguishable from decodeURIComponent.
* @param uri - The encoded URI string to decode
* @example
* Write(decodeURI("a%20b/c")); // "a b/c"
* Write(decodeURI("%2F")); // "/" in SFMC (spec: "%2F")
* Write(decodeURI("a+b")); // "a b" in SFMC (spec: "a+b")
*/
declare function decodeURI(uri: string): string;
/**
* Decodes a URI component previously encoded by encodeURIComponent, converting all percent-escapes back to characters. Runtime-verified to work in SFMC SSJS, but the Jint engine decodes a literal "+" to a space (form-urlencoded behaviour), unlike the spec.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)
*
* @remarks ⚠️ A literal "+" is decoded to a space, unlike the ECMAScript spec (which leaves it).
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN specifies decodeURIComponent leaves a literal "+" unchanged; the SFMC Jint engine decodes "+" to a space, matching application/x-www-form-urlencoded.
* @param str - The encoded component string to decode
* @example
* Write(decodeURIComponent("a%20b%2Fc")); // "a b/c"
* Write(decodeURIComponent("+")); // " " in SFMC (spec: "+")
*/
declare function decodeURIComponent(str: string): string;
// ── Constructible built-ins (value + constructor declarations) ───────────────
interface Error {
message?: string;
name: string;
description?: string;
}
interface ErrorConstructor {
/**
* The base Error constructor works in SSJS. Prefer throw new Error(message) and recover the text with String(e) in catch — reading e.message after new Error(...) is undefined in this engine.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN stores new Error(message) in .message. In SFMC Jint, new Error("msg") leaves .message undefined (not own); recover with String(e)/(""+e). Call-form Error("msg") and engine-raised errors DO set .message (engine-raised also set .description). .name works; .stack is unavailable; instanceof Error is always false (use .name / constructor === Error / String(e)).
* @param message - A human-readable description of the error
* @example
* try {
* throw new Error("Something failed");
* } catch (e) {
* Write(String(e)); // "Something failed" (e.message is undefined after new Error)
* }
*/
new (message?: string): Error;
/**
* The base Error constructor works in SSJS. Prefer throw new Error(message) and recover the text with String(e) in catch — reading e.message after new Error(...) is undefined in this engine.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN stores new Error(message) in .message. In SFMC Jint, new Error("msg") leaves .message undefined (not own); recover with String(e)/(""+e). Call-form Error("msg") and engine-raised errors DO set .message (engine-raised also set .description). .name works; .stack is unavailable; instanceof Error is always false (use .name / constructor === Error / String(e)).
* @param message - A human-readable description of the error
* @example
* try {
* throw new Error("Something failed");
* } catch (e) {
* Write(String(e)); // "Something failed" (e.message is undefined after new Error)
* }
*/
(message?: string): Error;
readonly prototype: Error;
}
declare var Error: ErrorConstructor;
interface EvalError {
message?: string;
name: string;
description?: string;
}
interface EvalErrorConstructor {
/**
* The EvalError subtype constructor is present in SSJS. It creates an error object you can throw and catch, though the engine itself rarely raises it.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new EvalError("msg") leaves .message undefined (recover via String(e)); EvalError("msg") call-form sets .message; instanceof EvalError/Error is false.
* @param message - A human-readable description of the error
* @example
* throw new EvalError("bad eval");
*/
new (message?: string): EvalError;
/**
* The EvalError subtype constructor is present in SSJS. It creates an error object you can throw and catch, though the engine itself rarely raises it.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new EvalError("msg") leaves .message undefined (recover via String(e)); EvalError("msg") call-form sets .message; instanceof EvalError/Error is false.
* @param message - A human-readable description of the error
* @example
* throw new EvalError("bad eval");
*/
(message?: string): EvalError;
readonly prototype: EvalError;
}
declare var EvalError: EvalErrorConstructor;
interface RangeError {
message?: string;
name: string;
description?: string;
}
interface RangeErrorConstructor {
/**
* The RangeError subtype constructor is present in SSJS. It signals that a value is outside the allowed range and can be thrown and caught.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new RangeError("msg") leaves .message undefined (recover via String(e)); RangeError("msg") call-form sets .message; instanceof RangeError/Error is false.
* @param message - A human-readable description of the error
* @example
* throw new RangeError("value out of range");
*/
new (message?: string): RangeError;
/**
* The RangeError subtype constructor is present in SSJS. It signals that a value is outside the allowed range and can be thrown and caught.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new RangeError("msg") leaves .message undefined (recover via String(e)); RangeError("msg") call-form sets .message; instanceof RangeError/Error is false.
* @param message - A human-readable description of the error
* @example
* throw new RangeError("value out of range");
*/
(message?: string): RangeError;
readonly prototype: RangeError;
}
declare var RangeError: RangeErrorConstructor;
interface ReferenceError {
message?: string;
name: string;
description?: string;
}
interface ReferenceErrorConstructor {
/**
* The ReferenceError subtype constructor is present in SSJS. It signals a reference to an undeclared variable and can be thrown and caught.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new ReferenceError("msg") leaves .message undefined (recover via String(e)); ReferenceError("msg") call-form sets .message; instanceof ReferenceError/Error is false.
* @param message - A human-readable description of the error
* @example
* throw new ReferenceError("undeclared variable");
*/
new (message?: string): ReferenceError;
/**
* The ReferenceError subtype constructor is present in SSJS. It signals a reference to an undeclared variable and can be thrown and caught.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new ReferenceError("msg") leaves .message undefined (recover via String(e)); ReferenceError("msg") call-form sets .message; instanceof ReferenceError/Error is false.
* @param message - A human-readable description of the error
* @example
* throw new ReferenceError("undeclared variable");
*/
(message?: string): ReferenceError;
readonly prototype: ReferenceError;
}
declare var ReferenceError: ReferenceErrorConstructor;
interface SyntaxError {
message?: string;
name: string;
description?: string;
}
interface SyntaxErrorConstructor {
/**
* The SyntaxError subtype constructor is present in SSJS. It signals a syntax problem and can be thrown and caught.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new SyntaxError("msg") leaves .message undefined (recover via String(e)); SyntaxError("msg") call-form sets .message; instanceof SyntaxError/Error is false.
* @param message - A human-readable description of the error
* @example
* throw new SyntaxError("invalid syntax");
*/
new (message?: string): SyntaxError;
/**
* The SyntaxError subtype constructor is present in SSJS. It signals a syntax problem and can be thrown and caught.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new SyntaxError("msg") leaves .message undefined (recover via String(e)); SyntaxError("msg") call-form sets .message; instanceof SyntaxError/Error is false.
* @param message - A human-readable description of the error
* @example
* throw new SyntaxError("invalid syntax");
*/
(message?: string): SyntaxError;
readonly prototype: SyntaxError;
}
declare var SyntaxError: SyntaxErrorConstructor;
interface TypeError {
message?: string;
name: string;
description?: string;
}
interface TypeErrorConstructor {
/**
* The TypeError subtype constructor is present in SSJS. It signals that a value is not of the expected type and can be thrown and caught.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new TypeError("msg") leaves .message undefined (recover via String(e)); TypeError("msg") call-form sets .message; instanceof TypeError/Error is false. Engine-raised TypeErrors (e.g. bad Platform.Function arity) do set .message and .description.
* @param message - A human-readable description of the error
* @example
* throw new TypeError("expected a string");
*/
new (message?: string): TypeError;
/**
* The TypeError subtype constructor is present in SSJS. It signals that a value is not of the expected type and can be thrown and caught.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new TypeError("msg") leaves .message undefined (recover via String(e)); TypeError("msg") call-form sets .message; instanceof TypeError/Error is false. Engine-raised TypeErrors (e.g. bad Platform.Function arity) do set .message and .description.
* @param message - A human-readable description of the error
* @example
* throw new TypeError("expected a string");
*/
(message?: string): TypeError;
readonly prototype: TypeError;
}
declare var TypeError: TypeErrorConstructor;
interface URIError {
message?: string;
name: string;
description?: string;
}
interface URIErrorConstructor {
/**
* The URIError subtype constructor is present in SSJS. It signals malformed URI handling and can be thrown and caught.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new URIError("msg") leaves .message undefined (recover via String(e)); URIError("msg") call-form sets .message; instanceof URIError/Error is false.
* @param message - A human-readable description of the error
* @example
* throw new URIError("malformed URI");
*/
new (message?: string): URIError;
/**
* The URIError subtype constructor is present in SSJS. It signals malformed URI handling and can be thrown and caught.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Same shape quirks as Error: new URIError("msg") leaves .message undefined (recover via String(e)); URIError("msg") call-form sets .message; instanceof URIError/Error is false.
* @param message - A human-readable description of the error
* @example
* throw new URIError("malformed URI");
*/
(message?: string): URIError;
readonly prototype: URIError;
}
declare var URIError: URIErrorConstructor;
interface StringConstructor {
new (value?: any): String;
(value?: any): string;
fromCharCode(code: number, ...args: number[]): string;
readonly prototype: String;
}
declare var String: StringConstructor;
interface ArrayConstructor {
new (arrayLength?: number): any[];
(arrayLength?: number): any[];
readonly prototype: any[];
}
declare var Array: ArrayConstructor;
interface NumberConstructor {
new (value?: any): Number;
(value?: any): number;
/**
* The largest positive finite value representable by a Number. Runtime-verified present in SFMC (typeof number). The value is correct (~1.7976931348623157e308) but note the sibling constants MIN_VALUE and the INFINITY constants are broken in this engine.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @example
* Write(Number.MAX_VALUE > 0); // true
*/
readonly MAX_VALUE: number;
/**
* Standard ES3 exposes the smallest positive representable Number (~5e-324). Runtime-verified present in SFMC (typeof number) but WRONG: the SFMC Jint engine returns the negative of MAX_VALUE (-1.7976931348623157e308) instead, so Number.MIN_VALUE > 0 is false. Use the literal 5e-324 if you need the true smallest positive value.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ⚠️ Broken in SFMC: Number.MIN_VALUE returns -MAX_VALUE (a large negative number), not the ES3 smallest-positive value 5e-324. Number.MIN_VALUE > 0 is false. Use the literal 5e-324.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN/ES3 define Number.MIN_VALUE as the smallest positive value (~5e-324); the SFMC Jint engine instead returns -Number.MAX_VALUE, so it is negative and MIN_VALUE > 0 evaluates to false.
* @example
* Write(Number.MIN_VALUE > 0); // false (returns -MAX_VALUE in SFMC)
*/
readonly MIN_VALUE: number;
/**
* The Not-a-Number value. Runtime-verified present in SFMC (typeof number); NaN !== NaN holds as expected. Note it stringifies as lowercase "nan" (not "NaN") in this engine.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ⚠️ Stringifies as lowercase "nan" in SFMC (String(Number.NaN) === "nan"), unlike the standard "NaN". The value still compares as not-equal to itself.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: the value is present and behaves as NaN for comparisons, but String(Number.NaN) yields lowercase "nan" instead of the standard "NaN".
* @example
* Write(Number.NaN !== Number.NaN); // true
*/
readonly NaN: number;
/**
* Standard ES3 exposes positive infinity. Runtime-verified present in SFMC (typeof number) but BROKEN: it stringifies as "-infinity" and Number.POSITIVE_INFINITY > 0 is false. The global Infinity is equally unreliable in this engine.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ⚠️ Broken in SFMC: Number.POSITIVE_INFINITY stringifies as "-infinity" and Number.POSITIVE_INFINITY > 0 is false (sign inverted). Avoid infinity constants; guard with explicit finite bounds instead.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN defines this as +Infinity; the SFMC Jint engine returns a value that stringifies as "-infinity" and for which > 0 is false (sign inverted). The global Infinity is likewise unreliable.
* @example
* Write(Number.POSITIVE_INFINITY > 0); // false (sign inverted in SFMC)
*/
readonly POSITIVE_INFINITY: number;
/**
* Standard ES3 exposes negative infinity. Runtime-verified present in SFMC (typeof number) but BROKEN: it stringifies as "infinity" and Number.NEGATIVE_INFINITY < 0 is false (sign inverted).
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/number-methods/)
*
* @remarks ⚠️ Broken in SFMC: Number.NEGATIVE_INFINITY stringifies as "infinity" and Number.NEGATIVE_INFINITY < 0 is false (sign inverted). Avoid infinity constants; guard with explicit finite bounds instead.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN defines this as -Infinity; the SFMC Jint engine returns a value that stringifies as "infinity" and for which < 0 is false (sign inverted).
* @example
* Write(Number.NEGATIVE_INFINITY < 0); // false (sign inverted in SFMC)
*/
readonly NEGATIVE_INFINITY: number;
readonly prototype: Number;
}
declare var Number: NumberConstructor;
interface BooleanConstructor {
/**
* new Boolean(value) creates a boxed Boolean object (typeof "object"). Almost every observable behaviour deviates from the spec in the SFMC engine — prefer Boolean(value) or !!value.
*
* @remarks ⚠️ A boxed Boolean stringifies capitalized ("True"/"False"), a boxed false is falsy in a condition, valueOf() returns the boxed object instead of the primitive, and instanceof Boolean is false. There is no reliable way to unwrap one — do not create it.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN specifies a boxed Boolean stringifies to lowercase "true"/"false", is always truthy (it is an object), unwraps via valueOf() and satisfies instanceof Boolean. The SFMC Jint engine breaks all four — String(new Boolean(true)) is "True", new Boolean(false) is falsy, valueOf() returns the boxed object itself (box.valueOf() === box), and instanceof Boolean is false although constructor === Boolean is true.
* @param value - The value to box as a Boolean object
* @example
* var b = new Boolean(false);
* Write(String(b)); // "False" in SFMC (spec: "false")
* if (b) { Write("not reached in SFMC"); } // boxed false is falsy here
* Write(typeof b.valueOf()); // "object" in SFMC (spec: "boolean")
*/
new (value?: any): Boolean;
/**
* Called as a plain function, Boolean(value) returns a primitive boolean reflecting the value truthiness.
*
* @remarks ⚠️ The SFMC engine treats a number as truthy only when it is greater than zero, so Boolean(-1) is false. Boolean([]) is also false. The returned primitive is not auto-boxed — Boolean(1).toString() throws "Object expected"; use String(value) instead.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. Runtime-verified: MDN specifies falsy is limited to false/0/-0/""/null/undefined/NaN and that every object is truthy. The SFMC Jint engine coerces numbers with the rule n > 0, so Boolean(-1) and Boolean(-0.5) are false; Boolean([]) is false (ToPrimitive yields ""), while Boolean([0]) is true; and the primitive result is not auto-boxed, so Boolean(1).toString() and Boolean(1).valueOf() throw "Object expected".
* @param value - The value to coerce to a boolean
* @example
* Write(Boolean(1)); // true
* Write(Boolean("")); // false
* Write(Boolean(-1)); // false in SFMC (spec: true)
* Write(Boolean([])); // false in SFMC (spec: true)
*/
(value?: any): boolean;
readonly prototype: Boolean;
}
declare var Boolean: BooleanConstructor;
interface ObjectConstructor {
new (value?: any): Object;
(value?: any): object;
/**
* Defines a new property on an object, or modifies an existing one, with the given descriptor.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/object-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param obj - The object on which to define the property
* @param prop - The name of the property to define
* @param descriptor - Property descriptor (value, enumerable, writable, configurable, get, set)
* @example
* var o = {};
* Object.defineProperty(o, "x", { value: 42, enumerable: true });
* Write(o.x); // 42
*/
defineProperty(obj: object, prop: string, descriptor: object): object;
/**
* Returns the prototype (internal [[Prototype]]) of the specified object. Runtime-verified working in SFMC SSJS.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/object-methods/)
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param obj - The object whose prototype to return
* @example
* var proto = Object.getPrototypeOf({ a: 1 }); // returns the object prototype
*/
getPrototypeOf(obj: object): object;
readonly prototype: Object;
}
declare var Object: ObjectConstructor;
interface DateConstructor {
new (valueOrYear?: any, month?: number, day?: number, hours?: number, minutes?: number, seconds?: number, milliseconds?: number): Date;
(): string;
/**
* Returns the number of milliseconds since the Unix epoch for the given UTC date components.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ⚠️ Runtime-verified: with year + month (and beyond) it returns the correct UTC timestamp, but the year-only form Date.UTC(2026) returns a nonsense small number (observed -21597974) instead of treating the month as 0 — always pass at least year and month, e.g. Date.UTC(2026, 0, 1).
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies Date.UTC(year[, month...]) accepts a year-only call. In the SFMC Jint engine the year-only form Date.UTC(2026) returns a nonsense small number (observed -21597974) rather than a valid timestamp or NaN. Always pass at least year and month, e.g. Date.UTC(2026, 0, 1); with two or more components it returns the correct UTC timestamp.
* @param year - Full year
* @param month - Month (0–11)
* @param day - Day of the month (1–31)
* @param hours - Hours (0–23)
* @param minutes - Minutes (0–59)
* @param seconds - Seconds (0–59)
* @param milliseconds - Milliseconds (0–999)
* @example
* Write(Date.UTC(1970, 0, 1)); // 0
*/
UTC(year: number, month?: number, day?: number, hours?: number, minutes?: number, seconds?: number, milliseconds?: number): number;
/**
* Parses a date string and returns the numeric timestamp (milliseconds since the Unix epoch). In the SFMC engine an unparseable string returns 0 (the epoch), NOT NaN as the spec requires.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ⚠️ Runtime-verified: unlike the spec, an unparseable or invalid string (e.g. "garbage", "", "2021-13-45") returns 0 — the Unix epoch — instead of NaN, so isNaN() cannot detect a bad date and invalid input silently becomes 1970-01-01. Also, a date-only ISO string such as "2026-06-18" is parsed as LOCAL midnight, not UTC (contrary to the ES5+ spec). Validate input yourself; do not rely on NaN for error detection.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies Date.parse(str) returns NaN for unparseable strings and treats date-only ISO forms as UTC. In the SFMC Jint engine invalid strings return 0 (the epoch), NEVER NaN, so isNaN() cannot detect a bad date; and date-only strings like "2026-06-18" parse as LOCAL midnight, not UTC. Validate input yourself before trusting the result.
* @param dateString - A date string (ISO 8601 is the most portable form)
* @example
* Write(Date.parse('2021-01-01T00:00:00Z')); // 1609459200000
*/
parse(dateString: string): number;
/**
* Returns the current time. In the SFMC engine this returns a Date OBJECT, not a numeric timestamp as the spec requires — coerce it (+Date.now() or new Date().getTime()) to get epoch milliseconds.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now) / [ssjs.guide reference](https://ssjs.guide/ecmascript-builtins/date-methods/)
*
* @remarks ⚠️ Runtime-verified: unlike the spec (which returns a Number), Date.now() returns a Date object (typeof "object") that stringifies to a date-time string. Numeric coercion (Date.now() + 0, Date.now() * 1) yields the epoch milliseconds, but code expecting a number will break. Prefer new Date().getTime(), which returns a clean number.
* @remarks ✅ Runtime-verified in a live SFMC test.
* @remarks ⚠️ Differs from the official Salesforce docs. MDN specifies Date.now() returns a Number (milliseconds since the Unix epoch). In the SFMC Jint engine it returns a Date OBJECT instead (typeof Date.now() is "object"). Numeric coercion (Date.now() + 0) recovers the epoch ms, but code expecting a plain number breaks. Prefer new Date().getTime() for a clean number.
* @example
* var ms = new Date().getTime(); // clean epoch milliseconds (Date.now() returns a Date object in SFMC)
*/
now(): object;
readonly prototype: Date;
}
declare var Date: DateConstructor;
interface RegExpConstructor {
/**
* Creates a regular expression object for pattern matching. Prefer the literal syntax (/pattern/flags) when the pattern is known at write time. Use the constructor when the pattern must be built dynamically at runtime.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param pattern - Regular expression pattern string
* @param flags - Optional flags: g (global), i (case-insensitive), m (multiline)
* @example
* var fieldName = "email";
* var re = new RegExp(fieldName + "=([^&]+)", "i");
* var match = queryString.match(re);
* if (match) { Write(match[1]); }
*/
new (pattern: string, flags?: string): RegExp;
/**
* Creates a regular expression object for pattern matching. Prefer the literal syntax (/pattern/flags) when the pattern is known at write time. Use the constructor when the pattern must be built dynamically at runtime.
*
* @remarks ✅ Runtime-verified in a live SFMC test.
* @param pattern - Regular expression pattern string
* @param flags - Optional flags: g (global), i (case-insensitive), m (multiline)
* @example
* var fieldName = "email";
* var re = new RegExp(fieldName + "=([^&]+)", "i");
* var match = queryString.match(re);
* if (match) { Write(match[1]); }
*/
(pattern: string, flags?: string): RegExp;
readonly prototype: RegExp;
}
declare var RegExp: RegExpConstructor;