Show examples in:
Javascript HTTP
Endpoint info
Available examples

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"
type string Required

Must be exactly "plugin".

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

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

Example: "5 stars"
attributes.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!"
attributes.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"
attributes.permissions Optional

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

Type: Array<string>
attributes.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

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

Examples

1
POST https://site-api.datocms.com/plugins HTTP/1.1
2
Authorization: Bearer YOUR-API-TOKEN
3
Accept: application/json
4
X-Api-Version: 3
5
Content-Type: application/vnd.api+json
6
7
{
8
"data": {
9
"type": "plugin",
10
"attributes": {}
11
}
12
}
Terminal window
1
curl -g 'https://site-api.datocms.com/plugins' \
2
-X POST \
3
-H "Authorization: Bearer YOUR-API-TOKEN" \
4
-H "Accept: application/json" \
5
-H "X-Api-Version: 3" \
6
-H "Content-Type: application/vnd.api+json" \
7
--data-binary '{"data":{"type":"plugin","attributes":{}}}'
1
await fetch("https://site-api.datocms.com/plugins", {
2
method: "POST",
3
headers: {
4
Authorization: "Bearer YOUR-API-TOKEN",
5
Accept: "application/json",
6
"X-Api-Version": "3",
7
"Content-Type": "application/vnd.api+json",
8
},
9
body: JSON.stringify({ data: { type: "plugin", attributes: {} } }),
10
});
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
Cache-Control: cache-control: max-age=0, private, must-revalidate
4
X-RateLimit-Limit: 30
5
X-RateLimit-Remaining: 28
6
7
{
8
"data": {
9
"type": "plugin",
10
"id": "RMAMRffBRlmBuDlQsIWZ0g",
11
"attributes": {
12
"name": "5 stars",
13
"description": "A better rating experience!",
14
"url": "https://cdn.rawgit.com/datocms/extensions/master/samples/five-stars/extension.js",
15
"parameters": {
16
"devMode": true
17
},
18
"package_name": "datocms-plugin-star-rating-editor",
19
"package_version": "0.0.4",
20
"permissions": [
21
"currentUserAccessToken"
22
]
23
},
24
"meta": {
25
"version": "2"
26
}
27
}
28
}