# Create Plugin Tenant

`POST /api/plugin-tenants`

Creates a new plugin tenant relationship with specified configuration and access controls

Authentication: no security requirement declared for this operation.

Request body: application/json (required)

Type: object

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

- `pluginId` (required)
  Type: string
  
  Plugin ID

- `enabled` (required)
  Type: boolean
  
  Whether the plugin is enabled for this tenant
  
  default: true

- `scope` (required)
  Type: string
  
  Scope of the plugin (USER, ORGANIZATION, TENANT)
  
  enum: ["tenant","organization","user"]

- `tenantId` (optional)
  Type: string
  
  Tenant ID

- `organizationId` (optional)
  Type: string
  
  Organization ID

- `autoInstall` (optional)
  Type: boolean
  
  Whether plugin can be installed automatically without user action
  
  default: false

- `requiresApproval` (optional)
  Type: boolean
  
  Whether plugin requires admin approval before installation
  
  default: true

- `isMandatory` (optional)
  Type: boolean
  
  Whether plugin is mandatory for all users in scope
  
  default: false

- `maxInstallations` (optional)
  Type: number
  
  Maximum number of installations allowed (-1 for unlimited, null for no limit)
  
  Example:
  
  ```json
  100
  ```

- `maxActiveUsers` (optional)
  Type: number
  
  Maximum number of active users allowed (-1 for unlimited, null for no limit)
  
  Example:
  
  ```json
  50
  ```

- `tenantConfiguration` (optional)
  Type: object
  
  Tenant-specific plugin configuration overrides
  
  Example:
  
  ```json
  {
    "branding": {
      "logo": "tenant-logo.png",
      "theme": "blue"
    },
    "features": {
      "advancedReporting": true
    },
    "limits": {
      "dailyUsage": 1000
    }
  }
  ```

- `preferences` (optional)
  Type: object
  
  Plugin preferences and UI customizations for this tenant
  
  Example:
  
  ```json
  {
    "defaultSettings": {
      "autoSave": true,
      "notifications": false
    },
    "uiCustomizations": {
      "hideAdvancedOptions": true
    }
  }
  ```

- `isDataCompliant` (optional)
  Type: boolean
  
  Whether plugin data handling complies with tenant data policies
  
  default: true

- `complianceCertifications` (optional)
  Type: array
  
  List of compliance certifications applicable to this tenant
  
  Example:
  
  ```json
  [
    "SOC2",
    "GDPR",
    "HIPAA"
  ]
  ```
  
  Items:
    Type: string

- `allowedRoleIds` (optional)
  Type: array
  
  Array of role IDs explicitly allowed to access this plugin
  
  Items:
    Type: string

- `allowedUserIds` (optional)
  Type: array
  
  Array of user IDs explicitly allowed to access this plugin
  
  Items:
    Type: string

- `deniedUserIds` (optional)
  Type: array
  
  Array of user IDs explicitly denied access to this plugin
  
  Items:
    Type: string

- `allowedRoles` (optional)
  Type: array
  
  Array of roles explicitly allowed to access this plugin
  
  Items:
    Type: object

- `allowedUsers` (optional)
  Type: array
  
  Array of users explicitly allowed to access this plugin
  
  Items:
    Type: object

- `deniedUsers` (optional)
  Type: array
  
  Array of users explicitly denied access to this plugin
  
  Items:
    Type: object

Responses:

- 201: Plugin tenant created successfully

Content type: application/json

Type: object

- 400: Invalid input data

- 409: Plugin tenant already exists

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/plugin-tenants' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "pluginId": "string",
  "enabled": true,
  "scope": "tenant",
  "tenantId": "string",
  "organizationId": "string",
  "autoInstall": false,
  "requiresApproval": true,
  "isMandatory": false,
  "maxInstallations": 100,
  "maxActiveUsers": 50,
  "tenantConfiguration": {
    "branding": {
      "logo": "tenant-logo.png",
      "theme": "blue"
    },
    "features": {
      "advancedReporting": true
    },
    "limits": {
      "dailyUsage": 1000
    }
  },
  "preferences": {
    "defaultSettings": {
      "autoSave": true,
      "notifications": false
    },
    "uiCustomizations": {
      "hideAdvancedOptions": true
    }
  },
  "isDataCompliant": true,
  "complianceCertifications": [
    "SOC2",
    "GDPR",
    "HIPAA"
  ],
  "allowedRoleIds": [
    "string"
  ],
  "allowedUserIds": [
    "string"
  ],
  "deniedUserIds": [
    "string"
  ],
  "allowedRoles": [
    {}
  ],
  "allowedUsers": [
    {}
  ],
  "deniedUsers": [
    {}
  ]
}'
```

### JavaScript

```javascript
const body = `{
  "pluginId": "string",
  "enabled": true,
  "scope": "tenant",
  "tenantId": "string",
  "organizationId": "string",
  "autoInstall": false,
  "requiresApproval": true,
  "isMandatory": false,
  "maxInstallations": 100,
  "maxActiveUsers": 50,
  "tenantConfiguration": {
    "branding": {
      "logo": "tenant-logo.png",
      "theme": "blue"
    },
    "features": {
      "advancedReporting": true
    },
    "limits": {
      "dailyUsage": 1000
    }
  },
  "preferences": {
    "defaultSettings": {
      "autoSave": true,
      "notifications": false
    },
    "uiCustomizations": {
      "hideAdvancedOptions": true
    }
  },
  "isDataCompliant": true,
  "complianceCertifications": [
    "SOC2",
    "GDPR",
    "HIPAA"
  ],
  "allowedRoleIds": [
    "string"
  ],
  "allowedUserIds": [
    "string"
  ],
  "deniedUserIds": [
    "string"
  ],
  "allowedRoles": [
    {}
  ],
  "allowedUsers": [
    {}
  ],
  "deniedUsers": [
    {}
  ]
}`;

const response = await fetch('http://localhost:3000/api/plugin-tenants', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "pluginId": "string",
  "enabled": true,
  "scope": "tenant",
  "tenantId": "string",
  "organizationId": "string",
  "autoInstall": false,
  "requiresApproval": true,
  "isMandatory": false,
  "maxInstallations": 100,
  "maxActiveUsers": 50,
  "tenantConfiguration": {
    "branding": {
      "logo": "tenant-logo.png",
      "theme": "blue"
    },
    "features": {
      "advancedReporting": true
    },
    "limits": {
      "dailyUsage": 1000
    }
  },
  "preferences": {
    "defaultSettings": {
      "autoSave": true,
      "notifications": false
    },
    "uiCustomizations": {
      "hideAdvancedOptions": true
    }
  },
  "isDataCompliant": true,
  "complianceCertifications": [
    "SOC2",
    "GDPR",
    "HIPAA"
  ],
  "allowedRoleIds": [
    "string"
  ],
  "allowedUserIds": [
    "string"
  ],
  "deniedUserIds": [
    "string"
  ],
  "allowedRoles": [
    {}
  ],
  "allowedUsers": [
    {}
  ],
  "deniedUsers": [
    {}
  ]
}'''

response = requests.post(
    'http://localhost:3000/api/plugin-tenants',
    data=body.encode('utf-8'),
    headers={
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
