Show examples in:
Javascript HTTP
Content Management API > Plugin

Update a plugin

Body parameters

name string Optional

The name of the plugin

Example: "5 stars"
description null, string Optional

A description of the plugin

Example: "A better rating experience!"
url string Optional

The entry point URL of the plugin

Example: "https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.ts"
package_name string Optional

Turns a private plugin into a Marketplace plugin, installing the specified package from the DatoCMS Marketplace. Only accepted for private, non-legacy plugins, and cannot be combined with other attributes (except enabled). Name, description, URL, version and permissions are replaced with the ones published in the Marketplace, while the existing parameters are preserved.

Example: "datocms-plugin-star-rating-editor"
parameters object Optional

Global plugin configuration. Plugins can persist whatever information they want in this object to reuse it later. Refer to the CMA for details about technical limits.

Example: { devMode: true }
package_version null, string Optional

The installed version of the plugin (or null if it's a private plugin)

Example: "0.0.4"
permissions Optional

Permissions granted to this plugin

Type: Array<string>
enabled boolean Optional

Whether the plugin is enabled or not. When disabled, the plugin behaves as if it didn't exist: fields using it as editor/addon fall back to the default editor, and any sidebar panel/page/config screen/asset source it registers does not render.

Returns

Returns a resource object of type plugin

Other examples

import { buildClient } from "@datocms/cma-client-node";
async function run() {
// Make sure the API token has access to the CMA, and is stored securely
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const pluginId = "124";
const plugin = await client.plugins.update(pluginId, {
parameters: { foo: "bar" },
});
console.log(plugin);
}
run();
const result = {
type: "plugin",
id: "124",
name: "5 stars",
/* ... */
parameters: { foo: "bar" },
};
import { buildClient } from "@datocms/cma-client-node";
async function run() {
// Make sure the API token has access to the CMA, and is stored securely
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const pluginId = "124";
const plugin = await client.plugins.update(pluginId, {
package_version: "2.0.0",
});
console.log(plugin);
}
run();
const result = {
type: "plugin",
id: "124",
name: "5 stars",
/* ... */
package_version: "2.0.0",
};
import { buildClient } from "@datocms/cma-client-node";
async function run() {
// Make sure the API token has access to the CMA, and is stored securely
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const pluginId = "124";
const plugin = await client.plugins.update(pluginId, {
name: "5 stars",
description: "A better rating experience!",
url: "https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js",
permissions: ["currentUserAccessToken"],
});
console.log(plugin);
}
run();
const result = {
type: "plugin",
id: "124",
name: "5 stars",
description: "A better rating experience!",
package_name: null,
package_version: null,
url: "https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js",
permissions: ["currentUserAccessToken"],
parameters: { foo: "bar" },
};

Once a privately-hosted plugin gets published to the DatoCMS Marketplace, you can turn the private plugin into a Marketplace plugin. Its global parameters are preserved.

import { buildClient } from "@datocms/cma-client-node";
async function run() {
// Make sure the API token has access to the CMA, and is stored securely
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const pluginId = "124";
const plugin = await client.plugins.update(pluginId, {
package_name: "datocms-plugin-star-rating-editor",
});
console.log(plugin);
}
run();
const result = {
type: "plugin",
id: "124",
name: "Star rating",
description: "A better rating experience!",
package_name: "datocms-plugin-star-rating-editor",
package_version: "0.0.4",
url: "https://plugins-cdn.datocms.com/datocms-plugin-star-rating-editor@0.0.4/dist/index.html",
permissions: [],
parameters: { foo: "bar" },
enabled: true,
};