---
title: "Create a file upload"
locale: en
url: https://tlg.builera.app/en/docs/reference/rest/files.create_upload
verified: 2026-10-24
app_version: "2.0"
generated: true
---

# Create a file upload

Step 1 for an agent to send a new file: give the purpose (message = send / album, story = post a story, photo = account / group / bot photo, campaign = a campaign "send file" block), accountId (or campaignId), file name, type and size. Returns `uploadUrl` (PUT the raw bytes with `headers`, valid 2 hours), then call files.complete_upload. Up to 50 MB (profile photos 10 MB); 20 waiting + 50 ready-unused files per connection. If you cannot PUT, give the user the link to upload it themselves.

Step 1 for an agent to send a new file: give the purpose (message = send / album, story = post a story, photo = account / group / bot photo, campaign = a campaign "send file" block), accountId (or campaignId), file name, type and size. Returns `uploadUrl` (PUT the raw bytes with `headers`, valid 2 hours), then call files.complete_upload. Up to 50 MB (profile photos 10 MB); 20 waiting + 50 ready-unused files per connection. If you cannot PUT, give the user the link to upload it themselves.

## Overview

| Name | Value |
| --- | --- |
| Code | `files.create_upload` |
| Scope needed | `messages.send` |
| Risk | Write |
| May need confirmation | No |
| Runs as | Answers right away |
| Needs `Idempotency-Key` | No |
| Member roles allowed | `owner`, `manager`, `agent` |
| In the app | Assistant (Build 2.1) |

## Input fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `purpose` | `"message" \| "story" \| "photo" \| "campaign"` | Yes |   |
| `accountId` | `uuid` | No |   |
| `campaignId` | `uuid` | No |   |
| `fileName` | `text` | Yes |   |
| `mime` | `text` | Yes |   |
| `size` | `integer` | Yes |   |

## Example request

```bash
curl -X POST https://tlg.builera.app/api/public/v2/ops/files.create_upload \
  -H "Authorization: Bearer $TELEGRAM_AUTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"purpose":"message","fileName":"…","mime":"…","size":1}'
```

## Output fields (`data`)

| Field | Type | Required |
| --- | --- | --- |
| `ok` | `true` | Yes |
| `uploadId` | `text` | Yes |
| `uploadUrl` | `text` | Yes |
| `method` | `"PUT"` | Yes |
| `headers` | `object` | Yes |
| `maxBytes` | `number` | Yes |
| `completeBefore` | `text` | Yes |

## Example answer

```json
{
  "data": {
    "ok": true,
    "uploadId": "00000000-0000-4000-8000-000000000000",
    "uploadUrl": "text",
    "method": "PUT",
    "headers": {
      "content-type": "text",
      "x-upsert": "text"
    },
    "maxBytes": 1,
    "completeBefore": "text"
  }
}
```

## Using it over MCP

Not listed on any profile: call `tools_describe` then `tools_run` with `code: "files.create_upload"`. Tool name when listed: `files_create_upload`.
