# Uploads and documents

> Signed PUT address, checks, types and limits.

Source: https://flow-marketing.org/en/help/api-uploads-and-documents · Question: How do I upload images, logos and documents for the API?

Files never travel in the JSON body. You create an upload, PUT the file to a signed address and complete it. Only then does Flow Marketing check the file header and scan for viruses, and release the file.

Afterwards you use images and logos as upl_… in the brand and in style film fields. PowerPoint, PDF and Word go through /documents and become a video.

## Three steps {#ablauf}

The signed address points into a quarantine on our storage. No file is used before `/complete` has checked it. Uploads that are never completed are deleted with their file after 24 hours.

1. `POST /uploads` (or `POST /documents`) with file name and exact size in bytes. The answer contains `upload_url`, `upload_method` (`PUT`), `upload_headers` and `upload_expires_in_s` (900 = 15 minutes).
2. PUT the file to `upload_url` with exactly the headers from `upload_headers`. For `/uploads`, type and size are part of the signature: the file must be exactly `size_bytes` long.
3. `POST /uploads/{id}/complete` (or `/documents/{id}/complete`). Now the checks run. On success `status` is `ready`.

**curl**

```bash
# 1. create (size_bytes = exact file size)
curl -X POST https://flow-marketing.org/api/turbo/v1/uploads \
  -H "Authorization: Bearer $FLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"kind\": \"logo\", \"filename\": \"logo.png\", \"size_bytes\": $(wc -c < logo.png)}"

# 2. upload the file to upload_url within 15 minutes (headers from upload_headers)
curl -X PUT "$UPLOAD_URL" -H "Content-Type: image/png" --data-binary @logo.png

# 3. complete: header check, virus scan, image check
curl -X POST https://flow-marketing.org/api/turbo/v1/uploads/upl_4dF6gH8jK0lZ2xC4vB6n/complete \
  -H "Authorization: Bearer $FLOW_API_KEY"
```

**JavaScript**

```js
import { readFile } from 'node:fs/promises'

const BASE = 'https://flow-marketing.org/api/turbo/v1'
const H = { Authorization: 'Bearer ' + process.env.FLOW_API_KEY, 'Content-Type': 'application/json' }
const file = await readFile('logo.png')

// 1. create
const up = await (await fetch(BASE + '/uploads', {
  method: 'POST',
  headers: H,
  body: JSON.stringify({ kind: 'logo', filename: 'logo.png', size_bytes: file.length }),
})).json()

// 2. PUT to the signed URL (15 minutes)
const put = await fetch(up.upload_url, { method: up.upload_method, headers: up.upload_headers, body: file })
if (!put.ok) throw new Error('upload failed: ' + put.status)

// 3. complete
const done = await (await fetch(BASE + '/uploads/' + up.id + '/complete', { method: 'POST', headers: H })).json()
console.log(done.id, done.status) // 'ready' → use done.id as brand.logo
```

**Python**

```python
import os, requests

BASE = "https://flow-marketing.org/api/turbo/v1"
H = {"Authorization": "Bearer " + os.environ["FLOW_API_KEY"]}
data = open("logo.png", "rb").read()

# 1. create
up = requests.post(BASE + "/uploads", headers=H, json={"kind": "logo", "filename": "logo.png", "size_bytes": len(data)}, timeout=30).json()

# 2. PUT to the signed URL (15 minutes)
put = requests.put(up["upload_url"], data=data, headers=up["upload_headers"], timeout=120)
put.raise_for_status()

# 3. complete
done = requests.post(BASE + "/uploads/" + up["id"] + "/complete", headers=H, timeout=120).json()
print(done["id"], done["status"])  # "ready" → use done["id"] as brand.logo
```

## Create an upload: POST /uploads {#upload-anlegen}

Answer 201: the upload object plus `upload_url`, `upload_method`, `upload_headers`, `upload_expires_in_s` and `max_bytes`. Unknown fields return 422. Scope: `videos:write`.

| Field | Meaning |
| --- | --- |
| `kind` | required: `image`, `logo` or `document` |
| `filename` | required, with extension; up to 160 characters |
| `size_bytes` | required: exact size, from 100 bytes up to the limit of the kind |
| `content_type` | optional; the type follows from the extension |

**Response 201**

