---
title: "Upload a file"
method: POST
path: "/v1/files"
tags: ["Files"]
---

# Upload a file

`POST /v1/files`

## Request

- Base URL: `https://api.dexto.ai`
- URL: `https://api.dexto.ai/v1/files`
- Auth: HTTP bearer

Upload a file of up to 80 MiB in one request: the body is its bytes, Content-Type its type and Content-Length is required. A path that already has a file is a 409 unless overwrite is true. Its storage is charged to the project from credits; without credits, or at a spend limit, the upload is refused with 402 before any byte is accepted. Larger files use an upload session.

## Query parameters

- `path` string, required: The file's path in the project, such as reports/q3.pdf.
- `overwrite` 'true' | 'false'
- `expires_at` string, date-time: Delete the file at this time. Files are kept until deleted when omitted.

## Headers

- `Content-Length` string, required
- `X-Content-SHA256` string

## Request body `application/octet-stream`

- string, binary

## Response `200`

Replaced the file at this path.

- object
  - `content_type` string, required
  - `created_at` string, date-time, required
  - `created_by` object, required: The key, agent or person that wrote the file first; a key or agent is null once deleted.
    - `agent_id` string, uuid, nullable, required
    - `api_key_id` string, uuid, nullable, required
    - `user_id` string, nullable, required: The person who wrote it, by their key or an OAuth token; null for agents and deployed code.
  - `expires_at` string, date-time, nullable, required
  - `id` string, uuid, required
  - `metadata` object, required
  - `object` 'file', required
  - `path` string, required
  - `sha256` string, required
  - `size_bytes` integer, required
  - `updated_at` string, date-time, required

## Other responses

- `201`: Created the file.
- `400`: Invalid JSON or request fields.
- `401`: Missing or invalid API key.
- `402`: The account has insufficient credits.
- `403`: The account cannot perform this operation.
- `404`: The requested resource was not found.
- `409`: The request conflicts with existing resource state.
- `429`: The account exceeded this operation's request rate.
- `500`: Unexpected Dexto failure.
- `502`: The upstream model provider failed.
- `503`: A required Dexto service is temporarily unavailable.

---

[API](https://skmtc.dev/dexto/apis/dexto-api.md) - [All operations](https://skmtc.dev/dexto/apis/dexto-api/llms.txt) - [OpenAPI document](https://skmtc.dev/dexto/apis/dexto-api/revisions/47eb880cffa5?raw)
