# Overview

Canonical URL: https://developers.iagenify.com/sdk/ref/files/
Language: en

Files kept on the account: created locally, saved to a storage, read back, replaced, deleted.

Status: 4 methods · 2 on the file · 1 credit to save · reading is free

The shape is unusual and worth a sentence: `create()` makes nothing anywhere. It hands you an object you fill, and `save()` is what reaches the server. That separation is what lets the same object be written to disk, to the account, or to both.

## The surface {#methods}

| Call | Does | Costs |
| --- | --- | --- |
| api.files.create({ name, content, mimeType }) | Builds a file object. No network. | nothing |
| file.save({ storageId, path, localOnly }) | Writes it — to the account, to disk, or both. | 1 credit |
| file.update() | Replaces the content of one already saved. | nothing |
| api.files.get(sourceId) | Reads one back, content included. | nothing |
| api.files.list() | Every file on the account. | nothing |
| api.files.delete(sourceId) | Removes it, and what was indexed from it. | nothing |

## End to end {#walk}

```javascript
// 1. Build it — nothing has happened yet
const file = api.files.create({
  name: "report.md",
  content: "# Q4\n\nRevenue was…",
  mimeType: "text/markdown",
});

// 2. Save it — this is the call that spends
const saved = await file.save();
saved.sourceId;      // how you will find it again
file.sourceId;       // the object learned its own id

// 3. Read it back, anywhere
const again = await api.files.get(saved.sourceId);
again.content;       // "# Q4\n\nRevenue was…"

// 4. Replace its content
again.content = "# Q4\n\nRevised.";
await again.update();

// 5. Remove it
await api.files.delete(saved.sourceId);
```

## Where a file actually goes {#where}

To the account's default storage, unless you name another with `storageId`. One kind of storage cannot take it at all.

> **A computer or a phone keeps its own files**
>
> Saving to one through the server is refused with storage_is_local, before any credit is spent — not a failure, a statement: those bytes live on that device. Read and write them from the device itself.

Which means `api.files` is for files on the account. For a machine's own files, see [LocalFiles](/sdk/ref/local-files); for an object storage's contents, [storage.run()](/sdk/ref/connected-storage/run).

## The category is deduced, not declared {#category}

| mimeType | category |
| --- | --- |
| image/* | image |
| audio/* | audio |
| video/* | video |
| json · yaml · xml · csv | data |
| anything else | document |

It matters for one reason: a `document` is indexed for semantic search after it is saved, so it can be found by meaning later. Nothing else is.

## Two things worth knowing before you build on it {#two}

- **Saving costs one credit**, refunded in full if the write fails. Reading, listing and deleting cost nothing.
- **The file object is a handle you fill.** `create()` never touches the network, so a validation mistake surfaces at `save()`.

- [file.save()](/sdk/ref/files/save): The call that writes, and the three ways to use it.
- [get()](/sdk/ref/files/get): Reading one back, text or binary.
- [api.storage](/sdk/ref/storage): The places a file can be saved to.

```python
# 1. Build it — nothing has happened yet
file = api.files.create(
    name="report.md",
    content="# Q4\n\nRevenue was…",
    mime_type="text/markdown",
)

# 2. Save it — this is the call that spends
saved = file.save()
saved["sourceId"]    # how you will find it again
file.source_id       # the object learned its own id

# 3. Read it back, anywhere
again = api.files.get(saved["sourceId"])
again.content        # "# Q4\n\nRevenue was…"

# 4. Replace its content
again.content = "# Q4\n\nRevised."
again.update()

# 5. Remove it
api.files.delete(saved["sourceId"])
```
