Choose your language:
    Create a new plugin
    Parameters
    packageName  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.

    name  string  Optional

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

    description  string  Optional

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

    url  string  Optional

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

    permissions  Array<string>  Optional

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

    Returns
    Returns a plugin object.

    Examples

    Installation of a public plugin from NPM
    Example code:
    const { SiteClient } = require("datocms-client");
    const client = new SiteClient("YOUR-API-TOKEN");
    client.plugins.create({
    packageName: 'datocms-plugin-star-rating-editor'
    })
    .then((plugin) => {
    console.log(plugin);
    })
    .catch((error) => {
    console.error(error);
    });
    Returned output:
    {
    "id": "124",
    "name": "5 stars",
    "description": "A simple field editor that allows a nicer editing rating experience",
    "packageName": "datocms-plugin-star-rating-editor",
    "packageVersion": "0.0.4",
    "url": "https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js",
    "permissions": ["currentUserAccessToken"],
    "parameters": {}
    }
    Creation of a private plugin
    Example code:
    const SiteClient = require('datocms-client').SiteClient;
    const client = new SiteClient('YOUR-API-TOKEN');
    client.plugins.create({
    name: '5 stars',
    description: 'A simple field editor that allows a nicer editing rating experience',
    url: 'https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js',
    permissions: ["currentUserAccessToken"],
    })
    .then((plugin) => {
    console.log(plugin);
    })
    .catch((error) => {
    console.error(error);
    });
    Returned output:
    {
    "id": "124",
    "name": "5 stars",
    "description": "A simple field editor that allows a nicer editing rating experience",
    "url": "https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js",
    "permissions": ["currentUserAccessToken"],
    "parameters": {}
    }