# TypeScript quickstart (/docs/sdks/typescript-quickstart)
In a few minutes you'll install `docklee`, write a memory with `Dock`, read it back with `Lynk`, and ask an engine a question, all from Node.js. The same code runs as plain JavaScript if you drop the type imports.

## Prerequisites [#prerequisites]

- Node.js 18+.
- An API key with the **Both** capability. See [API keys](/docs/docklee/api-keys).
- A memory space ID from **DUM**, and an engine ID from **Knowledge Engines**, in the [Docklee dashboard](https://app.docklee.com).

## Store and recall from TypeScript [#store-and-recall-from-typescript]

<Steps>
<Step>
### Install the package [#install-the-package]

```bash
npm install docklee
```
</Step>

<Step>
### Set your environment [#set-your-environment]

```bash
export DOCKLEE_API_KEY="your-api-key"
export DOCKLEE_MEMORY_SPACE_ID="your-memory-space-id"
export DOCKLEE_ENGINE_ID="your-engine-id"
```

`Dock` and `Lynk` read these on creation, so your code never holds the key.
</Step>

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

`capture` returns at once. `flush` sends the buffer and resolves with the result:

```ts
import { Dock } from 'docklee';

const dock = new Dock();
dock.capture('Maya prefers email over phone calls.', { type: 'preference', endUser: 'user_8f2c' });
const result = await dock.flush();
console.log(result?.accepted, result?.rejected);
```

```text
1 0
```
</Step>

<Step>
### Recall it [#recall-it]

```ts
import { Lynk } from 'docklee';

const lynk = new Lynk();
const records = await lynk.recall('How does Maya like to be contacted?', { endUser: 'user_8f2c' });
for (const record of records) {
  console.log(record.confidence, record.content);
}
```

```text
0.87 Maya prefers email over phone calls.
```
</Step>

<Step>
### Ask an engine [#ask-an-engine]

```ts
import type { KnowledgeResult } from 'docklee';

const result = (await lynk.query('What is the refund window?')) as KnowledgeResult;
console.log(result.answer);
```

```text
Customers can request a refund within 30 days of purchase.
```
</Step>
</Steps>

## Let your process exit [#let-your-process-exit]

`Dock` sends its buffer on a timer while it's open. Close it when you're done, so the timer stops and the last events are sent:

```ts
await dock.close();
```

<Callout type="warn">
Call the SDK from your server. An API key in browser code can be read by anyone who opens the page.
</Callout>

## Next steps [#next-steps]

You've used every part of the SDK once. Start with configuration, since every app sets it up a little differently.

<Cards>
  <Card title="Configuration" href="/docs/sdks/configuration" description="Environment variables and constructor options." />
  <Card title="TypeScript reference" href="/docs/sdks/typescript" description="Every class and method, with its options." />
  <Card title="Errors and retries" href="/docs/sdks/errors-and-retries" description="What's retried, and what's thrown." />
</Cards>
