---
title: "Complete an upload"
description: "Check the uploaded file once its bytes are sent, as the studio checks its own: a photo is decoded, a clip's or a recording's length is read and answered as `durationMs`. A file that isn't what it declared, can't be read, or is too short is refused. A photo's id then goes in a new influencer's `photoIds` or an image's `imageIds`; any file's id can be an item's `id` in a video's `medias`. A recording is stored as a 16-bit mono WAV: any other (stereo, another bit depth, an MP3, an M4A) is converted on completion, and the answer's `id` is then the WAV's, a new one; use it, not the upload's. Completing the upload again within a week answers the same WAV. Completing it again answers the same."
url: "https://docs.layo.co/reference/uploads/complete"
---

> 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.

# Complete an upload

`POST https://layo.co/v1/uploads/{upload}/complete`

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

Check the uploaded file once its bytes are sent, as the studio checks its own: a photo is decoded, a clip's or a recording's length is read and answered as `durationMs`. A file that isn't what it declared, can't be read, or is too short is refused. A photo's id then goes in a new influencer's `photoIds` or an image's `imageIds`; any file's id can be an item's `id` in a video's `medias`. A recording is stored as a 16-bit mono WAV: any other (stereo, another bit depth, an MP3, an M4A) is converted on completion, and the answer's `id` is then the WAV's, a new one; use it, not the upload's. Completing the upload again within a week answers the same WAV. Completing it again answers the same.

## Request

### curl

```bash
curl -X POST https://layo.co/v1/uploads/UPLOAD_ID/complete \
  -H "Authorization: Bearer $LAYO_API_KEY"
```

### TypeScript

```ts
const response = await fetch("https://layo.co/v1/uploads/UPLOAD_ID/complete", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.LAYO_API_KEY}` },
});
const data = await response.json();
```

### Python

```python
import os
import requests

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

## Path parameters

- `upload` (`string<uuid>`, required): The upload's id, from create_upload.

## Response

- `id` (`string<uuid>`, required)
- `kind` (`enum<string>`, required, one of `image`, `video`, `audio`): `image` (a photo), `video` (a clip) or `audio` (a recording).
- `mimeType` (`enum<string>`, required, one of `image/jpeg`, `image/png`, `image/webp`, `video/mp4`, `audio/wav`)
- `byteSize` (`integer`, required, `x >= -9007199254740991`)
- `durationMs` (`integer`, `x >= -9007199254740991`): A clip's or a recording's length in milliseconds, as Layo read it.

## 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.
- `not_found` (404): Nothing with that id 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",
  "kind": "image",
  "mimeType": "image/jpeg",
  "byteSize": 482113
}
```

### 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."
  }
}
```

### 404 `not_found`

```json
{
  "error": {
    "code": "not_found",
    "message": "Nothing with that id 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
