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

# Introduction

> REST API for encoding and decoding `.serva` files straight from your own code.

The Serva Encoder API encodes files into the portable **`.serva`** format and decodes them back, straight from your own code. Every request goes through a single base URL.

> [!NOTE]
>
> The API is in **beta**, so endpoints and schemas may still change. For most
> cases the [Python SDK](https://pypi.org/project/serva/) is the smoothest way in
> — it wraps these endpoints and handles the streaming flow for you.

## Base URL

All requests use one production host — auth, encode, decode, and download.

```
https://serva.servamind.com
```

## Authentication

Generate a **Service API key** from the [dashboard](https://serva.servamind.com) (Settings → API keys) or via `POST /keys`, then send it as a Bearer token on every request:

```bash theme={null}
curl https://serva.servamind.com/api/usage \
  -H "Authorization: Bearer sk_live_..."
```

The web app authenticates with a `session` cookie set at login. For programmatic access, use a Service API key.

## Encode

With the SDK, encoding a file is a single call — it runs the initiate, stream, and download steps for you.

```python theme={null}
from serva import Serva

client = Serva(api_key="sk_live_...")   # or set SERVA_API_KEY

result = client.encode("dataset.parquet")
print(result.output_path, result.savings_percent)
```

Under the hood this maps to `POST /api/encode` → `POST /api/stream/{file_reference}` → `GET /download/{file_id}`. See those endpoints in the sidebar for the raw request and response schemas.

## Decode

```python theme={null}
result = client.decode("dataset.serva")
print(result.output_path)
```

Files encoded now carry no password, so decoding needs none. A `.serva` issued while encoding still locked files takes the key it was encoded with:

```python theme={null}
client.decode("older.serva", password="my-secret")
```

That password goes directly to the backend over TLS via `X-Decode-Password`. It is never written to Redis or any persistent storage.

## Errors

Failed requests return a JSON body with a `detail` message and a standard HTTP status.

| Status | Meaning |
| - | - |
| `401` | Missing, invalid, or expired credentials |
| `403` | A payment method is required to continue |
| `413` | File exceeds the maximum allowed size |
| `429` | Rate limited — retry after `Retry-After` seconds |

Browse the full endpoint reference in the sidebar.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.