Show examples in:
JavascriptHTTP
Endpoint info
Available examples
Content Management API > Plugin

Create a new plugin

Body parameters

idstringOptional

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

Example:"RMAMRffBRlmBuDlQsIWZ0g"
typestringRequired

Must be exactly "plugin".

attributes.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"
attributes.namestringOptional

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

Example:"5 stars"
attributes.descriptionnull, stringOptional

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

Example:"A better rating experience!"
attributes.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"
attributes.permissionsOptional

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

Type:Array<string>
attributes.enabledbooleanOptional

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

attributes.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

attributes.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"]
attributes.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.

Examples

POST https://site-api.datocms.com/plugins HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Content-Type: application/vnd.api+json
{
"data": {
"type": "plugin",
"attributes": {}
}
}
Terminal window
curl -g 'https://site-api.datocms.com/plugins' \
-X POST \
-H "Authorization: Bearer YOUR-API-TOKEN" \
-H "Accept: application/json" \
-H "X-Api-Version: 3" \
-H "Content-Type: application/vnd.api+json" \
--data-binary '{"data":{"type":"plugin","attributes":{}}}'
await fetch("https://site-api.datocms.com/plugins", {
method: "POST",
headers: {
Authorization: "Bearer YOUR-API-TOKEN",
Accept: "application/json",
"X-Api-Version": "3",
"Content-Type": "application/vnd.api+json",
},
body: JSON.stringify({ data: { type: "plugin", attributes: {} } }),
});
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 28
{
"data": {
"type": "plugin",
"id": "RMAMRffBRlmBuDlQsIWZ0g",
"attributes": {
"name": "5 stars",
"description": "A better rating experience!",
"url": "https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.ts",
"parameters": {
"devMode": true
},
"package_name": "datocms-plugin-star-rating-editor",
"package_version": "0.0.4",
"permissions": [
"currentUserAccessToken"
],
"enabled": true
},
"meta": {
"version": "2"
}
}
}