---
title: "Upload a file"
description: "Start uploading a JPEG, PNG or WebP photo (up to 10 MB: a new influencer's photo, a picture to work from, or a video's start or end frame), an MP4 clip (up to 50 MB, at least 1 second long) or a WAV, MP3 or M4A recording (up to 10 MB), for reference media. Send the bytes to `upload.url` with a PUT and the headers given, then complete it. It costs nothing."
url: "https://docs.layo.co/reference/uploads/create"
---

> For agents: every page is listed at https://docs.layo.co/llms.txt. Search the docs over MCP at https://docs.layo.co/mcp, no sign-in needed.

# Upload a file

`POST https://layo.co/v1/uploads`

Needs the `generate` scope. No charge. MCP tool: `create_upload`.

Start uploading a JPEG, PNG or WebP photo (up to 10 MB: a new influencer's photo, a picture to work from, or a video's start or end frame), an MP4 clip (up to 50 MB, at least 1 second long) or a WAV, MP3 or M4A recording (up to 10 MB), for reference media. Send the bytes to `upload.url` with a PUT and the headers given, then complete it. It costs nothing.

## Request

### curl

```bash
curl -X POST https://layo.co/v1/uploads \
  -H "Authorization: Bearer $LAYO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mimeType":"image/jpeg","byteSize":482113}'
```

### TypeScript

```ts
const response = await fetch("https://layo.co/v1/uploads", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.LAYO_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({"mimeType":"image/jpeg","byteSize":482113}),
});
const data = await response.json();
```

### Python

```python
import os
import requests

response = requests.post(
    "https://layo.co/v1/uploads",
    headers={"Authorization": f"Bearer {os.environ['LAYO_API_KEY']}"},
    json={"mimeType":"image/jpeg","byteSize":482113},
)
data = response.json()
```

## Body

- `mimeType` (`enum<string>`, required, one of `image/jpeg`, `image/png`, `image/webp`, `video/mp4`, `audio/wav`, `audio/mpeg`, `audio/mp4`): The file's format: `image/jpeg`, `image/png` or `image/webp` for a photo, `video/mp4` for a clip, `audio/wav`, `audio/mpeg` (MP3) or `audio/mp4` (M4A) for a recording.
- `byteSize` (`integer`, required, `0 < x <= 52428800`): The file's exact size in bytes: up to 10 MB for a photo, 50 MB for a clip, 10 MB for a recording.

## Response

- `id` (`string<uuid>`, required): The upload's id: complete it, then pass it where its kind goes (a photo in `photoIds` or `imageIds`, or any file as an item's `id` in a video's `medias`).
- `upload` (`object`, required)
  - `url` (`string`, required): Send the file's bytes here with an HTTP PUT, before `expiresIn` seconds.
  - `headers` (`object`, required): Send exactly these headers with the PUT, plus a Content-Length equal to `byteSize`: the link is signed for that length, so a chunked upload is refused.
  - `expiresIn` (`integer`, required, `x >= -9007199254740991`): Seconds the link lasts from now.

## Errors

- `invalid_input` (400): Something in this request wasn't valid. Check it and try again.
- `invalid_api_key` (401): This key isn't valid. Make a new one at layo.co/api-keys.
- `insufficient_scope` (403): This key can't do that. Use a key with the scope this endpoint needs.
- `forbidden` (403): You don't have access to that in this workspace.
- `rate_limited` (429): Too many requests. Wait a moment and try again.
- `unavailable` (503): Layo had a problem. Try again shortly.

## Examples

### 200

```json
{
  "id": "0d6c1f2e-8a4b-4c3d-9e5f-7a1b2c3d4e5f",
  "upload": {
    "url": "https://storage.example.com/upload?signature=…",
    "headers": {
      "content-type": "image/jpeg",
      "if-none-match": "*"
    },
    "expiresIn": 600
  }
}
```

### 400 `invalid_input`

```json
{
  "error": {
    "code": "invalid_input",
    "message": "Something in this request wasn't valid. Check it and try again."
  }
}
```

### 401 `invalid_api_key`

```json
{
  "error": {
    "code": "invalid_api_key",
    "message": "This key isn't valid. Make a new one at layo.co/api-keys."
  }
}
```

### 403 `insufficient_scope`

```json
{
  "error": {
    "code": "insufficient_scope",
    "message": "This key can't do that. Use a key with the scope this endpoint needs."
  }
}
```

### 403 `forbidden`

```json
{
  "error": {
    "code": "forbidden",
    "message": "You don't have access to that in this workspace."
  }
}
```

### 429 `rate_limited`

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Too many requests. Wait a moment and try again."
  }
}
```

### 503 `unavailable`

```json
{
  "error": {
    "code": "unavailable",
    "message": "Layo had a problem. Try again shortly."
  }
}
```

The whole API as OpenAPI: https://docs.layo.co/openapi.json
