# Tạo link tải ảnh / video

> media_create_upload — Get a short-lived signed upload URL for one image (JPG/PNG/WEBP ≤ 5 MB), GIF (≤ 15 MB) or video (MP4/MOV ≤ 50 MB).

Source: https://x.builera.app/docs/vi/reference/media_create_upload

`media_create_upload` · Đổi thiết lập trong X-Buddy

> [!NOTE]
> Mô tả kỹ thuật bằng tiếng Anh — đúng chữ AI agent đọc qua MCP.

Get a short-lived signed upload URL for one image (JPG/PNG/WEBP ≤ 5 MB), GIF (≤ 15 MB) or video (MP4/MOV ≤ 50 MB). PUT the file bytes to upload_url with the given content-type, then pass media_id in post_publish / post_schedule parts (up to 4 per part) or x_profile_update (purpose=profile) or dm_send media_ids (purpose=dm). Files are private to the workspace and removed some days after the post went out.

| | |
|---|---|
| REST | `POST /api/public/v1/media/uploads` |
| Công cụ MCP | `media_create_upload` |
| Quyền cần có | `posts.manage` — Chủ, Quản lý, Vận hành |
| Nhóm quyền | `x:publish` |
| Nhóm | Bài đăng |
| Hiện sẵn trong hồ sơ | Điều khiển nick, Khách & danh sách, Hạ tầng |

## Đầu vào {#input}

| Trường | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
| `mime_type` | `image/jpeg` · `image/png` · `image/webp` · `image/gif` · `video/mp4` · `video/quicktime` | Có | The file's type. |
| `size_bytes` | integer (1–52428800) | Có | The file's size in bytes. |
| `purpose` | `post` · `profile` · `dm` | Không | profile = avatar / banner for x_profile_update (images only); dm = the attachment of dm_send. |

## Kết quả {#output}

Trả về kết quả của thao tác trong phong bì `{ data, meta }`.

> [!IMPORTANT]
> Cần khoá idempotency (`Idempotency-Key`, 8–128 ký tự). Gửi lại cùng khoá không bao giờ làm lại việc.

## Ví dụ {#example}

### Gọi qua REST {#example-rest}

```bash
curl -X POST "https://reach-link-craft.lovable.app/api/public/v1/media/uploads" \
  -H "Authorization: Bearer $XBUDDY_API_KEY" \
  -H "Idempotency-Key: 6f1c2a90-example-key" \
  -H "Content-Type: application/json" \
  -d '{"mime_type":"image/jpeg","size_bytes":1}'
```

### Gọi qua MCP {#example-mcp}

```json
{
  "method": "tools/call",
  "params": {
    "name": "media_create_upload",
    "arguments": {
      "mime_type": "image/jpeg",
      "size_bytes": 1,
      "idempotency_key": "6f1c2a90-example-key"
    }
  }
}
```

## Lỗi có thể gặp {#errors}

| Mã | HTTP | Thử lại được |
|---|---|---|
| [`unauthorized`](/docs/vi/errors/unauthorized) | 401 | Không |
| [`key_expired`](/docs/vi/errors/key_expired) | 401 | Không |
| [`integration_revoked`](/docs/vi/errors/integration_revoked) | 401 | Không |
| [`connection_not_linked`](/docs/vi/errors/connection_not_linked) | 403 | Không |
| [`integration_paused`](/docs/vi/errors/integration_paused) | 403 | Không |
| [`workspace_integrations_paused`](/docs/vi/errors/workspace_integrations_paused) | 403 | Không |
| [`integration_authorization_lost`](/docs/vi/errors/integration_authorization_lost) | 403 | Không |
| [`workspace_suspended`](/docs/vi/errors/workspace_suspended) | 403 | Không |
| [`forbidden`](/docs/vi/errors/forbidden) | 403 | Không |
| [`invalid_input`](/docs/vi/errors/invalid_input) | 422 | Không |
| [`rate_limited`](/docs/vi/errors/rate_limited) | 429 | Có |
| [`internal`](/docs/vi/errors/internal) | 500 | Có |
| [`read_only`](/docs/vi/errors/read_only) | 403 | Không |
| [`idempotency_key_required`](/docs/vi/errors/idempotency_key_required) | 428 | Không |
| [`idempotency_conflict`](/docs/vi/errors/idempotency_conflict) | 409 | Không |
| [`idempotency_processing`](/docs/vi/errors/idempotency_processing) | 409 | Có |
| [`conflict`](/docs/vi/errors/conflict) | 409 | Không |
| [`precondition_failed`](/docs/vi/errors/precondition_failed) | 422 | Không |

[Về danh sách thao tác](/docs/vi/reference)
