> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://uploadcare.com/docs/llms.txt.

# Convert video

POST https://api.uploadcare.com/convert/video/
Content-Type: application/json

Uploadcare video processing adjusts video quality, format (mp4, webm, ogg), and size, cuts it, and generates thumbnails. Processed video is instantly available over CDN.

Reference: https://uploadcare.com/docs/api/rest/conversion/video-convert

## Authentication

- `Authorization` header (required) — Every request made to `https://api.uploadcare.com/` MUST be signed. HTTPS SHOULD be used with any authorization scheme. Requests MUST contain the `Authorization` header defining `auth-scheme` and `auth-param`: `Authorization: auth-scheme auth-param`. Every request MUST contain the `Accept` header identifying the REST API version: `Accept: application/vnd.uploadcare-v0.7+json`. There are two available authorization schemes: * For production: `Uploadcare`, a scheme where a `signature`, not your Secret API Key MUST be specified. Signatures SHOULD be generated on backend. * For quick tests: `Uploadcare.Simple`, a simple scheme where your [Secret API Key](https://app.uploadcare.com/projects/-/api-keys/) MUST be specified in every request's `auth-param`.

## Request

### Headers

- `Accept` (string, required) — Version header.

### Body (application/json)

This endpoint expects a videoJobSubmitParameters.

- `paths` (list of string, optional) — An array of UUIDs of your video files to process together with a set of assigned operations (see [documentation](https://uploadcare.com/docs/transformations/video-encoding/)).
- `store` (enum, optional) — When `store` is set to `"0"`, the converted files will only be available for 24 hours. `"1"` makes converted files available permanently. If the parameter is omitted, it checks the `Auto file storing` setting of your Uploadcare project identified by the `public_key` provided in the `auth-param`.
  - Allowed values: `0`, `false`, `1`, `true`

## Response

### 200

Success.

- `problems` (map from string to string, optional) — Dictionary of problems related to your processing job, if any. Key is the `path` you requested.
- `result` (list of ConvertVideoPostResponsesContentApplicationJsonSchemaResultItems, optional) — Result for each requested path, in case of no errors for that path.

## Errors

### 400 Bad Request Error

Simple HTTP Auth or video conversion permission errors.

- `VideoConvertRequestBadRequestError`
  - simpleAuthHTTPForbidden: simpleAuthHTTPForbidden
  - cantUseVideoConversionError: cantUseVideoConversionError
  - jsonObjectParseError: jsonObjectParseError
  - VideoConvertRequestBadRequestError3

### 401 Unauthorized Error

Authorization errors.

- `detail` (enum, optional)
  - Allowed values: `Incorrect authentication credentials.`, `Public key {public_key} not found.`, `Secret key not found.`, `Invalid signature. Please check your Secret key.`

### 406 Not Acceptable Error

Invalid version header `Accept` for this endpoint.

- `detail` (string, optional, default: Incorrect Accept header provided. Make sure to specify API version. Refer to REST API docs for details.)

## Types

### ConvertVideoPostResponsesContentApplicationJsonSchemaResultItems

- `original_source` (string, optional) — Input file identifier including operations, if present.
- `uuid` (string, optional) — A UUID of your processed video file.
- `token` (integer, optional) — A processing job token that can be used to get a job status.
- `thumbnails_group_uuid` (string, optional) — UUID of a file group with thumbnails for an output video, based on the `thumbs` operation parameters.

### simpleAuthHTTPForbidden

- `detail` (string, optional, default: Simple authentication over HTTP is forbidden. Please, use HTTPS or signed requests instead.)

### cantUseVideoConversionError

- `detail` (string, optional, default: Video conversion feature is not available for this project.)

### jsonObjectParseError

- `detail` (string, optional) — Expected JSON object.

### VideoConvertRequestBadRequestError3

- `detail` (string, optional, default: “paths” parameter is required.)

## Examples

**Request**

```json
{
  "paths": [
    "d52d7136-a2e5-4338-9f45-affbf83b857d/video/",
    "d52d7136-a2e5-4338-9f45-affbf83b857d/video/-/format/ogg/-/quality/best/",
    "28843a09-dd3d-4b8a-ad4f-8aa5f8f60ff2"
  ],
  "store": "1"
}
```

**Response**

```json
{
  "problems": {
    "13cd56e2-f6d7-4c66-ab1b-ffd13cd6646d": "Bad path \"13cd56e2-f6d7-4c66-ab1b-ffd13cd6646d\". Use UUID or CDN URL"
  },
  "result": [
    {
      "original_source": "d52d7136-a2e5-4338-9f45-affbf83b857d/video/-/format/ogg/-/quality/best/",
      "uuid": "d52d7136-a2e5-4338-9f45-affbf83b857d",
      "token": 445630631,
      "thumbnails_group_uuid": "575ed4e8-f4e8-4c14-a58b-1527b6d9ee46~1"
    },
    {
      "original_source": "500196bc-9da5-4aaf-8f3e-70a4ce86edae/video/",
      "uuid": "28843a09-dd3d-4b8a-ad4f-8aa5f8f60ff2",
      "token": 445630637,
      "thumbnails_group_uuid": "be3b4d5e-179d-460e-8a5d-69112ac86cbb~1"
    }
  ]
}
```

**SDK Code**

```php PHP
<?php
use Uploadcare\Interfaces\Conversion\ConvertedItemInterface;
use Uploadcare\Interfaces\Response\ResponseProblemInterface;
$configuration = Uploadcare\Configuration::create((string) $_ENV['UPLOADCARE_PUBLIC_KEY'], (string) $_ENV['UPLOADCARE_SECRET_KEY']);

$api = (new Uploadcare\Api($configuration))->conversion();
$request = (new Uploadcare\Conversion\VideoEncodingRequest())
    ->setHorizontalSize(1024)
    ->setVerticalSize(768)
    ->setResizeMode('preserve_ratio')
    ->setTargetFormat('mp4');
$result = $api->convertVideo('1bac376c-aa7e-4356-861b-dd2657b5bfd2', $request);
if ($result instanceof ConvertedItemInterface) {
    echo \sprintf('Conversion requested. Key is \'%s\'', $result->getToken());
}
if ($result instanceof ResponseProblemInterface) {
    echo \sprintf('Error in request: %s', $result->getReason());
}

```

```python Python
from pyuploadcare import Uploadcare
uploadcare = Uploadcare(public_key='YOUR_PUBLIC_KEY', secret_key='YOUR_SECRET_KEY')

transformation = (
    VideoTransformation()
    .format(VideoFormat.mp4)
    .size(width=640, height=480, resize_mode=ResizeMode.add_padding)
    .quality(Quality.lighter)
    .cut(start_time="0:1.535", length="0:10.0")
    .thumbs(10)
)

path = transformation.path('1bac376c-aa7e-4356-861b-dd2657b5bfd2')
response = uploadcare.video_convert_api.convert([path])
video_convert_info = response.result[0]
converted_file = uploadcare.file(video_convert_info.uuid)
video_convert_status = uploadcare.video_convert_api.status(video_convert_info.token)

```

```ruby Ruby
require 'uploadcare'
Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'

video_params = {
  uuid: '1bac376c-aa7e-4356-861b-dd2657b5bfd2',
  format: :mp4,
  quality: :lighter
}
options = { store: true }
Uploadcare::VideoConverter.convert(video_params, options)

```

```swift Swift
import Uploadcare

let uploadcare = Uploadcare(withPublicKey: "YOUR_PUBLIC_KEY", secretKey: "YOUR_SECRET_KEY")

let file = try await uploadcare.fileInfo(withUUID: "1bac376c-aa7e-4356-861b-dd2657b5bfd2")
let settings = VideoConversionJobSettings(forFile: videoFile)
  .format(.mp4)
  .size(VideoSize(width: 640, height: 480))
  .resizeMode(.addPadding)
  .quality(.lighter)
  .cut( VideoCut(startTime: "0:0:5.000", length: "15") )
  .thumbs(10)

let response = try await uploadcare.convertVideosWithSettings([settings])
print(response)

```

```kotlin Kotlin
import com.uploadcare.android.library.api.UploadcareClient

val uploadcare = UploadcareClient(publicKey = "YOUR_PUBLIC_KEY", secretKey = "YOUR_SECRET_KEY")

val conversionJob = VideoConversionJob(fileId = "1bac376c-aa7e-4356-861b-dd2657b5bfd2")
    .apply {
        setFormat(VideoFormat.MP4)
        resize(width = 640, height = 480, resizeMode = VideoResizeMode.LETTERBOX)
        quality(VideoQuality.LIGHTER)
        cut(startTime = "0:0:5.000", length = "15")
        thumbnails(10)
    }
val converter = VideoConverter(uploadcare, listOf(conversionJob))
val response = converter.convertWithResultData()
Log.d("TAG", response.toString())

```

```javascript
const url = 'https://api.uploadcare.com/convert/video/';
const options = {
  method: 'POST',
  headers: {
    Accept: 'application/vnd.uploadcare-v0.7+json',
    Authorization: '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"paths":["d52d7136-a2e5-4338-9f45-affbf83b857d/video/","d52d7136-a2e5-4338-9f45-affbf83b857d/video/-/format/ogg/-/quality/best/","28843a09-dd3d-4b8a-ad4f-8aa5f8f60ff2"],"store":"1"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.uploadcare.com/convert/video/"

	payload := strings.NewReader("{\n  \"paths\": [\n    \"d52d7136-a2e5-4338-9f45-affbf83b857d/video/\",\n    \"d52d7136-a2e5-4338-9f45-affbf83b857d/video/-/format/ogg/-/quality/best/\",\n    \"28843a09-dd3d-4b8a-ad4f-8aa5f8f60ff2\"\n  ],\n  \"store\": \"1\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Accept", "application/vnd.uploadcare-v0.7+json")
	req.Header.Add("Authorization", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.uploadcare.com/convert/video/")
  .header("Accept", "application/vnd.uploadcare-v0.7+json")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"paths\": [\n    \"d52d7136-a2e5-4338-9f45-affbf83b857d/video/\",\n    \"d52d7136-a2e5-4338-9f45-affbf83b857d/video/-/format/ogg/-/quality/best/\",\n    \"28843a09-dd3d-4b8a-ad4f-8aa5f8f60ff2\"\n  ],\n  \"store\": \"1\"\n}")
  .asString();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.uploadcare.com/convert/video/");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/vnd.uploadcare-v0.7+json");
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"paths\": [\n    \"d52d7136-a2e5-4338-9f45-affbf83b857d/video/\",\n    \"d52d7136-a2e5-4338-9f45-affbf83b857d/video/-/format/ogg/-/quality/best/\",\n    \"28843a09-dd3d-4b8a-ad4f-8aa5f8f60ff2\"\n  ],\n  \"store\": \"1\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```