# File Uploads & Downloads

The AI can upload files to Inistate entries and retrieve download links for existing files. Both operations work in all three modes.

## Uploading a File

The AI uses a three-step presigned upload flow that supports files up to **500 MB**.

{% stepper %}
{% step %}

### Request an upload URL

The AI calls `request_upload_url` with the file name, MIME type, and size. Inistate returns a pre-signed S3 URL valid for approximately 1 hour.
{% endstep %}

{% step %}

### Upload the file to S3

The AI sends the file bytes directly to the S3 URL. The Content-Type header must match exactly.
{% endstep %}

{% step %}

### Confirm the upload

The AI calls `confirm_upload` with the `s3Key` returned in step 1. Inistate verifies the file is in S3 and returns the file path used in entry field values.
{% endstep %}
{% endstepper %}

After confirmation, the AI attaches the file to the entry by including the path in a `submit_activity` call.

{% tabs %}
{% tab title="Example prompts" %}

> "Attach this PDF to invoice INV-1042."

> "Upload the signed contract to PO-0234."

> "Add a photo to this equipment inspection entry."
> {% endtab %}

{% tab title="What the AI does" %}

1. Calls `request_upload_url` with the file details
2. Performs the S3 PUT
3. Calls `confirm_upload` to finalize
4. Calls `submit_activity` (edit activity) with the file path set on the relevant File or Image field
   {% endtab %}
   {% endtabs %}

{% hint style="info" %}
Supported file types include documents, images, spreadsheets, and most common formats. Executable files (`.exe`, `.bat`, `.cmd`, `.dll`, `.msi`) are blocked.
{% endhint %}

## Downloading a File

To retrieve an existing file from an entry, the AI requests a pre-signed download URL that expires after **1 hour**.

{% tabs %}
{% tab title="Example prompts" %}

> "Download the attachment from invoice INV-1042."

> "Get the signed contract from PO-0234."

> "Show me the photo attached to inspection entry INS-0012."
> {% endtab %}

{% tab title="What the AI does" %}

1. Calls `get_entry` to find the file path stored in the File or Image field
2. Calls `download_file` with the module name, file GUID, and filename
3. Returns a pre-signed URL you can open in your browser
   {% endtab %}
   {% endtabs %}

{% hint style="warning" %}
Download links expire after 1 hour. If you need to share a file, do so promptly after requesting the link.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://inistate.gitbook.io/home/mcp-integration/file-uploads.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
