> ## Documentation Index
> Fetch the complete documentation index at: https://docs.engramme.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Files

> List, download, and delete uploaded source files

File endpoints let you inspect and manage uploaded source files. They require an API key with access to the relevant source type.

<Note>
  These examples require an all-source key or a key that includes the requested `SOURCE_TYPE`.
</Note>

## Endpoints

| Method   | Endpoint                            | Description                    |
| -------- | ----------------------------------- | ------------------------------ |
| `GET`    | `/v1/files/list`                    | List files for a `source_type` |
| `GET`    | `/v1/files/download`                | Download a file by `item_id`   |
| `DELETE` | `/v1/files/{source_type}/{item_id}` | Delete a file                  |

## List Files

Query parameters:

| Parameter     | Required | Description                                                      |
| ------------- | -------- | ---------------------------------------------------------------- |
| `source_type` | Yes      | Source type to list, such as `text` or `email`                   |
| `limit`       | No       | Page size. Defaults to `1000`; max `10000`                       |
| `offset`      | No       | Pagination offset                                                |
| `start_date`  | No       | Accepted by the API, but date filtering is not currently applied |

```bash theme={null}
export SOURCE_TYPE="text"

curl "https://memorymachines-gateway-prod-btf57kda.uc.gateway.dev/v1/files/list?source_type=$SOURCE_TYPE" \
  -H "x-api-key: $ENGRAMME_API_KEY"
```

## Download a File

`source_type` is optional for download. Include it when you know the source; omitting it asks the API to search sources available to the key.

```bash theme={null}
export SOURCE_TYPE="text"
export ITEM_ID="YOUR_ITEM_ID"

curl "https://memorymachines-gateway-prod-btf57kda.uc.gateway.dev/v1/files/download?item_id=$ITEM_ID&source_type=$SOURCE_TYPE" \
  -H "x-api-key: $ENGRAMME_API_KEY"
```

## Delete a File

```bash theme={null}
export SOURCE_TYPE="text"
export ITEM_ID="YOUR_ITEM_ID"

curl -X DELETE "https://memorymachines-gateway-prod-btf57kda.uc.gateway.dev/v1/files/$SOURCE_TYPE/$ITEM_ID" \
  -H "x-api-key: $ENGRAMME_API_KEY"
```

<Warning>
  Deletes are destructive. Use source-scoped keys carefully when building file management tools.
</Warning>