```json
{
  "id": "upl_4dF6gH8jK0lZ2xC4vB6n",
  "object": "upload",
  "kind": "logo",
  "status": "awaiting_upload",
  "filename": "logo.png",
  "content_type": "image/png",
  "size_bytes": 48213,
  "width": null,
  "height": null,
  "sha256": null,
  "error": null,
  "created_at": "2026-11-22T09:00:00.000Z",
  "ready_at": null,
  "upload_url": "https://...",
  "upload_method": "PUT",
  "upload_headers": { "content-type": "image/png" },
  "upload_expires_in_s": 900,
  "max_bytes": 15728640
}
```

## Types and limits {#grenzen}

Uploads: at most 200 per day (UTC) and account – deleting does not free any (429 `daily_upload_limit`). At most 3 checks run at the same time per account (429 `upload_concurrency`).

We do not accept SVG because it can contain scripts. Save logos as PNG with transparency or as WebP.

| Kind | Extensions | Size | Other limits |
| --- | --- | --- | --- |
| `image`, `logo` | `.png`, `.jpg`, `.jpeg`, `.webp` (no SVG) | up to 15 MB (15,728,640 bytes) | at most 50 megapixels |
| `document` (upload) | `.pptx`, `.pdf`, `.docx` | up to 50 MB (52,428,800 bytes) | – |
| `/documents` | `.pptx`, `.pdf`, `.docx` | up to 50 MB | at most 30 documents per 24 hours and account |

## What completing checks {#pruefung}

You may repeat `/complete`: if the upload is already `ready`, it comes back unchanged. Status values: `awaiting_upload`, `checking`, `ready`, `rejected`, `failed`. On rejection the reason is in `error.code`.

- The file is there and has the announced size.
- The file header matches the extension (PNG, JPEG, WebP; PDF starts with `%PDF-`, PowerPoint and Word are ZIP files).
- Images: at most 50 megapixels – checked already in the header.
- Virus scan. If something is found, the file is deleted.
- Images are saved again: rotation from the camera data applied, metadata removed.
- Image protection: nudity and intimate content are never stored.

## Upload errors {#fehler}

| Status | Code | Meaning |
| --- | --- | --- |
| 422 | `validation_failed` | field missing or unknown |
| 422 | `upload_type` | extension not allowed, or the content does not match the extension |
| 422 / 413 | `upload_size` | `size_bytes` outside the limit, file empty or too large |
| 409 | `upload_missing` | the file has not been uploaded yet |
| 409 | `upload_busy` | being checked right now (`Retry-After: 5`) |
| 409 | `upload_state` | can no longer be completed (for example rejected) |
| 422 | `upload_image_too_large` | more than 50 megapixels |
| 422 | `upload_image_invalid` | image cannot be read |
| 422 | `upload_virus` | virus found, file deleted |
| 422 | `image_not_allowed` | rejected by image protection |
| 503 | `upload_scan_unavailable` | virus check not possible right now; the file stays in quarantine – complete again in a minute |
| 503 | `upload_image_check_unavailable`, `image_check_unavailable` | image check not possible right now; same as above |
| 429 | `upload_concurrency` | more than 3 checks at the same time |
| 429 | `daily_upload_limit` | 200 uploads reached for today |

## Using uploads {#verwenden}

Uploads of kind `document` are not used by any video field yet. For videos from PowerPoint, PDF or Word use `/documents`.

- `brand.logo` and `brand.logo_dark` in `POST /videos` and `PATCH /videos/{id}`: uploads of kind `logo` or `image`.
- Logo and image fields of style film templates: logo fields take `logo` or `image`, image fields only `image`.
- Only finished uploads (`ready`) of the same account and mode. A test key cannot use live uploads.

## Reading and deleting uploads {#uploads-verwalten}

`GET /uploads` returns the last 100 uploads of the mode, without pages. `GET /uploads/{id}` shows the state – never the content or storage paths. `DELETE /uploads/{id}` deletes file and entry; answer `{"id", "object": "upload", "deleted": true}`.

The upload object: `id`, `kind`, `status`, `filename`, `content_type`, `size_bytes`, `width`, `height`, `sha256` (after the check), `error`, `created_at`, `ready_at`.

## Documents: POST /documents {#dokumente}

For videos from PowerPoint (.pptx), PDF and Word (.docx). Export Google Slides as .pptx or PDF first. Body: `filename` (with extension), `size_bytes` (integer, at most 50 MB), optional `content_type`. Answer 201 with the document object and upload details as with `/uploads` (PUT, 15 minutes).

After the PUT, `POST /documents/{id}/complete` reads the file: header, virus scan, then slides or pages. Reading happens on our own server; the file goes to no third-party service. Reading is free. Then build the video with `POST /videos/from-document`.

Errors of the document check have codes starting with `document_`; `detail` says what does not fit.

