# Create a new plugin source

`POST /api/plugins/{pluginId}/versions/{versionId}/sources`

Authentication: no security requirement declared for this operation.

Parameters:

- `pluginId` (path, string, uuid, required) - The UUID of the plugin for which a new version is being associated to.
  Type: string, uuid

- `versionId` (path, string, uuid, required) - The UUID of the version for which a new source is being created.
  Type: string, uuid

Request body: multipart/form-data (required)

The data required to create a new plugin source.

Type: object

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

- `sources` (required)
  Type: array
  
  Array of plugin sources
  
  Examples:
  
  ```json
  [
    {
      "name": "source1",
      "operatingSystem": "UNIVERSAL",
      "architecture": "X64",
      "url": "https://example.com/plugin1",
      "type": "CDN"
    },
    {
      "name": "@scope/plugin2",
      "operatingSystem": "MAC",
      "architecture": "ARM",
      "scope": "@scope",
      "registry": "https://registry.npmjs.org/",
      "private": true,
      "type": "NPM"
    }
  ]
  ```
  
  Items:
    Reference: [PluginSourceDTO](https://sourcey-gauzy.pages.dev/api-reference/models/pluginsourcedto/index.md); Type: object

Responses:

- 201: Plugin source successfully created.

Content type: application/json

Type: array

Items:
  Reference: [PluginSourceDTO](https://sourcey-gauzy.pages.dev/api-reference/models/pluginsourcedto/index.md); Type: object

- 400: Bad request - Validation failed.

- 404: Version not found.

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/plugins/550e8400-e29b-41d4-a716-446655440000/versions/550e8400-e29b-41d4-a716-446655440000/sources' \
  --form-string 'sources={"name":"source1","operatingSystem":"UNIVERSAL","architecture":"X64","url":"https://example.com/plugin1","type":"CDN"}'
```

### JavaScript

```javascript
const form = new FormData();
form.append('sources', '{"name":"source1","operatingSystem":"UNIVERSAL","architecture":"X64","url":"https://example.com/plugin1","type":"CDN"}');
const response = await fetch('http://localhost:3000/api/plugins/550e8400-e29b-41d4-a716-446655440000/versions/550e8400-e29b-41d4-a716-446655440000/sources', {
  method: 'POST',
  headers: {},
  body: form,
});
console.log(await response.text());
```

### Python

```python
import requests
from contextlib import ExitStack

with ExitStack() as stack:
    files = [
        ('sources', (None, '{"name":"source1","operatingSystem":"UNIVERSAL","architecture":"X64","url":"https://example.com/plugin1","type":"CDN"}')),
    ]
    response = requests.request('POST', 'http://localhost:3000/api/plugins/550e8400-e29b-41d4-a716-446655440000/versions/550e8400-e29b-41d4-a716-446655440000/sources', headers={}, files=files)
    print(response.text)
```
