Content Management JS SDK

Managing content from outside of the CMS has never been easier. The Content Management JS SDK allows developers to create/update, or apply workflow actions to content using our Content Management API.

Use Cases

  • Importing Content
  • Implementing custom Approval Workflows
  • Keeping content in-sync with other systems

Using the SDK with NPM (Node Package Manager)

When using the Content Management API you'll need to know a few things about your instance in order to authenticate your requests and setup your API client.

To create an instance of an an API client for the Agility Content Management REST API you will need the following:

Location - The geo-location of the API you wish to connect to (USA/Canada)

Website Name - The Website Name that identifies your Agility Instance, accessible from API Keys in Agility

Security Key - The Security Key used to authenticate your API requests, accessible from API Keys in Agility

Install the Agility Content Management JS SDK package into your project:

> npm install @agility/content-management

Import the SDK when you need to use it in your JavaScript file(s):

import agilityMgmt from '@agility/content-management'

Now you can create a API client to retrieve content from your Agility instance:

import agilityMgmt from '@agility/content-management'

const mgmtApi = agilityMgmt.getApi({
  location: 'USA',
  websiteName: 'MyWebsiteName',
  securityKey: 'xyz123'
});

Example:

#Set the contentItem structure
let contentItem = {
 contentID: -1,
 fields: {
  "Title": "Test Title",
  "Image": {
   "mediaID": 123,
   "label": "Test Image"
  }
 }
}

let languageCode = "en-us";
let referenceName = "MyReferenceName";

api.saveContentItem({
 contentItem,
 languageCode,
 referenceName
})
.then(function(contentID) {
 contentIDToWorkOn = contentID;
})
.catch(function(error) {
});

Next Steps

Expanded documentation covering all methods in this SDK can be found here.