See Agility CMS in action. Watch a product demo
Management SDK - Instance
Instance
Get Locales
//get the locales for a particular instance
var locales = await apiClient.instanceMethods.getLocales(guid)
console.log("Locales for Instance:");
console.log(locales);
Instance User
Get Users, Save User, Delete User
const users = await apiClient.instanceUserMethods.getUsers(guid);
const savedUser = await apiClient.instanceUserMethods.saveUser('user@example.com', [/* InstanceRole[] */], guid, 'First', 'Last');
const deletedUser = await apiClient.instanceUserMethods.deleteUser(1234, guid);Server User
Get Current User (Me)
//get the current user and all their instance access details
const user = await apiClient.serverUserMethods.me("");Webhooks
Get Webhook List, Get Webhook, Save Webhook, Delete Webhook, Get Webhook History, Rotate Webhook Secret. See the full Webhooks reference for the complete payload and options.
//list the webhooks for the instance
const webhooks = await apiClient.webhookMethods.webhookList(guid)
console.log("Webhooks for Instance:");
console.log(webhooks);
//get a specific webhook
const webhook = await apiClient.webhookMethods.getWebhook(guid, webhooks[0].id);
console.log("Webhook Details:");
console.log(webhook);
//create a new webhook - secure delivery and retries are optional and default to false
const newWebhook = await apiClient.webhookMethods.saveWebhook(guid, {
name: "My New Webhook",
url: "https://example.com/webhook",
contentPublishEvents: true,
contentSaveEvents: true,
contentWorkflowEvents: true,
enabled: true,
instanceGuid: guid,
secureDeliveryEnabled: true,
retriesEnabled: true,
retryCount: 3,
retrySpeed: "standard",
});
//the signing secret is returned once, on the save that mints it
if (newWebhook.signingSecretJustCreated) {
console.log("Store this secret:", newWebhook.signingSecret);
}
//read recent delivery attempts (newest first, last 7 days by default)
const history = await apiClient.webhookMethods.getWebhookHistory(guid, newWebhook.id, { take: 50 });
console.log(history.items);
//roll the signing secret - the previous one keeps signing for 24 hours
const rolled = await apiClient.webhookMethods.rotateWebhookSecret(guid, newWebhook.id);
//delete a webhook
await apiClient.webhookMethods.deleteWebhook(guid, newWebhook.id);
In this Article:
Was this article helpful?