> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kept.computer/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://docs.kept.computer/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://docs.kept.computer/api/mcp.
> Every agent surface: https://docs.kept.computer/.well-known/llms-manifest.json

# HTTP API reference (/documentation/connect-ai-coding-tools/http-api)

<!-- agent-signals: reading_time_min: 11 · est_tokens: 4725 · updated: 2026-12-05 -->
Related: [MCP server](/documentation/connect-ai-coding-tools/connect-claude-code-and-cursor-over-mcp.md)

The Kept API lets scripts and apps on the Mac that runs Kept ask questions, search passages and list sources. The API is read-only and returns JSON over HTTP. AI agents can use the [MCP server](./mcp-server), which shares the same keys and limits.

The API is off by default. Turn it on in Settings → Sharing → Let apps and AI tools on this Mac use Kept.

The base URL is:

```text
http://127.0.0.1:47822/v1
```

The MCP endpoint is separate from `/v1`: `POST /mcp`.

## Authentication

Every request needs an API key in the `Authorization` header as a bearer token. Make one key per tool or person in Settings → Sharing so you can revoke one without affecting the others.

* Keys start with `kept_` and are 69 characters long.
* Kept shows each key once, when you make it, and stores only its SHA-256 hash.
* Revoking a key stops it on the next request.
* Settings shows when each key was last used, updated every few minutes rather than on every request.

A missing or unknown key returns `401` with a `WWW-Authenticate: Bearer` header.

Send the bearer token as shown in these authenticated requests:

<CodeGroup>
```bash title="cURL"
curl http://127.0.0.1:47822/v1/status \
  -H "Authorization: Bearer kept_3f9a1c…"
```

```javascript title="JavaScript"
const res = await fetch("http://127.0.0.1:47822/v1/status", {
  headers: { Authorization: `Bearer ${process.env.KEPT_KEY}` },
});
```

```python title="Python"
import os, requests

res = requests.get(
    "http://127.0.0.1:47822/v1/status",
    headers={"Authorization": f"Bearer {os.environ['KEPT_KEY']}"},
)
```
</CodeGroup>

## Errors

Kept uses ordinary HTTP status codes. Errors have a JSON body with one field, `error`, a sentence you can show to a person. In every response, Kept omits fields with no value rather than sending them as `null`.

| Status | Meaning                                                                                      |
| ------ | -------------------------------------------------------------------------------------------- |
| `200`  | OK.                                                                                          |
| `400`  | Bad input: not JSON, a missing field, an empty or too-long question.                         |
| `401`  | Missing or unknown API key.                                                                  |
| `402`  | The trial or subscription has ended. Search and ask stop; status and sources still work.     |
| `403`  | The API is turned off, the `Host` isn't a loopback name, or the request came from a website. |
| `404`  | No such route.                                                                               |
| `405`  | Wrong method. The `Allow` header says which one to use.                                      |
| `413`  | The body is larger than 64 KB.                                                               |
| `429`  | Rate limit reached for this key.                                                             |
| `500`  | Something went wrong inside Kept.                                                            |
| `502`  | The AI engine reported a problem.                                                            |
| `503`  | Kept's AI isn't set up, its engine isn't running, or its model isn't installed.              |

A request after the free trial ends can return this error:

```http
HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "error": "Your free trial has ended. The owner can subscribe at kept.computer; the documents are all still there."
}
```

## Rate limits

Each key can make **120 requests a minute**, of which **20 can be questions** (`POST /v1/ask` or the MCP `ask` tool), since each question runs the local model. Give each tool its own key. Over the limit, Kept returns `429`; wait a moment and retry.

### Other limits

* Request bodies: 64 KB.
* Questions and queries: 2,000 characters.
* Search results: 20 passages.

If a key exceeds the question limit, Kept returns this error body:

```json
{
  "error": "Too many questions in the last minute. Wait a moment and try again."
}
```

## Get status

<Badge>GET /v1/status</Badge>

Check that Kept is running and your key works. The response includes the team name, source count, model and whether Kept can answer questions right now.

### Parameters

None.

### Returns

| Attribute   | Type             | Description                                                                            |
| ----------- | ---------------- | -------------------------------------------------------------------------------------- |
| `app`       | string           | Always `Kept`.                                                                         |
| `version`   | string           | Kept's version.                                                                        |
| `business`  | string           | The team's name from Settings → General. May be empty.                                 |
| `sources`   | integer          | How many sources Kept has.                                                             |
| `chatModel` | string, optional | The model that writes answers.                                                         |
| `license`   | string           | The trial or subscription, in words, for example `Subscribed · renews by Dec 9, 2026`. |
| `canAsk`    | boolean          | Whether search and ask will work. `false` after the trial or subscription ends.        |

Send an authenticated request to get the current status:

<CodeGroup>
```bash title="cURL"
curl http://127.0.0.1:47822/v1/status \
  -H "Authorization: Bearer $KEPT_KEY"
```

