Plugin API & Database Reference
This page documents all API endpoints and the MongoDB/Mongoose schema for the NetPad plugin system. Use this as a reference for advanced integration, automation, or troubleshooting.
1. API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/plugins | Publish plugin |
| GET | /api/plugins | Browse store |
| GET | /api/plugins/:id | Get plugin details |
| POST | /api/plugins/:id/install | Install plugin |
| DELETE | /api/plugins/:id/install | Uninstall plugin |
| GET | /api/my/plugins | User’s plugins |
| GET | /api/org/plugins | Organization plugins |
| POST | /api/org/plugins/:id/enable | Enable for org |
| DELETE | /api/org/plugins/:id/disable | Disable for org |
| GET | /api/admin/plugins | Admin plugin management |
| POST | /api/admin/plugins/:id/kill | Emergency disable |
| GET | /api/admin/audit | Audit logs |
2. Plugin Model (Mongoose)
Plugin.js
const PluginSchema = new mongoose.Schema({
id: String, // Unique plugin identifier (author.name)
name: String, // Plugin name (from manifest)
version: String, // Semantic version
manifest: mongoose.Schema.Types.Mixed, // Complete plugin manifest
files: {
runner: String,
shape: String,
icon: String,
readme: String
},
author_id: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
organization_id: { type: mongoose.Schema.Types.ObjectId, ref: 'Organization' },
status: String, // draft, pending, approved, rejected
scope: String, // private, org, public
category: String, // ai, data, integration, etc.
stats: {
downloads: Number,
installations: Number,
rating: Number,
reviews: Number
},
verified: Boolean,
verified_by: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
verified_at: Date,
tags: [String],
review_notes: String,
reviewed_by: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
reviewed_at: Date,
published_at: Date,
homepage: String,
repository: String,
size: Number,
checksum: String
}, { timestamps: { createdAt: 'created_at', updatedAt: 'updated_at' }});Key Fields:
| Field | Type | Description |
|---|---|---|
| id | String | Unique plugin identifier (author.name) |
| name | String | Plugin name (from manifest) |
| version | String | Semantic version |
| manifest | Mixed | Complete plugin manifest |
| files | Object | runner, shape, icon, readme |
| author_id | ObjectId | Reference to User |
| organization_id | ObjectId | Reference to Organization |
| status | String | draft, pending, approved, rejected |
| scope | String | private, org, public |
| category | String | ai, data, integration, etc. |
| stats | Object | downloads, installations, rating, reviews |
| verified | Boolean | Trust indicator |
| tags | [String] | Search tags |
| published_at | Date | When published |
3. Plugin Installation Model (Mongoose)
PluginInstallation.js
const PluginInstallationSchema = new mongoose.Schema({
plugin_id: String, // Plugin.id field
user_id: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
organization_id: { type: mongoose.Schema.Types.ObjectId, ref: 'Organization' },
scope: String, // user, org, public
status: String, // active, disabled, failed
installed_version: String,
config: mongoose.Schema.Types.Mixed,
last_used: Date,
execution_count: Number,
avg_execution_time: Number,
total_execution_time: Number,
error_count: Number,
last_error: {
message: String,
timestamp: Date,
stack: String
},
installed_at: Date,
auto_update: Boolean,
update_available: Boolean,
available_version: String,
source: String // store, upload, cli, org_admin
}, { timestamps: { createdAt: 'created_at', updatedAt: 'updated_at' }});Key Fields:
| Field | Type | Description |
|---|---|---|
| plugin_id | String | Reference to Plugin.id |
| user_id | ObjectId | Reference to User |
| organization_id | ObjectId | Reference to Organization |
| scope | String | user, org, public |
| status | String | active, disabled, failed |
| installed_version | String | Version at install |
| config | Mixed | User/org config |
| last_used | Date | Last used timestamp |
| execution_count | Number | Usage count |
| avg_execution_time | Number | ms average |
| error_count | Number | Error count |
| last_error | Object | Last error details |
| installed_at | Date | Install timestamp |
| auto_update | Boolean | Auto-update enabled |
| update_available | Boolean | Update available flag |
| source | String | store, upload, cli, org_admin |
4. Usage Notes
- All endpoints require authentication
- Organization and admin endpoints require appropriate permissions
- Audit logs are available to admins for compliance and security
Further Reading
For more, see the Plugin Sprint Plan.