# Quickstart (/docs/docklee/quickstart)
In a few minutes you'll write a memory with `Dock`, read it back with `Lynk`, and then ask an engine a question about your own content. Every step works in Python, TypeScript, or cURL.

<Callout type="info" title="Building with an AI coding assistant?">
Claude Code, Cursor, Codex, and other assistants can read every page of these docs as plain Markdown from [/llms.txt](/llms.txt). Point your assistant there and it can follow this guide for you.
</Callout>

## Prerequisites [#prerequisites]

- A Docklee account. [Sign up](https://app.docklee.com) if you don't have one.
- An API key with the **Both** capability, created in **API Keys** in the dashboard. See [API keys](/docs/docklee/api-keys).
- A memory space, created in **DUM** in the dashboard. Copy its ID.
- Python 3.9+, Node.js 18+, or cURL.

## Store your first memory [#store-your-first-memory]

Pick a language tab below. Your choice carries over to every step on this page.

<Steps>
<Step>
### Install the SDK [#install-the-sdk]

<CodeTabs items={['Python', 'TypeScript', 'cURL']}>
  <Tab value="Python">
    ```bash
    pip install docklee
    ```
  </Tab>
  <Tab value="TypeScript">
    ```bash
    npm install docklee
    ```
  </Tab>
  <Tab value="cURL">
    cURL calls the REST API directly, so there's nothing to install. Check that it's available:

    ```bash
    curl --version
    ```
  </Tab>
</CodeTabs>
</Step>

<Step>
### Set your key and memory space [#set-your-key-and-memory-space]

The SDK reads both values from the environment, so your code never holds the key.

```bash
export DOCKLEE_API_KEY="your-api-key"
export DOCKLEE_MEMORY_SPACE_ID="your-memory-space-id"
```
</Step>

<Step>
### Write a memory [#write-a-memory]

`capture` adds the memory to a buffer, and `flush_sync()` or `close()` sends it.

<CodeTabs>
  <Tab value="Python">
    ```python
    from docklee import Dock

    dock = Dock()
    dock.capture("Maya prefers email over phone calls.", type="preference")
    result = dock.flush_sync()
    print(result)
    ```
  </Tab>
  <Tab value="TypeScript">
    ```ts
    import { Dock } from 'docklee';

    const dock = new Dock();
    dock.capture('Maya prefers email over phone calls.', { type: 'preference' });
    const result = await dock.flush();
    console.log(result);
    await dock.close();
    ```
  </Tab>
  <Tab value="cURL">
    ```bash
    curl https://api.docklee.com/v1/dock/ingest \
      -H "Authorization: Bearer $DOCKLEE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "memory_space_id": "'"$DOCKLEE_MEMORY_SPACE_ID"'",
        "events": [
          {"content": "Maya prefers email over phone calls.", "type": "preference"}
        ]
      }'
    ```
  </Tab>
</CodeTabs>

Docklee accepts the event and stores it in your memory space. The SDK returns the same counts as the API:

```json
{
  "batch_id": "3f6d2a1c-8b4e-4c2f-9a71-5e0b9c4d7a12",
  "accepted": 1,
  "rejected": 0,
  "errors": [],
  "usage": {
    "events_accepted": 1,
    "ke_events": 0,
    "dum_events": 1,
    "processing_time_ms": 412
  }
}
```
</Step>

<Step>
### Read it back [#read-it-back]

Ask a question in plain words. You don't need to match the stored text.

<CodeTabs>
  <Tab value="Python">
    ```python
    from docklee import Lynk

    lynk = Lynk()
    for record in lynk.recall_sync("How does Maya like to be contacted?"):
        print(record.content, record.confidence)
    ```
  </Tab>
  <Tab value="TypeScript">
    ```ts
    import { Lynk } from 'docklee';

    const lynk = new Lynk();
    const records = await lynk.recall('How does Maya like to be contacted?');
    for (const record of records) {
      console.log(record.content, record.confidence);
    }
    ```
  </Tab>
  <Tab value="cURL">
    ```bash
    curl https://api.docklee.com/v1/dum/search \
      -H "Authorization: Bearer $DOCKLEE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "memory_space_id": "'"$DOCKLEE_MEMORY_SPACE_ID"'",
        "query": "How does Maya like to be contacted?",
        "top_k": 5
      }'
    ```
  </Tab>
</CodeTabs>

The memory comes back with a confidence score, best match first:

```json
[
  {
    "id": "9b1e7c42-5d3a-4f08-b6e2-1a7c0d93e5f4",
    "content": "Maya prefers email over phone calls.",
    "memory_type": "entity",
    "confidence_score": 0.87
  }
]
```
</Step>
</Steps>

Place the recalled memories in your model's prompt, and its replies will reflect what your app already knows about Maya.

## Query your knowledge [#query-your-knowledge]

<Steps>
<Step>
### Write knowledge into a container [#write-knowledge-into-a-container]

A knowledge write declares a container instead of a memory space. A vector container also takes an embedding dimension.

<CodeTabs>
  <Tab value="Python">
    ```python
    from docklee import Dock

    dock = Dock(container="vector", dimension=1024)
    dock.capture("Refunds are available within 30 days of purchase.", type="knowledge")
    dock.flush_sync()
    ```
  </Tab>
  <Tab value="TypeScript">
    ```ts
    import { Dock } from 'docklee';

    const dock = new Dock({ container: 'vector', dimension: 1024 });
    dock.capture('Refunds are available within 30 days of purchase.', { type: 'knowledge' });
    await dock.close();
    ```
  </Tab>
  <Tab value="cURL">
    ```bash
    curl https://api.docklee.com/v1/dock/ingest \
      -H "Authorization: Bearer $DOCKLEE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "container": "vector",
        "dimension": 1024,
        "events": [
          {"content": "Refunds are available within 30 days of purchase.", "type": "knowledge"}
        ]
      }'
    ```
  </Tab>
</CodeTabs>

The first write to a container creates an **API/SDK Feed** source for it in **Sources**.
</Step>

<Step>
### Link the feed to an engine [#link-the-feed-to-an-engine]

In the dashboard, open **Knowledge Engines**, create an engine, and copy its ID. On the engine's **Sources** tab, add the **API/SDK Feed** source. An engine reads only the sources linked to it.

```bash
export DOCKLEE_ENGINE_ID="your-engine-id"
```
</Step>

<Step>
### Ask a question [#ask-a-question]

<CodeTabs>
  <Tab value="Python">
    ```python
    from docklee import Lynk

    lynk = Lynk()
    result = lynk.query_sync("How long do customers have to request a refund?")
    print(result.answer, result.confidence)
    ```
  </Tab>
  <Tab value="TypeScript">
    ```ts
    import { Lynk, type KnowledgeResult } from 'docklee';

    const lynk = new Lynk();
    const result = (await lynk.query(
      'How long do customers have to request a refund?',
    )) as KnowledgeResult;
    console.log(result.answer, result.confidence);
    ```
  </Tab>
  <Tab value="cURL">
    ```bash
    curl https://api.docklee.com/v1/engine/query \
      -H "Authorization: Bearer $DOCKLEE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "engine_id": "'"$DOCKLEE_ENGINE_ID"'",
        "query": "How long do customers have to request a refund?",
        "top_k": 8
      }'
    ```
  </Tab>
</CodeTabs>

The engine answers from the feed and cites the chunk it used:

```json
{
  "answer": "Customers can request a refund within 30 days of purchase.",
  "citations": [
    {
      "chunk_id": "c2a8f5e1-7b39-4d6c-a014-8e3f2b9d61c7",
      "page_number": null,
      "section_title": null
    }
  ],
  "confidence": 0.93
}
```
</Step>
</Steps>

<Callout type="idea" title="Capture without calling capture">
In a FastAPI or Express app, `dock.instrument(app)` captures write requests for you. See [Instrument your app](/docs/memory/automatic-capture/instrument).
</Callout>

## Troubleshooting [#troubleshooting]

| What you see | Why it happens | What to do |
| --- | --- | --- |
| `API key is required` | `DOCKLEE_API_KEY` isn't set in the shell that runs your code. | Export the key in that shell, or pass `api_key` (Python) or `apiKey` (TypeScript). |
| `memory_space_id is required for recall()` | `DOCKLEE_MEMORY_SPACE_ID` isn't set. | Export the space ID, or pass it to `Lynk`. |
| `401` | The key is wrong or revoked. | Copy a fresh key from **API Keys**. |
| `403` | The key's capability or scope doesn't cover this space or engine. | Use a key with **Both**, scoped to this space and engine. |
| Recall returns `[]` | The capture was never sent. | Call `flush_sync()` or `close()` after `capture`. |
| The answer ignores your knowledge | The feed isn't linked to the engine. | Add the **API/SDK Feed** source on the engine's **Sources** tab. |

## Next steps [#next-steps]

You've written a memory, recalled it, and queried an engine. Start with How Docklee works, since every call you make from here follows the same two paths.

<Cards>
  <Card title="How Docklee works" href="/docs/docklee/how-docklee-works" description="Where each write goes, and how it comes back." />
  <Card title="Capture memory" href="/docs/memory/capture-memory" description="Types, metadata, and per-user memory for every capture." />
  <Card title="Containers" href="/docs/docklee/containers" description="Pick vector or OKF, and the right dimension." />
  <Card title="API keys" href="/docs/docklee/api-keys" description="Narrow a key to the engines and spaces it needs." />
</Cards>

<Callout type="info">
Stuck on something else? See [FAQs](/docs/docklee/faqs).
</Callout>
