# Upload files

Store the images and documents a project uses as uploads, kept apart from its source code.

## Before you start

You need a project. See [Create a project](/docs/projects/create-project.md).

## Upload a file

The steps upload a short refund policy, `refund-policy.md`:

```md title="refund-policy.md"
# Refund policy

You can return any order within 30 days of delivery for a full refund.
Refunds go back to the original payment method within 5 business days.
Gift cards are not refundable.
```

**Code**

1. In your project's folder, upload `refund-policy.md`:

```bash
npx veryfront uploads put refund-policy.md --from refund-policy.md
```

2. List the project's uploads. You should now see `[file] refund-policy.md (190 bytes)`:

```bash
npx veryfront uploads list
```

### Try it in a sandbox

```playground
step: Write the file | printf '%s\n' '# Refund policy' '' 'You can return any order within 30 days of delivery for a full refund.' 'Refunds go back to the original payment method within 5 business days.' 'Gift cards are not refundable.' > refund-policy.md
step: Upload it | npx veryfront uploads put refund-policy.md --from refund-policy.md
check: npx veryfront uploads list
expect: [file] refund-policy.md
```

**Studio**

1. Open **Uploads**.
2. Click **Upload file**.
3. Choose `refund-policy.md`.
4. Click **Upload**. You should now see `refund-policy.md` in the list.

**API**

1. Set `PROJECT` to your project's ID ([Find your IDs](/docs/authentication/api-keys.md#find-your-ids)): `export PROJECT=<id>`.
2. Create the upload. Its `size_bytes` is the file's size:

```bash
SIZE=$(wc -c < refund-policy.md | tr -d ' ')
curl -X POST https://api.veryfront.com/projects/$PROJECT/uploads \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"path\":\"refund-policy.md\",\"content_type\":\"text/markdown\",\"size_bytes\":$SIZE}"
```

3. Set `UPLOAD_URL` to the `upload_url` in the response: `export UPLOAD_URL='<upload_url>'`.
4. Send the file to it, with the headers in `required_headers`:

```bash
curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: text/markdown" \
  -H "x-goog-content-length-range: 0,$SIZE" \
  --data-binary @refund-policy.md
```

5. List the uploads. You should now see `refund-policy.md` in the list with `"status": "active"`:

```bash
curl https://api.veryfront.com/projects/$PROJECT/uploads \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

## Use a file in knowledge

**Studio**

1. Open the file's menu.
2. Click **Add to knowledge base**. You should now see **Runs** open, with a Knowledge Ingest run.

## With MCP

1. Write `refund-policy.md` and read its size with `wc -c < refund-policy.md` (190).
2. Call `veryfront__create_upload` with `project_reference` (the project's slug or ID), `"path": "refund-policy.md"`, `"content_type": "text/markdown"` and `"size_bytes": 190`. It answers `"status": "pending"`, an `upload_url` and `required_headers`.
3. Send the file to `upload_url` with `curl -X PUT`, the headers in `required_headers` and `--data-binary @refund-policy.md`. It answers 200.
4. Call `veryfront__list_uploads` with `project_reference`. It worked when `refund-policy.md` is listed with `"status": "active"`.

## Next steps

* [Add knowledge](/docs/agents/knowledge.md)
* [Edit files](/docs/projects/files.md)
