# Create new plugin

`POST /api/plugins`

Uploads a plugin file along with metadata to register a new plugin in the system.

Authentication (security requirement alternatives):

```json
[
  {
    "api_key": []
  },
  {
    "Bearer": []
  }
]
```

- api_key
- Bearer

Request body: multipart/form-data (required)

Plugin metadata and file

Type: object

Schema: [CreatePluginDTO](https://sourcey-gauzy.pages.dev/api-reference/models/createplugindto/index.md)

- `name` (required)
  Type: string
  
  Plugin name

- `description` (optional)
  Type: string
  
  Plugin description

- `type` (required)
  Type: string
  
  Type of the plugin
  
  enum: ["DESKTOP","WEB","MOBILE"]

- `status` (required)
  Type: string
  
  Status of the plugin
  
  enum: ["ACTIVE","INACTIVE","DEPRECATED","ARCHIVED"]

- `isActive` (optional)
  Type: boolean
  
  Plugin is active or not
  
  default: false

- `categoryId` (optional)
  Type: string
  
  Plugin category ID

- `author` (optional)
  Type: string
  
  Plugin author

- `license` (optional)
  Type: string
  
  Plugin license

- `homepage` (optional)
  Type: string
  
  Homepage URL

- `repository` (optional)
  Type: string
  
  Repository URL

- `tags` (optional)
  Type: array
  
  Plugin tags
  
  Items:
    Type: string

- `requiresSubscription` (optional)
  Type: boolean
  
  Whether plugin requires subscription
  
  default: false

- `uploadedById` (optional)
  Type: string
  
  ID of user who uploaded the plugin

- `subscriptionPlans` (optional)
  Type: array
  
  Subscription plans for the plugin
  
  Items:
    Type: string

Responses:

- 201: Plugin created successfully.

Content type: application/json

Type: object

Schema: [Plugin_1](https://sourcey-gauzy.pages.dev/api-reference/models/plugin-1/index.md)

- `deletedAt` (optional)
  Type: string, date-time
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `createdAt` (optional)
  Type: string, date-time
  
  The creation timestamp of the entity.
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `updatedAt` (optional)
  Type: string, date-time
  
  The last update timestamp of the entity.
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `id` (optional)
  Type: string

- `isActive` (optional)
  Type: boolean
  
  Plugin is active or not
  
  default: false

- `isArchived` (optional)
  Type: boolean
  
  default: false

- `archivedAt` (optional)
  Type: string, date-time
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `name` (required)
  Type: string
  
  Plugin name

- `description` (optional)
  Type: string
  
  Plugin description

- `type` (required)
  Type: string
  
  Type of the plugin
  
  enum: ["DESKTOP","WEB","MOBILE"]

- `status` (required)
  Type: string
  
  Status of the plugin
  
  enum: ["ACTIVE","INACTIVE","DEPRECATED","ARCHIVED"]

- `categoryId` (optional)
  Type: string
  
  Plugin category ID

- `category` (optional)
  Type: object
  
  Plugin category

- `versions` (required)
  Type: array
  
  Versions of the plugin
  
  Items:
    Type: string

- `author` (optional)
  Type: string
  
  Plugin author

- `license` (optional)
  Type: string
  
  Plugin license

- `homepage` (optional)
  Type: string
  
  Homepage URL

- `repository` (optional)
  Type: string
  
  Repository URL

- `uploadedBy` (optional)
  Type: unknown
  
  User who uploaded the plugin
  
  allOf:
    Reference: [User](https://sourcey-gauzy.pages.dev/api-reference/models/user/index.md); Type: object

- `uploadedAt` (optional)
  Type: string, date-time
  
  Upload date

- `requiresSubscription` (required)
  Type: boolean
  
  Is subscription plan enabled
  
  default: false

- `isFeatured` (required)
  Type: boolean
  
  Whether the plugin is featured
  
  default: false

- `isVerified` (required)
  Type: boolean
  
  Whether the plugin is verified by Gauzy
  
  default: false

- `lastDownloadedAt` (optional)
  Type: string, date-time
  
  Last downloaded date

- `pluginTenants` (optional)
  Type: array
  
  Plugin tenants for this plugin
  
  Items:
    Type: string

- `settings` (optional)
  Type: array
  
  Plugin settings
  
  Items:
    Type: string

- `subscriptions` (optional)
  Type: array
  
  Plugin subscriptions
  
  Items:
    Type: string

- `subscriptionPlans` (optional)
  Type: array
  
  Plugin subscription plans
  
  Items:
    Type: string

- `pluginTags` (optional)
  Type: array
  
  Plugin tag relationships
  
  Items:
    Type: string

- 400: Invalid input provided. Check the response body for error details.

- 401: Unauthorized access.

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/plugins' \
  --form-string 'name=string' \
  --form-string 'description=string' \
  --form-string 'type=DESKTOP' \
  --form-string 'status=ACTIVE' \
  --form-string 'isActive=false' \
  --form-string 'categoryId=string' \
  --form-string 'author=string' \
  --form-string 'license=string' \
  --form-string 'homepage=string' \
  --form-string 'repository=string' \
  --form-string 'tags=string' \
  --form-string 'requiresSubscription=false' \
  --form-string 'uploadedById=string' \
  --form-string 'subscriptionPlans=string'
```

### JavaScript

```javascript
const form = new FormData();
form.append('name', 'string');
form.append('description', 'string');
form.append('type', 'DESKTOP');
form.append('status', 'ACTIVE');
form.append('isActive', 'false');
form.append('categoryId', 'string');
form.append('author', 'string');
form.append('license', 'string');
form.append('homepage', 'string');
form.append('repository', 'string');
form.append('tags', 'string');
form.append('requiresSubscription', 'false');
form.append('uploadedById', 'string');
form.append('subscriptionPlans', 'string');
const response = await fetch('http://localhost:3000/api/plugins', {
  method: 'POST',
  headers: {},
  body: form,
});
console.log(await response.text());
```

### Python

```python
import requests
from contextlib import ExitStack

with ExitStack() as stack:
    files = [
        ('name', (None, 'string')),
        ('description', (None, 'string')),
        ('type', (None, 'DESKTOP')),
        ('status', (None, 'ACTIVE')),
        ('isActive', (None, 'false')),
        ('categoryId', (None, 'string')),
        ('author', (None, 'string')),
        ('license', (None, 'string')),
        ('homepage', (None, 'string')),
        ('repository', (None, 'string')),
        ('tags', (None, 'string')),
        ('requiresSubscription', (None, 'false')),
        ('uploadedById', (None, 'string')),
        ('subscriptionPlans', (None, 'string')),
    ]
    response = requests.request('POST', 'http://localhost:3000/api/plugins', headers={}, files=files)
    print(response.text)
```
