> For the complete documentation index, see [llms.txt](https://docs.release.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.release.com/reference-documentation/release-api/ai-sandbox-api/file-uploads.md).

# File Uploads

The File Uploads API provides a presigned-URL workflow for uploading files that can be attached to sandbox sessions as resources. Uploads are limited to 100 MB per file.

To obtain your authentication credentials, [install the Release CLI](/cli/installation.md) and run `release auth login`. The CLI stores credentials in `~/.release.yaml`.

***

## Upload Flow

Uploading a file to a sandbox session is a two-step process:

1. **Get a presigned URL** — POST to the endpoint below with the file metadata. The response contains a `presigned_url` and an `s3_uri`.
2. **PUT the file content** — Send a `PUT` request to the `presigned_url` with the raw file bytes as the request body. Set the `Content-Type` header to the same MIME type you provided in step 1.

Once uploaded, reference the file in a session by using the `s3_uri` value when creating a session resource of type `file` (see [Session Resources](/reference-documentation/release-api/ai-sandbox-api/sessions.md#resource-types)).

***

## Get Presigned Upload URL

Returns a presigned S3 URL that you can PUT file content to, along with an S3 URI for referencing the uploaded file in session resources.

#### Endpoint

<mark style="color:green;">`POST`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_uploads`

#### Authentication

Authenticate using headers from your `~/.release.yaml` file. To set this up, [install the Release CLI](/cli/installation.md) and run `release auth login`.

| Header       | Description                                       |
| ------------ | ------------------------------------------------- |
| X-User-Email | User email from `~/.release.yaml` (`login` field) |
| X-User-Token | User token from `~/.release.yaml` (`token` field) |

#### Headers

| Header       | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| Accept       | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |

#### Request Body

| Field         | Type    | Required | Description                                                  |
| ------------- | ------- | -------- | ------------------------------------------------------------ |
| filename      | string  | Yes      | Name of the file to upload                                   |
| content\_type | string  | Yes      | MIME type of the file (e.g. `text/plain`, `application/zip`) |
| size\_bytes   | integer | Yes      | File size in bytes (maximum 100 MB)                          |

**Example**

```json
{
  "filename": "data.txt",
  "content_type": "text/plain",
  "size_bytes": 1024
}
```

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 201  | Presigned URL generated                       |
| 401  | Unauthorized — invalid or missing credentials |
| 422  | Validation error (see error codes below)      |

#### Error Codes

| Code                | Description                                          |
| ------------------- | ---------------------------------------------------- |
| file\_too\_large    | File exceeds the 100 MB size limit                   |
| no\_upload\_cluster | No cluster is configured for uploads on this account |

#### Response Body

| Field               | Type   | Description                                                        |
| ------------------- | ------ | ------------------------------------------------------------------ |
| data.presigned\_url | string | URL to PUT the file content to                                     |
| data.s3\_uri        | string | S3 URI to reference when creating session resources of type `file` |

#### Example Responses

**201 Created**

```json
{
  "data": {
    "presigned_url": "https://s3.amazonaws.com/bucket/path?...",
    "s3_uri": "s3://bucket/path"
  }
}
```

**422 File Too Large**

```json
{
  "errors": [
    {
      "code": "file_too_large",
      "message": "File exceeds the 100 MB size limit"
    }
  ]
}
```

**422 No Upload Cluster**

```json
{
  "errors": [
    {
      "code": "no_upload_cluster",
      "message": "No cluster configured for uploads"
    }
  ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.release.com/reference-documentation/release-api/ai-sandbox-api/file-uploads.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