```javascript title="JavaScript"
const res = await fetch("http://127.0.0.1:47822/v1/status", {
  headers: { Authorization: `Bearer ${process.env.KEPT_KEY}` },
});
const status = await res.json();
```

```python title="Python"
status = requests.get(
    "http://127.0.0.1:47822/v1/status",
    headers={"Authorization": f"Bearer {KEPT_KEY}"},
).json()
```
</CodeGroup>

Example response:

```json
{
  "app": "Kept",
  "version": "0.1.0",
  "business": "Acme Platform",
  "sources": 214,
  "chatModel": "qwen3.5:9b",
  "license": "Subscribed · renews by Dec 9, 2026",
  "canAsk": true
}
```

## The source object

A source is a document Kept has read.

| Attribute  | Type              | Description                                                                            |
| ---------- | ----------------- | -------------------------------------------------------------------------------------- |
| `id`       | integer           | Kept's ID for the source.                                                              |
| `name`     | string            | The display name, usually the file name.                                               |
| `type`     | string            | The file type: `pdf`, `docx`, `rtf`, `txt`, `md`, `html` or `image`.                   |
| `category` | string, optional  | Its category, if it has one.                                                           |
| `status`   | string            | `ready` (searchable), `noText` (nothing readable found) or `error` (couldn't be read). |
| `pages`    | integer, optional | Page count, for paged formats.                                                         |
| `addedAt`  | string            | When it was added, ISO 8601 in UTC.                                                    |

Example source object:

```json
{
  "id": 42,
  "name": "payments-runbook.md",
  "type": "md",
  "category": "Runbooks",
  "status": "ready",
  "addedAt": "2026-11-05T12:28:29Z"
}
```

## List sources

<Badge>GET /v1/sources</Badge>

List every source Kept has. This endpoint works after the trial or subscription ends.

### Parameters

None.

### Returns

An object with `sources`, a list of [source objects](#the-source-object).

Send an authenticated request to list the sources:

<CodeGroup>
```bash title="cURL"
curl http://127.0.0.1:47822/v1/sources \
  -H "Authorization: Bearer $KEPT_KEY"
```

```javascript title="JavaScript"
const { sources } = await fetch("http://127.0.0.1:47822/v1/sources", {
  headers: { Authorization: `Bearer ${process.env.KEPT_KEY}` },
}).then((r) => r.json());
```

```python title="Python"
sources = requests.get(
    "http://127.0.0.1:47822/v1/sources",
    headers={"Authorization": f"Bearer {KEPT_KEY}"},
).json()["sources"]
```
</CodeGroup>

Example response (abbreviated):

```json
{
  "sources": [
    {
      "id": 42,
      "name": "payments-runbook.md",
      "type": "md",
      "category": "Runbooks",
      "status": "ready",
      "addedAt": "2026-11-05T12:28:29Z"
    },
    …
  ]
}
```

## The passage object

A passage is a short piece of a source, a few paragraphs long, as Kept indexed it.

| Attribute              | Type              | Description                                                                                                     |
| ---------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------- |
| `source`               | string            | The source's name.                                                                                              |
| `category`             | string, optional  | The source's category.                                                                                          |
| `pageStart`, `pageEnd` | integer, optional | The pages the passage spans, for paged formats.                                                                 |
| `heading`              | string, optional  | The nearest heading above the passage.                                                                          |
| `text`                 | string            | The passage, word for word.                                                                                     |
| `relevance`            | number            | How close it is to the query in meaning, from 0 to 1. Use it to rank passages rather than as an absolute score. |

Example passage object:

```json
{
  "source": "payments-runbook.md",
  "category": "Runbooks",
  "heading": "Rolling back",
  "text": "To roll back, run deploy rollback payments --to previous, then watch the error-rate dashboard for 10 minutes…",
  "relevance": 0.812
}
```

## Search passages

<Badge>POST /v1/search</Badge>

Get the passages most relevant to a query, best first. Search skips answer generation, so use it when your code or model needs the source text directly.

### Body parameters

| Name    | Type    | Required | Description                                 |
| ------- | ------- | -------- | ------------------------------------------- |
| `query` | string  | Yes      | What to look for. Up to 2,000 characters.   |
| `limit` | integer | No       | How many passages, from 1 to 20. Default 6. |

### Returns

An object with `passages`, a list of [passage objects](#the-passage-object). Returns `402` after the trial or subscription ends.

Request up to three passages about a payments rollback:

<CodeGroup>
```bash title="cURL"
curl http://127.0.0.1:47822/v1/search \
  -H "Authorization: Bearer $KEPT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "payments rollback", "limit": 3}'
```

```javascript title="JavaScript"
const { passages } = await fetch("http://127.0.0.1:47822/v1/search", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KEPT_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ query: "payments rollback", limit: 3 }),
}).then((r) => r.json());
```

```python title="Python"
passages = requests.post(
    "http://127.0.0.1:47822/v1/search",
    headers={"Authorization": f"Bearer {KEPT_KEY}"},
    json={"query": "payments rollback", "limit": 3},
).json()["passages"]
```
</CodeGroup>

Example response (abbreviated):

```json
{
  "passages": [
    {
      "source": "payments-runbook.md",
      "category": "Runbooks",
      "heading": "Rolling back",
      "text": "To roll back, run deploy rollback payments --to previous…",
      "relevance": 0.812
    },
    …
  ]
}
```

## The answer object

An answer from your documents, with its citations.

| Attribute              | Type                           | Description                                                                                                                                                                                                                                                                                   |
| ---------------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `kind`                 | string                         | `grounded` when the answer comes from your documents, `notFound` when they don't cover the question.                                                                                                                                                                                          |
| `answer`               | string                         | The answer, with `[n]` markers that match `citations`. For `notFound`, a sentence saying so.                                                                                                                                                                                                  |
| `citations`            | array                          | The passages the answer relies on. If the model wrote no `[n]` markers, the array holds the few passages Kept found closest to the question. Treat these as the passages the model read. They don't show which passage supports each sentence.                                                |
| `citationsAreExplicit` | boolean, from the next release | `true` when each citation matches an `[n]` marker in the answer; `false` when the answer has no markers and `citations` are the closest passages Kept found. Until the next release, Kept omits this field. Treat a missing field as unknown and check the answer for `[n]` markers yourself. |
| `notice`               | string, optional               | A note to show with the answer, when Kept has one. For example, when the question names a category and nothing in it answers, Kept answers from your other documents and says so here.                                                                                                        |
| `pinned`               | boolean                        | Only present, and `true`, when the owner pinned (approved) the answer. Kept serves it without running the model.                                                                                                                                                                              |

### Citation attributes

| Attribute              | Type              | Description                                                  |
| ---------------------- | ----------------- | ------------------------------------------------------------ |
| `number`               | integer           | Matches an `[n]` in the answer, when the answer has markers. |
| `source`               | string            | The source's name.                                           |
| `category`             | string, optional  | The source's category.                                       |
| `pageStart`, `pageEnd` | integer, optional | Pages, for paged formats.                                    |
| `quote`                | string            | The cited passage, or the part of it that matters.           |

Example answer object:

```json
{
  "kind": "grounded",
  "answer": "Roll back with the deploy tool's previous release, then confirm the error rate drops within 10 minutes [1].",
  "citations": [
    {
      "number": 1,
      "source": "payments-runbook.md",
      "category": "Runbooks",
      "quote": "To roll back, run deploy rollback payments --to previous, then watch the error-rate dashboard for 10 minutes."
    }
  ]
}
```

## Ask a question

<Badge>POST /v1/ask</Badge>

Ask a question and get an answer from your documents, the same way the app does. A local model writes the answer, so a request takes 5 to 60 seconds. Set your client's timeout to match. Pinned answers come back at once.

Kept doesn't save API questions in its history or show them on the Gaps page.

### Body parameters

| Name       | Type   | Required | Description                                              |
| ---------- | ------ | -------- | -------------------------------------------------------- |
| `question` | string | Yes      | The question, in plain language. Up to 2,000 characters. |

### Returns

An [answer object](#the-answer-object). The request counts toward the 20 questions a minute. Returns `402` after the trial or subscription ends, and `503` if the AI engine isn't running.

Ask how to roll back a payments deploy:

<CodeGroup>
```bash title="cURL"
curl http://127.0.0.1:47822/v1/ask \
  -H "Authorization: Bearer $KEPT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question": "How do we roll back a payments deploy?"}'
```

```javascript title="JavaScript"
const answer = await fetch("http://127.0.0.1:47822/v1/ask", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KEPT_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ question: "How do we roll back a payments deploy?" }),
  signal: AbortSignal.timeout(90_000),
}).then((r) => r.json());
```

```python title="Python"
answer = requests.post(
    "http://127.0.0.1:47822/v1/ask",
    headers={"Authorization": f"Bearer {KEPT_KEY}"},
    json={"question": "How do we roll back a payments deploy?"},
    timeout=90,
).json()
```
</CodeGroup>

Example response:

```json
{
  "kind": "grounded",
  "answer": "Roll back with the deploy tool's previous release, then confirm the error rate drops within 10 minutes [1].",
  "citations": [
    {
      "number": 1,
      "source": "payments-runbook.md",
      "category": "Runbooks",
      "quote": "To roll back, run deploy rollback payments --to previous…"
    }
  ]
}
```

## Security

* Kept listens on `127.0.0.1`. Other computers can't reach port 47822.
* `Host` must be `127.0.0.1`, `localhost` or `[::1]`, which stops DNS rebinding. Any `Origin` must be a loopback `http://` origin. Browsers can't send `Authorization` cross-site without a CORS preflight, which Kept never approves.
* Nothing in the API can add, change or delete documents or settings.
* Passages and answers contain your documents' words. If you pass them to an AI with tools, treat them as untrusted data rather than instructions.

See [Privacy and network](./privacy-and-network).
