# Complete a document upload

> Completes an upload after its bytes were PUT: the document appears in the trip's Documents tab — internal (`visibility: staff`) unless you release it with `visibility: traveler`, optionally into a folder (`folderId`), as dropping a file on a visible folder does.

`POST /v1/documents/{documentId}/complete`

Completes an upload after its bytes were PUT: the document appears in the trip's Documents tab — internal (`visibility: staff`) unless you release it with `visibility: traveler`, optionally into a folder (`folderId`), as dropping a file on a visible folder does. The recorded size and type are the ones storage received. Nothing uploaded yet is a 422 `upload_missing`; a second completion a 409 `already_complete`. Undo with POST /changes/{changeId}/revert: it deletes the upload while nobody has changed it since.

**Permissions:** `documents:write` · **Kind:** write · **Cost:** 1 unit · MCP tool [`complete_document_upload`](https://api.bymundi.com/docs/mcp/tools/complete_document_upload.md)

Undoable: the response carries `Bymundi-Change-Id`; [revert it](https://api.bymundi.com/docs/guides/undo-and-dry-run.md) with `POST /v1/changes/{changeId}/revert`.

## Path parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `documentId` | uuid | yes |  |

## Body

| Field | Type | Required | Description |
|---|---|---|---|
| `visibility` | "staff" \| "traveler" |  | `staff` (the default) keeps it internal; `traveler` releases it to the trip's travelers. default "staff" |
| `folderId` | uuid \| null |  | File it in this folder of the trip; null or absent = loose. |

## Response `200`

| Field | Type | Required | Description |
|---|---|---|---|
| `object` | "document" | yes |  |
| `id` | uuid | yes |  |
| `tripId` | uuid | yes |  |
| `folderId` | uuid \| null | yes | The folder it is filed in; null = loose (in no folder). |
| `name` | string | yes |  |
| `mimeType` | string | yes |  |
| `byteSize` | integer | yes | ≥ 0 |
| `status` | "pending" \| "ready" | yes | `pending`: reserved, the upload is not complete — never listed. `ready`: a document. |
| `visibility` | "staff" \| "traveler" | yes | `staff`: internal, only the agency sees it. `traveler`: released to the trip's travelers. |
| `visibleToTravelersNow` | boolean | yes | Released AND the trip is published: the traveler's app shows it right now. |
| `visibleAt` | string \| null | yes | When it was last released to travelers; null while internal. |
| `visibleBy` | object \| null | yes |  |
| `visibleBy.id` | string | yes |  |
| `visibleBy.name` | string \| null | yes |  |
| `uploadedBy` | object \| null | yes |  |
| `uploadedBy.id` | string | yes |  |
| `uploadedBy.name` | string \| null | yes |  |
| `createdAt` | string | yes |  |
| `updatedAt` | string | yes |  |
| `appUrl` | string \| null | yes | The trip's Documents tab in bymundi. |

## Errors

Errors are [problem details](https://api.bymundi.com/docs/guides/errors.md). Besides the refusals described above, any call like this one can return:

- [`invalid_request`](https://api.bymundi.com/problems/invalid_request.md) — Invalid request
- [`unauthorized`](https://api.bymundi.com/problems/unauthorized.md) — Missing or invalid API key
- [`insufficient_scope`](https://api.bymundi.com/problems/insufficient_scope.md) — Missing permission
- [`rate_limited`](https://api.bymundi.com/problems/rate_limited.md) — Rate limit reached
- [`not_found`](https://api.bymundi.com/problems/not_found.md) — Not found
- [`idempotency_key_reused`](https://api.bymundi.com/problems/idempotency_key_reused.md) — Idempotency-Key reused
- [`request_in_progress`](https://api.bymundi.com/problems/request_in_progress.md) — Request in progress

## Examples

#### curl

```bash
curl -X POST https://api.bymundi.com/v1/documents/$DOCUMENT_ID/complete \
  -H "Authorization: Bearer $BYMUNDI_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{}'
```

#### JavaScript

```javascript
const res = await fetch(`https://api.bymundi.com/v1/documents/${documentId}/complete`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BYMUNDI_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({}),
});
if (!res.ok) throw new Error((await res.json()).detail);
const data = await res.json();
```

#### Python

```python
import os, uuid, requests

res = requests.post(
    f"https://api.bymundi.com/v1/documents/{documentId}/complete",
    headers={"Authorization": f"Bearer {os.environ['BYMUNDI_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={},
)
res.raise_for_status()
data = res.json()
```
