# Saving files (https://brainapi.lumen-labs.ai/docs/v2/ingestion/files)

> For the complete BrainAPI documentation index, see [llms.txt](https://brainapi.lumen-labs.ai/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL (e.g. https://brainapi.lumen-labs.ai/docs/v2/ingestion/files.md).

How to save files to the memory store

Ingesting files is useful when you have information stored in documents and you don't want to implement a pipeline yourself to extract textual information from them.
You just need to send the files to the ingestion API and the system will take care of going through a complete OCR process to extract the textual information from the files.

`POST /ingest/file` returns **202 Accepted** with `{ "message": "File ingestion accepted", "task_id": "…" }`. Poll with [ingestion tasks](https://brainapi.lumen-labs.ai/docs/v2/ingestion/tasks).

<AgentNote>
- `POST /ingest/file` as multipart form (`file` + brain fields), auth with `BrainPAT`
- One file per request; accepted: pdf, doc/docx, xls/xlsx, txt, csv, json, jpg, png
- **202** + `task_id` → poll `GET /tasks/{id}`; **404** ≠ pending
</AgentNote>

<Callout type="info">
  The accepted file types are: PDF (.pdf), DOC (.doc), DOCX (.docx), XLS (.xls),
  XLSX (.xlsx), TXT (.txt), CSV (.csv), JSON (.json), JPG (.jpg), and PNG
  (.png).
</Callout>

## Usage

The file ingestion API is available via the REST API, Python SDK, and TypeScript SDK.
It accepts one file at a time and will process it one page at a time.

<Tabs items={["Typescript", "Python", "cURL"]}>
  <Tab value="Typescript">
    The Typescript SDK provides the `ingestFile` function to ingest a file.
    <DynamicCodeBlock
      lang="ts"
      code={`
const result = await brain.ingestFile({
    file: "path/to/file.pdf",
    brain_id: "example01",
});`}
    />
  </Tab>
  <Tab value="Python">
    The Python SDK provides the `ingest_file` method to ingest a file.
    <DynamicCodeBlock
      lang="py"
      code={`result = await client.ingest_file(
    file="path/to/file.pdf",
    brain_id="example01",
)`}
    />
  </Tab>
  <Tab value="cURL">
    Upload a multipart file to `POST /ingest/file`. Expect HTTP 202 and a `task_id`.
    <DynamicCodeBlock
      lang="bash"
      code={`curl -X POST "<DEPLOYMENT_URL>/ingest/file" \\
      -H "X-Brain-ID: mybrain123" \\
      -H "BrainPAT: YOUR_BRAIN_PAT" \\
      -F "file=@/absolute/path/to/your-file.pdf"
# → {"message":"File ingestion accepted","task_id":"…"}`}
    />
  </Tab>
</Tabs>

<Callout type="info">
  After 202, poll `GET /tasks/` with the returned task id until the job finishes.
  A missing task returns **404**. See [Ingestion tasks](https://brainapi.lumen-labs.ai/docs/v2/ingestion/tasks).
</Callout>
