What is your developer-dependent CMS actually costing you? Calculate your costs and get a full report
What is your developer-dependent CMS actually costing you? Calculate your costs and get a full report
SDKs
Learn how to update Agility Pages programmatically using JavaScript.
This page has moved โ the Management SDK is now documented elsewhere. The JavaScript and .NET guides have been merged into a single set with per-language code tabs. Read the current guide.
This guide covers page and page model operations using the Agility Management SDK, including creating, updating, publishing, and managing pages and templates.
Page Models are also referred to as Page Templates. We will use the terminology interchangeable here.
// Get the sitemap for a website and locale
const sitemap = await apiClient.pageMethods.getSitemap(
guid, // instance GUID
locale // locale (e.g., 'en-us')
);
console.log('Sitemap:', sitemap);
// Get all page templates
const pageTemplates = await apiClient.pageMethods.getPageTemplates(
guid, // instance GUID
locale, // locale
true, // includeModuleZones
'' // searchFilter (optional)
);
console.log('Page templates:', pageTemplates);
// Get a specific page template by ID
const pageTemplate = await apiClient.pageMethods.getPageTemplate(
guid,
locale,
pageTemplateId // template ID
);
console.log('Page template:', pageTemplate);
// Get a page template by name
const pageTemplateByName = await apiClient.pageMethods.getPageTemplateName(
guid,
locale,
'Home Page' // template name
);
console.log('Page template by name:', pageTemplateByName);
// Delete a page template by ID
await apiClient.pageMethods.deletePageTemplate(
guid,
locale,
pageTemplateId
);
console.log('Page template deleted.');
PageItemTemplate is the section where components can be added into a page model.
// Get item templates for a page template
const itemTemplates = await apiClient.pageMethods.getPageItemTemplates(
guid,
locale,
pageTemplateId
);
console.log('Item templates:', itemTemplates);
// Save (create or update) a page template
const savedPageTemplate = await apiClient.pageMethods.savePageTemplate(
guid,
locale,
pageModel // PageModel object
);
console.log('Saved page template:', savedPageTemplate);
A save replaces the template's zones with the contentSectionDefinitions list you send. Read the template with getPageTemplate, change what you need, and send the complete list back.
pageItemTemplateID: -1: the original zone is restored, with its placements. Re-adding a zone in Web Studio creates a new, empty zone instead.contentSectionDefinitions to null to leave the zones unchanged, for example when you only rename the template.pageItemTemplateID. Zones are matched by ID. A zone sent with -1 takes over an existing zone with the same reference name, unless another zone in the request already claims that zone by ID. Otherwise it's created as a new zone.defaultModules list replaces its default components, and an empty list ([]) removes them. Leave the key out to keep them. If you round-trip them, read the template with getPageTemplate: getPageItemTemplates always returns an empty defaultModules list.digitalChannelTypeID is optional. A new template defaults to Website (1), and an update keeps the template's current channel.// Get a page by its ID
const page = await apiClient.pageMethods.getPage(
pageID, // page ID
guid,
locale
);
console.log('Page:', page);
// Publish a page
const publishedPageIDs = await apiClient.pageMethods.publishPage(
pageID,
guid,
locale,
'Publishing page' // comments (optional)
);
console.log('Published page IDs:', publishedPageIDs);
// Unpublish a page
const unpublishedPageIDs = await apiClient.pageMethods.unPublishPage(
pageID,
guid,
locale,
'Unpublishing page' // comments (optional)
);
console.log('Unpublished page IDs:', unpublishedPageIDs);
// Delete a page
const deletedPageIDs = await apiClient.pageMethods.deletePage(
pageID,
guid,
locale,
'Deleting page' // comments (optional)
);
console.log('Deleted page IDs:', deletedPageIDs);
// Approve a page
const approvedPageIDs = await apiClient.pageMethods.approvePage(
pageID,
guid,
locale,
'Approving page' // comments (optional)
);
console.log('Approved page IDs:', approvedPageIDs);
// Decline a page
const declinedPageIDs = await apiClient.pageMethods.declinePage(
pageID,
guid,
locale,
'Declining page' // comments (optional)
);
console.log('Declined page IDs:', declinedPageIDs);
// Request approval for a page
const approvalRequestedPageIDs = await apiClient.pageMethods.pageRequestApproval(
pageID,
guid,
locale,
'Requesting approval' // comments (optional)
);
console.log('Approval requested for page IDs:', approvalRequestedPageIDs);
// Save (create or update) a page
const savedPageIDs = await apiClient.pageMethods.savePage(
pageItem, // PageItem object
guid,
locale,
parentPageID, // parent page ID (optional)
placeBeforePageItemID // place before page ID (optional)
);
console.log('Saved page IDs:', savedPageIDs);
// Get history for a page
const pageHistory = await apiClient.pageMethods.getPageHistory(
locale,
guid,
pageID,
50, // take (number of items)
0 // skip (offset)
);
console.log('Page history:', pageHistory);