> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qontext.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Create a Markdown file and read its content back using cURL, Python, or JavaScript.

Create a small file in your context repository, then read it back by ID.

## 1. Create an API key

In the [Qontext app](https://app.qontext.ai), open **Clients → API Keys** and select **+ Create API key**. Copy the key and store it as an environment variable:

```bash theme={null}
export QONTEXT_API_KEY="your-api-key"
```

The key needs permission to create and read files at the example path. See [Authentication](/api-docs/authentication) for access controls.

## 2. Create a file

This request creates `/api-example/hello.md`. Missing parent folders are created automatically.

<CodeGroup>
  ```bash cURL theme={null}
  curl --fail-with-body https://api.qontext.ai/v1/files \
    -H "Authorization: Bearer $QONTEXT_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"path":"/api-example/hello.md","content":"# Hello\n\nCreated with the Qontext API."}'
  ```

  ```python Python theme={null}
  import json
  import os
  from urllib.request import Request, urlopen

  request = Request(
      "https://api.qontext.ai/v1/files",
      data=json.dumps({
          "path": "/api-example/hello.md",
          "content": "# Hello\n\nCreated with the Qontext API.",
      }).encode(),
      headers={
          "Authorization": f"Bearer {os.environ['QONTEXT_API_KEY']}",
          "Content-Type": "application/json",
      },
      method="POST",
  )
  with urlopen(request) as response:
      file = json.load(response)
  print(file["id"])
  ```

  ```javascript JavaScript (Node.js) theme={null}
  const response = await fetch("https://api.qontext.ai/v1/files", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.QONTEXT_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      path: "/api-example/hello.md",
      content: "# Hello\n\nCreated with the Qontext API.",
    }),
  });
  if (!response.ok) throw new Error(await response.text());
  const file = await response.json();
  console.log(file.id);
  ```
</CodeGroup>

A successful request returns `201` and a file object. These are the fields you need next:

```json theme={null}
{
  "id": "doc_9f2k1x8b3m7q0v",
  "path": "/api-example/hello.md",
  "lastChangeId": "chg_7t4p2w9c1n6s8k"
}
```

This is an excerpt; see [Create a file](/api-docs/files/create-file) for the full response. Save the returned `id` and `lastChangeId`.

<Note>
  Running the example again at the same path returns `409 path_already_exists`. Choose another path, or [find the existing file](/api-docs/files/list-files) with the `path` filter. Creating a file never overwrites existing content.
</Note>

## 3. Read the file

Replace the example ID with the `id` returned by your create request.

<CodeGroup>
  ```bash cURL theme={null}
  curl --fail-with-body https://api.qontext.ai/v1/files/doc_9f2k1x8b3m7q0v \
    -H "Authorization: Bearer $QONTEXT_API_KEY"
  ```

  ```python Python theme={null}
  request = Request(
      f"https://api.qontext.ai/v1/files/{file['id']}",
      headers={"Authorization": f"Bearer {os.environ['QONTEXT_API_KEY']}"},
  )
  with urlopen(request) as response:
      saved = json.load(response)
  print(saved["content"])
  ```

  ```javascript JavaScript (Node.js) theme={null}
  const read = await fetch(`https://api.qontext.ai/v1/files/${file.id}`, {
    headers: { Authorization: `Bearer ${process.env.QONTEXT_API_KEY}` },
  });
  if (!read.ok) throw new Error(await read.text());
  const saved = await read.json();
  console.log(saved.content);
  ```
</CodeGroup>

The Python and JavaScript examples continue from the previous step. The response includes the full `content` and the file's `lastChangeId`.

## Next steps

* [Update the file](/api-docs/updating-content) using the version you read.
* [Search your context](/api-docs/search/hybrid-search) by meaning. Newly written content may take a moment to become searchable.
* [Manage files and folders](/api-docs/files-and-folders) using stable IDs and paths.
