# Files API

> Each user's file storage. Upload a file in three steps (create an upload, PUT the bytes, confirm), then attach it to a task or message by id.

Part of the AGNT API reference. AGNT (https://agnt.ai) is the developer platform behind OpenAssistant (https://openassistant.us). Docs index: https://agnt.ai/llms.txt. Web page: https://agnt.ai/reference/api/files

Base URL: `https://api.agnt.ai`. Auth: `Authorization: Bearer ak_live_...`.

## POST /drive-files/upload

Create a file upload

Returns a short-lived upload URL and the new file's id. PUT the bytes to `url` with the returned `contentType` as the `Content-Type` header, then confirm the upload.

Acts as one user: send `X-User-Email`.

**Request body** (JSON)

- `name` (string, required): File name
- `mimeType` (string): Detected from the name when omitted
- `size` (integer, required): Size in bytes, for the quota check
- `folder` (string | null): Folder id; omit for the root

**Responses**

- `200`: Upload URL
  - `ok` (boolean)
  - `url` (string): PUT the bytes here
  - `fileId` (string)
  - `contentType` (string)
- `400`: Invalid body or storage quota exceeded

```bash
curl 'https://api.agnt.ai/drive-files/upload' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Brightline-MSA-2026.pdf",
  "size": 48213
}'
```

Example response:

```json
{
  "ok": true,
  "url": "https://example.com",
  "fileId": "6702c804b5c6d7e8f9a0b1c2",
  "contentType": "application/pdf"
}
```

## POST /drive-files/{fileId}/confirm

Confirm a file upload

Marks an uploaded file `ready` once its bytes are in place. Confirming a ready file returns it unchanged.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `fileId` (string, required)

**Request body** (JSON)

- `size` (integer, required): Actual size in bytes

**Responses**

- `200`: File
  - `ok` (boolean)
  - `driveFile` (object)
    - `id` (string): File id; pass it as fileId in files[] on POST /tasks/{taskId}/process or POST /chats/{chatId}/process
    - `name` (string)
    - `mimeType` (string | null)
    - `size` (integer): Bytes
    - `status` (enum): pending until the upload is confirmed One of: `pending`, `ready`.
    - `folder` (string | null)
    - `createdAt` (string)
- `404`: No such file for this user

```bash
curl 'https://api.agnt.ai/drive-files/<fileId>/confirm' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "size": 48213
}'
```

Example response:

```json
{
  "ok": true,
  "driveFile": {
    "id": "6702c804b5c6d7e8f9a0b1c2",
    "name": "Brightline-MSA-2026.pdf",
    "mimeType": "application/pdf",
    "size": 48213,
    "status": "ready",
    "folder": null,
    "createdAt": "2026-10-10T14:30:00Z"
  }
}
```

## GET /drive-files/{fileId}

Retrieve a file

Retrieves a file's details. The owner can read it, and so can people a task shares it with.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `fileId` (string, required)

**Responses**

- `200`: File
  - Same fields as the `200` response of `POST /drive-files/{fileId}/confirm`.
- `404`: Not found

```bash
curl 'https://api.agnt.ai/drive-files/<fileId>' \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "driveFile": {
    "id": "6702c804b5c6d7e8f9a0b1c2",
    "name": "Brightline-MSA-2026.pdf",
    "mimeType": "application/pdf",
    "size": 48213,
    "status": "ready",
    "folder": null,
    "createdAt": "2026-10-10T14:30:00Z"
  }
}
```
