# Create a video playlist

`POST /api/v1/video-playlists`

If the video playlist is set as public, `videoChannelId` is mandatory.

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": []
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started


Request body: multipart/form-data

Type: object

- `displayName` (required)
  Type: string
  
  Video playlist display name
  
  minLength: 1
  
  maxLength: 120

- `thumbnailfile` (optional)
  Type: string, binary
  
  Video playlist thumbnail file

- `privacy` (optional)
  Reference: [VideoPlaylistPrivacySet](https://sourcey-peertube.pages.dev/api-rest-reference/models/videoplaylistprivacyset.md); Type: VideoPlaylistPrivacySet
  
  Video playlist privacy policy (see [/video-playlists/privacies](#operation/getPlaylistPrivacyPolicies))
  
  enum: [1,2,3]

- `description` (optional)
  Type: string
  
  Video playlist description
  
  minLength: 3
  
  maxLength: 1000

- `videoChannelId` (optional)
  Type: id
  
  Video channel in which the playlist will be published
  
  allOf:
    Reference: [id](https://sourcey-peertube.pages.dev/api-rest-reference/models/id.md); Type: id
    
    minimum: 1
    
    Example:
    
    ```json
    42
    ```

Responses:

- 200: successful operation

Content type: application/json

Type: object

- `videoPlaylist` (optional)
  Type: object
  
  - `id` (optional)
    Reference: [id](https://sourcey-peertube.pages.dev/api-rest-reference/models/id.md); Type: id
    
    minimum: 1
    
    Example:
    
    ```json
    42
    ```
  
  - `uuid` (optional)
    Reference: [UUIDv4](https://sourcey-peertube.pages.dev/api-rest-reference/models/uuidv4.md); Type: UUIDv4, uuid
    
    minLength: 36
    
    maxLength: 36
    
    pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    
    Example:
    
    ```json
    "9c9de5e8-0a1e-484a-b099-e80766180a6d"
    ```
  
  - `shortUUID` (optional)
    Reference: [shortUUID](https://sourcey-peertube.pages.dev/api-rest-reference/models/shortuuid.md); Type: shortUUID

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/video-playlists' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  --form-string 'displayName=string' \
  --form-string 'privacy=1' \
  --form-string 'description=string'
```

### JavaScript

```javascript
const form = new FormData();
form.append('displayName', 'string');
form.append('privacy', '1');
form.append('description', 'string');
const response = await fetch('https://peertube2.cpy.re/api/v1/video-playlists', {
  method: 'POST',
  headers: {"Authorization":"Bearer YOUR_TOKEN"},
  body: form,
});
console.log(await response.text());
```

### Python

```python
import requests
from contextlib import ExitStack

with ExitStack() as stack:
    files = [
        ('displayName', (None, 'string')),
        ('privacy', (None, '1')),
        ('description', (None, 'string')),
    ]
    response = requests.request('POST', 'https://peertube2.cpy.re/api/v1/video-playlists', headers={"Authorization":"Bearer YOUR_TOKEN"}, files=files)
    print(response.text)
```
