> ## Documentation Index
> Fetch the complete documentation index at: https://botmesh.afaya.com.co/llms.txt
> Use this file to discover all available pages before exploring further.

# DurabilityConfig

> Interface exported by @botmesh/core.

Defined in: [durability/types.ts:364](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L364)

`BotConfig.durability`. Every field is optional; `{}` enables durability with the in-memory backend.

## Properties

### backend?

```ts theme={null}
backend?: DurabilityBackend;
```

Defined in: [durability/types.ts:372](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L372)

Where the inbox and outbox records live: `MemoryDurability`, `FileDurability`, or a store's
backend (`new PostgresDurability({ pool })` from `@botmesh/postgres-store`,
`new RedisDurability({ client })` from `@botmesh/redis-store`, `SQLiteStore#durability()`,
or a `KvDurability` over any `DurableKv`). Default: a new
`MemoryDurability` (survives nothing but redeliveries within the process).

***

### ~~journal?~~

```ts theme={null}
journal?: DurabilityBackend;
```

Defined in: [durability/types.ts:377](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L377)

#### Deprecated

Use [DurabilityConfig.backend](#backend) (same value; the old name of the option).
Setting both to different backends throws a `ConfigValidationError`.

***

### instanceId?

```ts theme={null}
instanceId?: string;
```

Defined in: [durability/types.ts:388](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L388)

Lease owner of this process. Keep it STABLE across restarts of the same deployment
(a restarted process then reclaims its own in-flight records at once, without waiting
for their leases to expire) and UNIQUE per concurrently running replica (two live
processes with one id would take each other's leases).

Default: `<hostname>/<botId>/<connectionId>` on a single-process backend (memory, file);
on a shared backend (Postgres, Redis) that id plus a per-boot suffix, so two processes
on one host never share it — a restart then waits for the old leases to expire.

***

### failOpen?

```ts theme={null}
failOpen?: boolean;
```

Defined in: [durability/types.ts:394](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L394)

`false` (default): when the journal cannot record an inbound event, the event is NOT
dispatched (fail-closed) — an `'error'` is emitted and the dedupe key is released so
a transport redelivery is processed. `true`: dispatch it without the journal.

***

### inbox?

```ts theme={null}
inbox?: object;
```

Defined in: [durability/types.ts:395](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L395)

#### leaseMs?

```ts theme={null}
leaseMs?: string | number;
```

Processing lease (heartbeat-extended while the event is running). Default `60_000` ms.

#### maxAttempts?

```ts theme={null}
maxAttempts?: number;
```

Attempts before an event whose processing keeps failing is dead-lettered. Default `5`.

#### backoff?

```ts theme={null}
backoff?: RetryBackoff;
```

Backoff between failed attempts. Default `{ baseMs: 1000, capMs: 60000, jitter: 0.2 }`.

#### mediaRefs?

```ts theme={null}
mediaRefs?: boolean;
```

Journal a serializable reference to each message's media (`IProvider.serializeMediaRef`)
so a replayed message (crash recovery, background retry) can still download it
(`IProvider.rehydrateMediaRef`). Only applies to providers with those hooks. The
reference grants access to the media, like the message body stored next to it.
`false`: journal media tokens as they are, as before (a replayed message may then be
unable to download its media). Default `true`.

***

### outbox?

```ts theme={null}
outbox?: object;
```

Defined in: [durability/types.ts:412](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L412)

#### retries?

```ts theme={null}
retries?: number;
```

Retries after the first attempt before a send is dead-lettered. Default `5`.

#### backoff?

```ts theme={null}
backoff?: RetryBackoff;
```

Backoff between attempts (a `RateLimitedError` waits at least its `retryAfterMs`). Default as `inbox.backoff`.

#### inlineMaxMs?

```ts theme={null}
inlineMaxMs?: string | number;
```

How long a `ctx.reply` / `bot.send` keeps retrying inline before it rejects with
`SendDeferredError` and leaves the send to the background sweeper. Default `'15s'`.

#### onAmbiguous?

```ts theme={null}
onAmbiguous?: "skip" | "resend";
```

A send whose outcome is unknown after a crash (the provider was called, the result
was never recorded): `'skip'` (default) marks it `unknown` — possible loss, never a
duplicate; `'resend'` sends it again — never a loss, possible duplicate.

#### maxPayloadBytes?

```ts theme={null}
maxPayloadBytes?: number;
```

Encoded payloads above this size bypass the outbox (sent directly, with a warning). Default 1 MiB.

#### leaseMs?

```ts theme={null}
leaseMs?: string | number;
```

Lease of a send in flight (heartbeat-extended while the provider call runs). Default `60_000` ms.

#### onDiverged?

```ts theme={null}
onDiverged?: "send" | "skip";
```

A replayed handler whose n-th send differs from the one recorded under the same derived
key (`<inboundId>:<n>`) took another path (e.g. a non-persistent flow lost on a crash):
`'send'` (default) sends the new content under a new key — never a lost reply;
`'skip'` answers it with the recorded ref, as if it were the same send. Explicit
`idempotencyKey`s are never compared: the caller names the send.

***

### pollMs?

```ts theme={null}
pollMs?: string | number;
```

Defined in: [durability/types.ts:442](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L442)

Background sweeper period (retries, expired leases). Default `1000` ms.

***

### retention?

```ts theme={null}
retention?: string | number;
```

Defined in: [durability/types.ts:447](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L447)

Keep `done`/`sent` records this long before the sweeper purges them. It bounds how long
a late transport redelivery is still recognised as a duplicate. Default `'7d'`; `0` disables purging.


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