Show examples in:
    Create a new plugin

    Body Parameters

    id  string  Optional
    RFC 4122 UUID of plugin expressed in URL-safe base64 format
    package_name  Optional  null, string  Example: "datocms-plugin-star-rating-editor"

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

    name  Optional  string  Example: "5 stars"

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

    description  Optional  null, string  Example: "A better rating experience!"

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

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

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

    permissions  Optional  Array<string>

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

    Returns

    Returns a plugin resource object.

    Examples

    Example Installation of a public plugin from NPM
    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();
    Example Creation of a private plugin
    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();