SDK for core BLDR functionality
const bldrSDK = require('@basetime/bldr-sfmc-sdk')
// OR
Import { bldrSDK } from '@basetime/bldr-sfmc-sdk'
const authObject = {
client_id: 'xxxxxxxxxx',
client_secret: 'xxxxxxxxxx',
auth_url: 'https://xxxxxxxxxx-xxxxxxxxx.auth.marketingcloudapis.com/',
account_id: 'xxxxxxxxx'
}
const bldr = new bldrSDK(authObject)
const { sfmc } = bldr
Folder functionality is based on the DataFolder SOAP API object unless otherwise documented.
const request = await sfmc.folder.search({
contentType: 'asset',
searchKey: 'Name',
searchTerm: 'bldr-sfmc'
})
const request = await sfmc.folder.getFolder({
contentType: 'asset',
categoryId: 3134
})
const request = await sfmc.folder.getSubfolders({
contentType: 'dataextension',
parentId: 3134
})
const request = await sfmc.folder.createFolder({
contentType: 'dataextension';
name: 'new bldr folder';
parentId: 3134;
})
const request = await sfmc.folder._updateAllowChildren({
contentType: 'dataextension';
categoryId: 3134;
});
const request = await sfmc.asset.getByAssetId(8272);
const request = await sfmc.asset.getAssetByLegacyId(8272);
const request = await sfmc.asset.getAssetsByFolderArray([3134, 8373, 8727]);
const request = await sfmc.asset.getAssetByNameAndFolder({
assetName: 'bldr_api';
assetFolderName: 'ssjs_functions';
});
const request = await sfmc.asset.searchAsset({
searchKey: 'name';
searchTerm: 'bldr_api';
});
const request = await sfmc.asset.postAsset({
"name": "Asset Name",
"data": {
"email": {
"options": {
"characterEncoding": "utf-8"
}
}
},
"views": {
"html": {
"content": "<!DOCTYPE html>.....</html>"
}
},
"text": {},
"subjectline": {
"content": "%%First_Name%% this is my subject line"
},
"preheader": {
"content": "updated the preheader too!"
},
"assetType": {
"name": "htmlemail",
"id": 208
}
})
const request = await sfmc.asset.putAsset({
"name": "Asset Name",
"data": {
"email": {
"options": {
"characterEncoding": "utf-8"
}
}
},
"views": {
"html": {
"content": "<!DOCTYPE html>.....</html>"
}
},
"text": {},
"subjectline": {
"content": "%%First_Name%% this is my subject line"
},
"preheader": {
"content": "updated the preheader too!"
},
"assetType": {
"name": "htmlemail",
"id": 208
}
})
const request = await sfmc.asset.getImageData(3837)