# Put a file into Elaichi

> Source: https://elaichi.ai/docs/api-reference/files/file/createfile/

`POST /file`

Resource: **File** · API: **Files**

## Query parameters

- **`filename`** _(string)_
  Same as `X-Filename`, for a client that cannot set headers.

## Request body

- **`filename`** _(string)_
- **`content`** _(string)_
- **`encoding`** _(string)_
  Allowed: `utf8`, `base64`
- **`mime`** _(string)_

## Response body

- **`file`** _(object)_
  - **`file_id`** _(string)_
  - **`status`** _(string)_
    `pending`: an upload link you made is waiting for its bytes (not a file yet: no type, size or URL). `ready`: a file you can open. `expired`: your link ran out unused, or the file it filled is gone.
    Allowed: `pending`, `ready`, `expired`
  - **`filename`** _(string)_
  - **`mime`** _(string,null)_
  - **`size_bytes`** _(integer,null)_
  - **`expires_at`** _(string)_
  - **`url`** _(string,null)_
    The console download page, for a `ready` file.
  - **`origin`** _(string)_
    How the bytes got here: `tool` (a connector tool returned them), `upload` (a person chose it on the Files screen), `request` (a person handed it to an app that asked, through an upload request; `origin_host` is the app), `inline` (content an assistant wrote with `file.create`), `api` (a backend sent it to `POST /file` with a token), `url_import`, `web_fetch` (fetched from the web), `export` (produced by an export). Provenance for wording (“Uploaded by Dana”), never an access gate.
    Allowed: `tool`, `upload`, `request`, `inline`, `api`, `url_import`, `web_fetch`, `export`
  - **`origin_host`** _(string,null)_
    The web host an import or web fetch read from, or the asking app’s name for origin `request`; null otherwise.
  - **`max_bytes`** _(integer,null)_
    The link’s size limit while `pending`.
  - **`access`** _(string,null)_
    Allowed: `owner`, `view`, `null`
  - **`can_open`** _(boolean)_
  - **`can_delete`** _(boolean)_
  - **`can_share`** _(boolean)_
  - **`can_see_shares`** _(boolean)_
  - **`can_revoke_share`** _(boolean)_

## Code examples

### curl

```bash
curl -X POST 'https://api.elaichi.ai/file' \
  -H 'Authorization: Bearer $ELAICHI_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"filename":"your_filename","content":"your_content","encoding":"utf8","mime":"your_mime"}'
```

### JavaScript

```javascript
const body = {
  "filename": "your_filename",
  "content": "your_content",
  "encoding": "utf8",
  "mime": "your_mime"
};

const response = await fetch('https://api.elaichi.ai/file', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ' + process.env.ELAICHI_API_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import os
import requests

url = "https://api.elaichi.ai/file"
headers = {
    "Authorization": f"Bearer {os.environ['ELAICHI_API_TOKEN']}",
    "Content-Type": "application/json",
}
payload = {
    "filename": "your_filename",
    "content": "your_content",
    "encoding": "utf8",
    "mime": "your_mime"
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```
