Show examples in:
JavascriptHTTP
Content Management API > Plugin

Create a new plugin

Body parameters

idstringOptional

RFC 4122 UUID of plugin expressed in URL-safe base64 format

Example:"RMAMRffBRlmBuDlQsIWZ0g"
package_namenull, stringOptional

NPM package name of the public plugin you want to install. For public plugins, that's the only attribute you need to pass.

Example:"datocms-plugin-star-rating-editor"
namestringOptional

The name of the plugin. Only to be passed if package name key is not specified.

Example:"5 stars"
descriptionnull, stringOptional

A description of the plugin. Only to be passed if package name key is not specified.

Example:"A better rating experience!"
urlstringOptional

The entry point URL of the plugin. Only to be passed if package name key is not specified.

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

Permissions granted to this plugin. Only to be passed if package name key is not specified.

Type:Array<string>
enabledbooleanOptional

Whether the plugin is enabled or not. Defaults to true.

plugin_typeenumDeprecated

The type of field extension this legacy plugin implements. Only to be passed if package name key is not specified.

Pass this field only if you plan to create a legacy plugin. Modern plugins declare their capabilities at run-time.

Example:"field_editor"
field_editorOptional

Field editor plugin

sidebarOptional

Sidebar plugin

field_addonOptional

Field addon plugin

field_typesDeprecated

On which types of field in which this legacy plugin can be used. Only to be passed if package name key is not specified.

Pass this field only if you plan to create a legacy plugin. Modern plugins declare their capabilities at run-time.

Type:Array<string>
Example:["integer", "float"]
parameter_definitionsobjectDeprecated

The schema for the parameters this legacy plugin can persist

This field makes sense for legacy plugins only. Modern plugins declare can store anything they want in the parameters attribute.

Example:{ global: [ { id: "devMode", type: "boolean", label: "Run in development mode" }, ], instance: [ { id: "halfStars", type: "boolean", label: "Allow half stars ratings?", default: false, hint: "If enabled, rate using whole stars, if enabled, it doesn't use half-steps", }, { id: "totalStars", type: "integer", label: "Amount of stars to show", default: 5, hint: "", }, ], }
globalArrayRequired
instanceArrayRequired

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 plugin = await client.plugins.create({
package_name: "datocms-plugin-star-rating-editor",
});
console.log(plugin);
}
run();
const result = {
type: "plugin",
id: "124",
name: "5 stars",
description: "A better rating experience!",
package_name: "datocms-plugin-star-rating-editor",
package_version: "0.0.4",
url: "https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js",
permissions: ["currentUserAccessToken"],
parameters: {},
};
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 plugin = await client.plugins.create({
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!",
url: "https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js",
permissions: ["currentUserAccessToken"],
parameters: {},
};