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

# API Quickstart

> Get up and running with the OpenFiles REST API in 5 minutes.

## 1. Get Your API Key

<Steps>
  <Step title="Sign up">
    Create your account at [console.openfiles.ai](https://console.openfiles.ai)
  </Step>

  <Step title="Create API Key">
    Navigate to **API Keys** → **Create API Key**
  </Step>

  <Step title="Copy Your Key">
    Copy your API key (starts with `oa_`) and store it securely
  </Step>
</Steps>

## 2. Make Your First API Call

Let's create your first file:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.openfiles.ai/functions/v1/api/files" \
    -H "Content-Type: application/json" \
    -H "x-api-key: oa_your_api_key_here" \
    -d '{
      "path": "hello-world.txt",
      "content": "Hello from OpenFiles API!",
      "contentType": "text/plain"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.openfiles.ai/functions/v1/api/files', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': 'oa_your_api_key_here'
    },
    body: JSON.stringify({
      path: 'hello-world.txt',
      content: 'Hello from OpenFiles API!',
      contentType: 'text/plain'
    })
  })

  const result = await response.json()
  console.log(result)
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.openfiles.ai/functions/v1/api/files"
  headers = {
      "Content-Type": "application/json",
      "x-api-key": "oa_your_api_key_here"
  }

  data = {
      "path": "hello-world.txt",
      "content": "Hello from OpenFiles API!",
      "contentType": "text/plain"
  }

  response = requests.post(url, json=data, headers=headers)
  result = response.json()
  print(result)
  ```
</CodeGroup>

## 3. Read Your File Back

Now let's read the file we just created:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.openfiles.ai/functions/v1/api/files/hello-world.txt" \
    -H "x-api-key: oa_your_api_key_here"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.openfiles.ai/functions/v1/api/files/hello-world.txt', {
    headers: {
      'x-api-key': 'oa_your_api_key_here'
    }
  })

  const file = await response.json()
  console.log(file.data.content) // "Hello from OpenFiles API!"
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.openfiles.ai/functions/v1/api/files/hello-world.txt"
  headers = {"x-api-key": "oa_your_api_key_here"}

  response = requests.get(url, headers=headers)
  file = response.json()
  print(file['data']['content'])  # "Hello from OpenFiles API!"
  ```
</CodeGroup>

## 4. List All Your Files

See all files in your project:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.openfiles.ai/functions/v1/api/files" \
    -H "x-api-key: oa_your_api_key_here"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.openfiles.ai/functions/v1/api/files', {
    headers: {
      'x-api-key': 'oa_your_api_key_here'
    }
  })

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

  ```python Python theme={null}
  import requests

  url = "https://api.openfiles.ai/functions/v1/api/files"
  headers = {"x-api-key": "oa_your_api_key_here"}

  response = requests.get(url, headers=headers)
  files = response.json()
  print(files['data']['files'])
  ```
</CodeGroup>

## Core Concepts

### File Paths

* Use S3-style paths: `documents/report.pdf` ✅
* No leading slashes: `/documents/report.pdf` ❌
* Forward slashes on all platforms

### Versioning

* Every write creates a new version automatically
* Access specific versions: `GET /files/report.pdf?version=2`
* Version history: `GET /files/report.pdf?versions`

### Content Types

* Auto-detected from file extension
* Or specify explicitly: `"contentType": "application/json"`
* Supports text and binary files

## Common Patterns

### Organize Files with Folders

```json theme={null}
{
  "path": "projects/website/src/index.html",
  "content": "<!DOCTYPE html>...",
  "contentType": "text/html"
}
```

### Edit Existing Files

```json theme={null}
{
  "oldString": "Hello World",
  "newString": "Hello OpenFiles"
}
```

### Append to Log Files

```json theme={null}
{
  "content": "\n2025-01-15 10:30:00 - User logged in"
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="File Operations" icon="file" href="/api-reference/files/write-file">
    Explore all 8 file operations
  </Card>

  <Card title="SDKs" icon="code" href="/guides/overview">
    Use our TypeScript or Python SDKs
  </Card>
</CardGroup>

Ready to build something amazing? Check out our complete [API reference](/api-reference/files/write-file) for all available operations!
