# API reference: Uploads

> The Uploads endpoints (4 operations), generated from the OpenAPI document (https://faraatarjomeh.com/api/v1/openapi.json). For task-level walkthroughs use the guides; for error handling use /api/v1/docs/errors. The full reference: /api/v1/docs/reference.

## At a glance

- Auth on every call: `Authorization: Bearer $FARA_API_KEY`
- `scope`: `read` for GET/HEAD, `write` for the rest
- **spends Fara**: the call holds or charges Fara; get the price first and send `Idempotency-Key`
- Path parameters in the examples are shell variables (`$JOB_ID`, `$ID` …)
- Errors: `application/problem+json` with a stable `code` (not repeated per endpoint below)

## Index

- **Uploads**: [POST /api/v1/uploads](#startUpload), [GET /api/v1/uploads/{uploadId}](#getUpload), [DELETE /api/v1/uploads/{uploadId}](#cancelUpload), [PUT /api/v1/uploads/{uploadId}/chunks/{index}](#putUploadChunk)

## Uploads

Send a large recording or video in chunks, then make a meeting, transcription or video job from it.

<a id="startUpload"></a>
### POST /api/v1/uploads

Start a chunked upload

- operationId `startUpload` · scope `write` · free · send `Idempotency-Key`

Starts an upload for a meeting or transcription recording, or for a video to translate, up to 1 GB. Free: nothing is held or charged until the job is created. Counts as one upload toward the per-account upload limit; the chunks and the job create made from it do not. The answer gives `chunkSize` and `totalChunks`. An upload not used within 24 hours is deleted. At most 10 uploads can be open at once (`UPLOAD_LIMIT_REACHED`). When we are short of room for a very large file the answer is 503 `SERVICE_UNAVAILABLE` with `Retry-After`.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Request body** `application/json` (required)

[`UploadStartRequest`](#schema-upload-start-request)

**Response `201`**

[`UploadSession`](#schema-upload-session)

**Responses**

- `201` Started. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/uploads" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"purpose":"meeting","size":1}'
```

<a id="getUpload"></a>
### GET /api/v1/uploads/{uploadId}

Read an upload

- operationId `getUpload` · scope `read` · free

`received` lists the chunks that arrived. After a lost connection, send only the missing ones. A used upload shows `status: used` and its `jobId`.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `uploadId` | path | string | yes | Upload id (`upl_...`) returned when the upload started. |

**Response `200`**

[`UploadSession`](#schema-upload-session)

**Responses**

- `200` The upload. (`application/json`)
- Errors: `401`, `403`, `404`, `410`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/uploads/$UPLOAD_ID" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="cancelUpload"></a>
### DELETE /api/v1/uploads/{uploadId}

Cancel an upload

- operationId `cancelUpload` · scope `write` · free · send `Idempotency-Key`

Deletes the chunks. Cancelling again answers 204 too. An upload that already made a job answers 409 `UPLOAD_ALREADY_USED`.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `uploadId` | path | string | yes | Upload id (`upl_...`) returned when the upload started. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Responses**

- `204` Cancelled.
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X DELETE "https://faraatarjomeh.com/api/v1/uploads/$UPLOAD_ID" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="putUploadChunk"></a>
### PUT /api/v1/uploads/{uploadId}/chunks/{index}

Send one chunk

- operationId `putUploadChunk` · scope `write` · free · send `Idempotency-Key`

The body is the chunk's raw bytes (`Content-Type: application/octet-stream`). Index 0 is the start of the file. Every chunk is exactly `chunkSize` bytes except the last, which is the rest (`BAD_CHUNK` otherwise). Chunks can come in any order and in parallel. Sending the same index again replaces it, so a retry after a timeout is always safe and needs no `Idempotency-Key`. With a `Content-Digest` header (RFC 9530, `sha-256=:<base64>:`) a chunk that does not match is refused with `CHUNK_DIGEST_MISMATCH`. Counts toward the per-key request limit, not toward the upload limit.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `uploadId` | path | string | yes | Upload id (`upl_...`) returned when the upload started. |
| `index` | path | integer | yes | Chunk index, from 0 to `totalChunks - 1`. — min 0 |
| `Content-Digest` | header | string | no | Optional RFC 9530 digest of this chunk, for example `sha-256=:X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=:`. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Request body** `application/octet-stream` (required)

**Response `200`**

[`UploadSession`](#schema-upload-session)

**Responses**

- `200` The upload, with this index in `received`. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `410`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X PUT "https://faraatarjomeh.com/api/v1/uploads/$UPLOAD_ID/chunks/$INDEX" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

## Schemas

Named request and response objects used above. Nested objects are flattened as `parent.child`; arrays as `parent[].child`.

<a id="schema-upload-session"></a>
### UploadSession

| Field | Type | Required | Notes |
|---|---|---|---|
| `uploadId` | string | yes | Upload id (`upl_...`). Send it as `uploadId` when you create the job. |
| `purpose` | string | no | one of: `meeting`, `transcription`, `video` |
| `filename` | string | no |  |
| `size` | integer | no | The whole file's size in bytes. |
| `chunkSize` | integer | yes | Bytes in every chunk except the last. |
| `totalChunks` | integer | yes | How many chunks make the file. Indexes run from 0 to `totalChunks - 1`. |
| `received` | integer[] | yes | Indexes of the chunks that have arrived, in order. After a lost connection, send only the others. |
| `status` | string | no | `open` (taking chunks), or `used` (a job was made from it). — one of: `open`, `used` |
| `jobId` | string \| null | no | The job made from this upload, once `status` is `used`. — may be null |
| `createdAt` | string \| null | no | may be null |
| `expiresAt` | string \| null | yes | When an unused upload and its chunks are deleted (24 hours after it started). — may be null |

<a id="schema-upload-start-request"></a>
### UploadStartRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `purpose` | string | yes | What the file will make: `meeting` (POST /api/v1/meetings/jobs), `transcription` (POST /api/v1/transcription/jobs) or `video` (POST /api/v1/video/jobs). — one of: `meeting`, `transcription`, `video` |
| `filename` | string | no | The file's name (up to 255 characters). Kept as the job's file name. |
| `contentType` | string | no | Optional. An audio or video type, for example `audio/mp4`. The file itself is checked when the job is created. |
| `size` | integer | yes | The whole file's size in bytes, at most 1073741824. — min 1 |
| `sha256` | string | no | Optional. SHA-256 of the whole file, 64 hex characters. When given, the joined file is checked against it when the job is created. |
| `chunkSize` | integer | no | Optional. Bytes per chunk, from 262144 (256 KB) to 8388608 (8 MB, the default). Ask for smaller chunks on a slow or unstable line, so each chunk is sent before the line drops. Out of range answers 400 `BAD_REQUEST` with `minChunkSize` and `maxChunkSize`. — min 262144; max 8388608 |