**curl**

```bash
# 1. create
curl -X POST https://flow-marketing.org/api/turbo/v1/documents \
  -H "Authorization: Bearer $FLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"filename\": \"pitch.pptx\", \"size_bytes\": $(wc -c < pitch.pptx)}"

# 2. PUT the file (headers from upload_headers)
curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation" \
  --data-binary @pitch.pptx

# 3. complete: type check, virus scan, read slides
curl -X POST https://flow-marketing.org/api/turbo/v1/documents/dok_8sD0fG2hJ4kL6zX8cV0b/complete \
  -H "Authorization: Bearer $FLOW_API_KEY"
```

**JavaScript**

```js
import { readFile } from 'node:fs/promises'

const BASE = 'https://flow-marketing.org/api/turbo/v1'
const H = { Authorization: 'Bearer ' + process.env.FLOW_API_KEY, 'Content-Type': 'application/json' }
const file = await readFile('pitch.pptx')

const doc = await (await fetch(BASE + '/documents', {
  method: 'POST',
  headers: H,
  body: JSON.stringify({ filename: 'pitch.pptx', size_bytes: file.length }),
})).json()
await fetch(doc.upload_url, { method: doc.upload_method, headers: doc.upload_headers, body: file })
const read = await (await fetch(BASE + '/documents/' + doc.id + '/complete', { method: 'POST', headers: H })).json()
console.log(read.status, read.title, read.pages_total, read.warnings)
```

**Python**

```python
import os, requests

BASE = "https://flow-marketing.org/api/turbo/v1"
H = {"Authorization": "Bearer " + os.environ["FLOW_API_KEY"]}
data = open("pitch.pptx", "rb").read()

doc = requests.post(BASE + "/documents", headers=H, json={"filename": "pitch.pptx", "size_bytes": len(data)}, timeout=30).json()
requests.put(doc["upload_url"], data=data, headers=doc["upload_headers"], timeout=300).raise_for_status()
read = requests.post(BASE + "/documents/" + doc["id"] + "/complete", headers=H, timeout=300).json()
print(read["status"], read["title"], read["pages_total"], read["warnings"])
```

**Response to complete (shortened)**

```json
{
  "id": "dok_8sD0fG2hJ4kL6zX8cV0b",
  "object": "document",
  "status": "ready",
  "kind": "pptx",
  "filename": "pitch.pptx",
  "size_bytes": 2483910,
  "error_code": null,
  "title": "Musterwerk 2027",
  "language": "de",
  "pages_total": 12,
  "pages": [
    { "number": 1, "title": "Musterwerk 2027", "hidden": false, "bullets": 0, "has_notes": true, "numbers": [], "chart": null, "table": false, "images": 1 },
    { "number": 2, "title": "Umsatz", "hidden": false, "bullets": 3, "has_notes": true, "numbers": [{ "value": 42, "unit": "%" }], "chart": { "title": "Umsatz je Quartal", "points": 4 }, "table": false, "images": 0 }
  ],
  "images": 5,
  "warnings": [],
  "video_id": null,
  "created_at": "2026-11-22T09:00:00.000Z",
  "delete_after": "2026-11-29T09:00:00.000Z"
}
```

## The document object {#dokument-objekt}

`GET /documents/{id}` shows the state and what was read – only the structure, never the full content. `DELETE /documents/{id}` deletes the document with its images; answer `{"id", "object": "document", "deleted": true}`. There is no list of all documents.

| Field | Meaning |
| --- | --- |
| `id` | `dok_` plus 20 characters |
| `status` | `awaiting_upload`, `processing`, `ready`, `rejected`, `failed`, `deleted` |
| `kind` | `pptx`, `pdf` or `docx` |
| `filename`, `size_bytes` | as announced |
| `error_code` | reason on rejection, otherwise `null` |
| `title`, `language` | title and language read (`de` or `en`) |
| `pages_total` | number of slides or pages |
| `pages` | per page: `number`, `title`, `hidden`, `bullets` (number of points), `has_notes`, `numbers` (`value`, `unit`), `chart` (`title`, `points`), `table`, `images` |
| `images` | number of images |
| `warnings` | notes with `code`, `de`, `en` |
| `video_id` | the video last built from it |
| `created_at`, `delete_after` | created; when we delete document and images |

## See also

- [Videos (brand, from-document)](https://flow-marketing.org/en/help/api-videos)
- [Templates (style film fields)](https://flow-marketing.org/en/help/api-templates)
- [Upload failed](https://flow-marketing.org/en/help/upload-failed)
