# Update a video

`PUT /api/v1/videos/{id}`

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


Parameters:

- `id` (path, id | UUIDv4 | shortUUID, required) - The object id, uuid or short uuid
  Type: id | UUIDv4 | shortUUID
  
  oneOf:
    Reference: [id](https://sourcey-peertube.pages.dev/api-rest-reference/models/id.md); Type: id
    
    minimum: 1
    
    Example:
    
    ```json
    42
    ```
  
    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"
    ```
  
    Reference: [shortUUID](https://sourcey-peertube.pages.dev/api-rest-reference/models/shortuuid.md); Type: shortUUID
    
    translation of a uuid v4 with a bigger alphabet to have a shorter uuid
    
    Example:
    
    ```json
    "2y84q2MQUMWPbiEcxNXMgC"
    ```

Request body: multipart/form-data

Type: object

- `channelId` (optional)
  Type: integer
  
  New channel of the video. The channel must be owned by the same account as the previous one. Use the "change ownership" endpoints to give a video to a channel owned by another account on the local PeerTube instance.

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

- `previewfile` (optional)
  Type: string, binary
  
  Deprecated in PeerTube v8.1, use thumbnailfile instead
  
  deprecated: true

- `category` (optional)
  Reference: [VideoCategorySet](https://sourcey-peertube.pages.dev/api-rest-reference/models/videocategoryset.md); Type: VideoCategorySet
  
  category id of the video (see [/videos/categories](#operation/getCategories))
  
  Example:
  
  ```json
  15
  ```

- `licence` (optional)
  Reference: [VideoLicenceSet](https://sourcey-peertube.pages.dev/api-rest-reference/models/videolicenceset.md); Type: VideoLicenceSet
  
  licence id of the video (see [/videos/licences](#operation/getLicences))
  
  Example:
  
  ```json
  2
  ```

- `language` (optional)
  Reference: [VideoLanguageSet](https://sourcey-peertube.pages.dev/api-rest-reference/models/videolanguageset.md); Type: VideoLanguageSet
  
  language id of the video (see [/videos/languages](#operation/getLanguages))
  
  Example:
  
  ```json
  "en"
  ```

- `privacy` (optional)
  Reference: [VideoPrivacySet](https://sourcey-peertube.pages.dev/api-rest-reference/models/videoprivacyset.md); Type: VideoPrivacySet
  
  privacy id of the video (see [/videos/privacies](#operation/getVideoPrivacyPolicies))
  
  enum: [1,2,3,4,5]

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

- `waitTranscoding` (optional)
  Type: string
  
  Whether or not we wait transcoding before publish the video

- `support` (optional)
  Type: string
  
  A text tell the audience how to support the video creator
  
  Example:
  
  ```json
  "Please support our work on https://soutenir.framasoft.org/en/ <3"
  ```

- `nsfw` (optional)
  Type: boolean
  
  Whether or not this video contains sensitive content

- `nsfwSummary` (optional)
  Type: any
  
  More information about the sensitive content of the video

- `nsfwFlags` (optional)
  Reference: [NSFWFlag](https://sourcey-peertube.pages.dev/api-rest-reference/models/nsfwflag.md); Type: NSFWFlag
  
  
  NSFW flags (can be combined using bitwise or operator)
  - `0` NONE
  - `1` VIOLENT
  - `2` EXPLICIT_SEX
  
  
  enum: [0,1,2,4]

- `name` (optional)
  Type: string
  
  Video name
  
  minLength: 3
  
  maxLength: 120

- `tags` (optional)
  Type: Array<string>
  
  Video tags (maximum 5 tags each between 2 and 30 characters)
  
  minItems: 1
  
  maxItems: 5
  
  Items:
    Type: string
    
    minLength: 2
    
    maxLength: 30

- `commentsPolicy` (optional)
  Reference: [VideoCommentsPolicySet](https://sourcey-peertube.pages.dev/api-rest-reference/models/videocommentspolicyset.md); Type: VideoCommentsPolicySet
  
  Comments policy of the video (Enabled = `1`, Disabled = `2`, Requires Approval = `3`)
  
  enum: [1,2,3]

- `recommendationScope` (optional)
  Reference: [VideoRecommendationScopeSet](https://sourcey-peertube.pages.dev/api-rest-reference/models/videorecommendationscopeset.md); Type: VideoRecommendationScopeSet
  
  Videos that can be recommended next to a video:
    - `1` All videos
    - `2` Only videos of the platform that owns the reference video (or of the current platform if no video is given)
    - `3` Only videos of the account that owns the reference video
    - `4` Only videos of the channel of the reference video
  
  This is a preference of the video owner: applications displaying recommendations may not apply it
  
  
  enum: [1,2,3,4]

- `aiUsage` (optional)
  Reference: [VideoAIUsageSet](https://sourcey-peertube.pages.dev/api-rest-reference/models/videoaiusageset.md); Type: VideoAIUsageSet
  
  **PeerTube >= 9.0** Use of AI in the video, declared by the video creator:
    - `1` Not specified
    - `2` No AI-generated content: nothing seen or heard in the video has been generated by AI
    - `3` Contains AI-generated content: some parts of the video have been generated by AI
    - `4` AI-generated: the whole video, or most of it, has been generated by AI
  
  
  enum: [1,2,3,4]

- `commercialContent` (optional)
  Reference: [VideoCommercialContentSet](https://sourcey-peertube.pages.dev/api-rest-reference/models/videocommercialcontentset.md); Type: VideoCommercialContentSet
  
  **PeerTube >= 9.0** Commercial content in the video, declared by the video creator:
    - `1` None
    - `2` Promotional content: the creator promotes their own products, services or business
    - `3` Paid partnership: a third party paid, or provided goods or services, in exchange for the promotion
  
  
  enum: [1,2,3]

- `downloadEnabled` (optional)
  Type: boolean
  
  Enable or disable downloading for this video

- `originallyPublishedAt` (optional)
  Type: string, date-time; nullable
  
  Date when the content was originally published

- `scheduleUpdate` (optional)
  Reference: [VideoScheduledUpdate](https://sourcey-peertube.pages.dev/api-rest-reference/models/videoscheduledupdate.md); Type: VideoScheduledUpdate

- `videoPasswords` (optional)
  Reference: [AddVideoPasswords](https://sourcey-peertube.pages.dev/api-rest-reference/models/addvideopasswords.md); Type: Array<password>
  
  uniqueItems: true

Responses:

- 204: successful operation

## Examples

### cURL

```bash
curl -X PUT 'https://peertube2.cpy.re/api/v1/videos/42' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  --form-string 'channelId=0' \
  --form-string 'category=15' \
  --form-string 'licence=2' \
  --form-string 'language=en' \
  --form-string 'privacy=1' \
  --form-string 'description=string' \
  --form-string 'waitTranscoding=string' \
  --form-string 'support=Please support our work on https://soutenir.framasoft.org/en/ <3' \
  --form-string 'nsfw=true' \
  --form-string 'nsfwFlags=0' \
  --form-string 'name=string' \
  --form-string 'tags=string' \
  --form-string 'commentsPolicy=1' \
  --form-string 'recommendationScope=1' \
  --form-string 'aiUsage=1' \
  --form-string 'commercialContent=1' \
  --form-string 'downloadEnabled=true' \
  --form-string 'originallyPublishedAt=2024-01-15T09:30:00Z' \
  --form-string 'scheduleUpdate={"privacy":1,"updateAt":"2024-01-15T09:30:00Z"}' \
  --form-string 'videoPasswords=string'
```

### JavaScript

```javascript
const form = new FormData();
form.append('channelId', '0');
form.append('category', '15');
form.append('licence', '2');
form.append('language', 'en');
form.append('privacy', '1');
form.append('description', 'string');
form.append('waitTranscoding', 'string');
form.append('support', 'Please support our work on https://soutenir.framasoft.org/en/ <3');
form.append('nsfw', 'true');
form.append('nsfwFlags', '0');
form.append('name', 'string');
form.append('tags', 'string');
form.append('commentsPolicy', '1');
form.append('recommendationScope', '1');
form.append('aiUsage', '1');
form.append('commercialContent', '1');
form.append('downloadEnabled', 'true');
form.append('originallyPublishedAt', '2024-01-15T09:30:00Z');
form.append('scheduleUpdate', '{"privacy":1,"updateAt":"2024-01-15T09:30:00Z"}');
form.append('videoPasswords', 'string');
const response = await fetch('https://peertube2.cpy.re/api/v1/videos/42', {
  method: 'PUT',
  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 = [
        ('channelId', (None, '0')),
        ('category', (None, '15')),
        ('licence', (None, '2')),
        ('language', (None, 'en')),
        ('privacy', (None, '1')),
        ('description', (None, 'string')),
        ('waitTranscoding', (None, 'string')),
        ('support', (None, 'Please support our work on https://soutenir.framasoft.org/en/ <3')),
        ('nsfw', (None, 'true')),
        ('nsfwFlags', (None, '0')),
        ('name', (None, 'string')),
        ('tags', (None, 'string')),
        ('commentsPolicy', (None, '1')),
        ('recommendationScope', (None, '1')),
        ('aiUsage', (None, '1')),
        ('commercialContent', (None, '1')),
        ('downloadEnabled', (None, 'true')),
        ('originallyPublishedAt', (None, '2024-01-15T09:30:00Z')),
        ('scheduleUpdate', (None, '{"privacy":1,"updateAt":"2024-01-15T09:30:00Z"}')),
        ('videoPasswords', (None, 'string')),
    ]
    response = requests.request('PUT', 'https://peertube2.cpy.re/api/v1/videos/42', headers={"Authorization":"Bearer YOUR_TOKEN"}, files=files)
    print(response.text)
```
