> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs-dev.ltx.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-dev.ltx.io/_mcp/server.

# Upload file

POST https://api.ltx.io/v1/upload

Generate a signed URL for uploading media files to use as input for video generation.

Returns a pre-signed URL that can be used to upload files directly to cloud storage.
The URL creates a new object and cannot overwrite an existing object. Include every header returned in `required_headers` in the upload request.
Use the returned `storage_uri` in subsequent video generation requests (e.g., `image_uri` or `video_uri` parameters).
The URL expires after 1 hour.


Reference: https://docs-dev.ltx.io/api-documentation/api-reference/upload/create-upload

## Authentication

- `Authorization` header (bearer token, required) — API key authentication

## Response

### 200

Upload URL generated successfully

- `upload_url` (string, required) — Pre-signed URL for uploading the file. Use PUT request to upload your file to this URL. The URL includes all necessary authentication and expires after 1 hour.
- `storage_uri` (string, required) — Storage URI that can be used to reference the uploaded file in subsequent API requests. Use this value in image_uri or video_uri parameters. The uploaded file will be available for 24 hours.
- `expires_at` (datetime, required) — ISO 8601 timestamp indicating when the signed URL expires (1 hour from creation).
- `required_headers` (map from string to string, required) — Headers that must be included unchanged in the upload request to cloud storage. These headers enforce the file size limit and prevent overwriting an existing object.

## Errors

### 401 Unauthorized Error

Authentication failed

- `type` (enum, required) — Response type indicator
  - Allowed values: `error`
- `error` (ErrorError, required)

### 500 Internal Server Error

An unexpected error occurred

- `type` (enum, required) — Response type indicator
  - Allowed values: `error`
- `error` (ErrorError, required)

### 503 Service Unavailable Error

Service temporarily unavailable

- `type` (enum, required) — Response type indicator
  - Allowed values: `error`
- `error` (ErrorError, required)

## Types

### ErrorError

- `type` (string, required) — Error type for programmatic handling
- `message` (string, required) — Human-readable error description

## Examples

**Response**

```json
{
  "upload_url": "https://...",
  "storage_uri": "ltx://...",
  "expires_at": "2024-01-15T12:00:00Z",
  "required_headers": {
    "x-goog-content-length-range": "0,209715200",
    "x-goog-if-generation-match": "0"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.ltx.io/v1/upload"

headers = {
    "Authorization": "Bearer YOUR_API_KEY"
}

response = requests.post(url, headers=headers)
upload_info = response.json()

# Use the signed URL to upload your file
upload_url = upload_info["upload_url"]
storage_uri = upload_info["storage_uri"]  # Use this in subsequent API requests
required_headers = upload_info["required_headers"]

with open("my-video.mp4", "rb") as f:
    requests.put(
        upload_url,
        data=f,
        headers={
            "Content-Type": "video/mp4",
            **required_headers
        }
    )

```

```typescript
const url = "https://api.ltx.io/v1/upload";

const response = await fetch(url, {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY"
  }
});

const uploadInfo = await response.json();

// Use the signed URL to upload your file
const uploadUrl = uploadInfo.upload_url;
const storageUri = uploadInfo.storage_uri; // Use this in subsequent API requests
const requiredHeaders = uploadInfo.required_headers;

const fileBuffer = await fs.promises.readFile("my-video.mp4");
await fetch(uploadUrl, {
  method: "PUT",
  body: fileBuffer,
  headers: {
    "Content-Type": "video/mp4",
    ...requiredHeaders
  }
});

```

```go
package main

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

func main() {

	url := "https://api.ltx.io/v1/upload"

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

	req.Header.Add("Authorization", "Bearer <token>")

	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.ltx.io/v1/upload")
  .header("Authorization", "Bearer <token>")
  .asString();
```