Sorry, no results found for "".

Show examples in:
Javascript HTTP

Content Management API > Plugin

Create a new plugin

Body parameters

id string Optional

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

Example: "RMAMRffBRlmBuDlQsIWZ0g"
package_name null, string Optional

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"
name string Optional

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

Example: "5 stars"
description null, string Optional

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

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

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.js"
permissions Optional

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

Type: Array<string>
plugin_type enum Deprecated

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_editor Optional

Field editor plugin

sidebar Optional

Sidebar plugin

field_addon Optional

Field addon plugin

field_types Deprecated

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_definitions object Deprecated

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: "", }, ], }
global Array Required
instance Array Required

Returns

Returns a resource object of type plugin

Other examples

1
import { buildClient } from "@datocms/cma-client-node";
2
3
async function run() {
4
// Make sure the API token has access to the CMA, and is stored securely
5
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
6
7
const plugin = await client.plugins.create({
8
package_name: "datocms-plugin-star-rating-editor",
9
});
10
11
console.log(plugin);
12
}
13
14
run();
1
const result = {
2
type: 'plugin',
3
id: '124',
4
name: '5 stars',
5
description: 'A better rating experience!',
6
package_name: 'datocms-plugin-star-rating-editor',
7
package_version: '0.0.4',
8
url: 'https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js',
9
permissions: ['currentUserAccessToken'],
10
parameters: {},
11
};
1
import { buildClient } from "@datocms/cma-client-node";
2
3
async function run() {
4
// Make sure the API token has access to the CMA, and is stored securely
5
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
6
7
const plugin = await client.plugins.create({
8
name: "5 stars",
9
description: "A better rating experience!",
10
url: "https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js",
11
permissions: ["currentUserAccessToken"],
12
});
13
14
console.log(plugin);
15
}
16
17
run();
1
const result = {
2
type: 'plugin',
3
id: '124',
4
name: '5 stars',
5
description: 'A better rating experience!',
6
url: 'https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js',
7
permissions: ['currentUserAccessToken'],
8
parameters: {},
9
};