# Checkpoints

## Get Checkpoint Tuple

`client.checkpoints.getTuple(CheckpointGetTupleParamsbody, RequestOptionsoptions?): CheckpointGetTupleResponse | null`

**post** `/checkpoints/get-tuple`

Get Checkpoint Tuple

### Parameters

- `body: CheckpointGetTupleParams`

  - `thread_id: string`

  - `checkpoint_id?: string | null`

  - `checkpoint_ns?: string`

### Returns

- `CheckpointGetTupleResponse`

  - `checkpoint: Record<string, unknown>`

  - `checkpoint_id: string`

  - `checkpoint_ns: string`

  - `metadata: Record<string, unknown>`

  - `thread_id: string`

  - `blobs?: Array<Blob>`

    - `channel: string`

    - `type: string`

    - `version: string`

    - `blob?: string | null`

  - `parent_checkpoint_id?: string | null`

  - `pending_writes?: Array<PendingWrite>`

    - `channel: string`

    - `idx: number`

    - `task_id: string`

    - `blob?: string | null`

    - `type?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const response = await client.checkpoints.getTuple({ thread_id: 'thread_id' });

console.log(response.checkpoint_id);
```

#### Response

```json
{
  "checkpoint": {
    "foo": "bar"
  },
  "checkpoint_id": "checkpoint_id",
  "checkpoint_ns": "checkpoint_ns",
  "metadata": {
    "foo": "bar"
  },
  "thread_id": "thread_id",
  "blobs": [
    {
      "channel": "channel",
      "type": "type",
      "version": "version",
      "blob": "blob"
    }
  ],
  "parent_checkpoint_id": "parent_checkpoint_id",
  "pending_writes": [
    {
      "channel": "channel",
      "idx": 0,
      "task_id": "task_id",
      "blob": "blob",
      "type": "type"
    }
  ]
}
```

## Put Checkpoint

`client.checkpoints.put(CheckpointPutParamsbody, RequestOptionsoptions?): CheckpointPutResponse`

**post** `/checkpoints/put`

Put Checkpoint

### Parameters

- `body: CheckpointPutParams`

  - `checkpoint: Record<string, unknown>`

  - `checkpoint_id: string`

  - `thread_id: string`

  - `blobs?: Array<Blob>`

    - `channel: string`

    - `type: string`

    - `version: string`

    - `blob?: string | null`

  - `checkpoint_ns?: string`

  - `metadata?: Record<string, unknown>`

  - `parent_checkpoint_id?: string | null`

### Returns

- `CheckpointPutResponse`

  - `checkpoint_id: string`

  - `checkpoint_ns: string`

  - `thread_id: string`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const response = await client.checkpoints.put({
  checkpoint: { foo: 'bar' },
  checkpoint_id: 'checkpoint_id',
  thread_id: 'thread_id',
});

console.log(response.checkpoint_id);
```

#### Response

```json
{
  "checkpoint_id": "checkpoint_id",
  "checkpoint_ns": "checkpoint_ns",
  "thread_id": "thread_id"
}
```

## Put Writes

`client.checkpoints.putWrites(CheckpointPutWritesParamsbody, RequestOptionsoptions?): void`

**post** `/checkpoints/put-writes`

Put Writes

### Parameters

- `body: CheckpointPutWritesParams`

  - `checkpoint_id: string`

  - `thread_id: string`

  - `writes: Array<Write>`

    - `blob: string`

    - `channel: string`

    - `idx: number`

    - `task_id: string`

    - `task_path?: string`

    - `type?: string | null`

  - `checkpoint_ns?: string`

  - `upsert?: boolean`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

await client.checkpoints.putWrites({
  checkpoint_id: 'checkpoint_id',
  thread_id: 'thread_id',
  writes: [
    {
      blob: 'blob',
      channel: 'channel',
      idx: 0,
      task_id: 'task_id',
    },
  ],
});
```

## List Checkpoints

`client.checkpoints.list(CheckpointListParamsbody, RequestOptionsoptions?): CheckpointListResponse`

**post** `/checkpoints/list`

List Checkpoints

### Parameters

- `body: CheckpointListParams`

  - `thread_id: string`

  - `before_checkpoint_id?: string | null`

  - `checkpoint_ns?: string | null`

  - `filter_metadata?: Record<string, unknown> | null`

  - `limit?: number`

### Returns

- `CheckpointListResponse = Array<CheckpointListResponseItem>`

  - `checkpoint: Record<string, unknown>`

  - `checkpoint_id: string`

  - `checkpoint_ns: string`

  - `metadata: Record<string, unknown>`

  - `thread_id: string`

  - `parent_checkpoint_id?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const checkpoints = await client.checkpoints.list({ thread_id: 'thread_id' });

console.log(checkpoints);
```

#### Response

```json
[
  {
    "checkpoint": {
      "foo": "bar"
    },
    "checkpoint_id": "checkpoint_id",
    "checkpoint_ns": "checkpoint_ns",
    "metadata": {
      "foo": "bar"
    },
    "thread_id": "thread_id",
    "parent_checkpoint_id": "parent_checkpoint_id"
  }
]
```

## Delete Thread

`client.checkpoints.deleteThread(CheckpointDeleteThreadParamsbody, RequestOptionsoptions?): void`

**post** `/checkpoints/delete-thread`

Delete Thread

### Parameters

- `body: CheckpointDeleteThreadParams`

  - `thread_id: string`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

await client.checkpoints.deleteThread({ thread_id: 'thread_id' });
```

## Domain Types

### Checkpoint Get Tuple Response

- `CheckpointGetTupleResponse`

  - `checkpoint: Record<string, unknown>`

  - `checkpoint_id: string`

  - `checkpoint_ns: string`

  - `metadata: Record<string, unknown>`

  - `thread_id: string`

  - `blobs?: Array<Blob>`

    - `channel: string`

    - `type: string`

    - `version: string`

    - `blob?: string | null`

  - `parent_checkpoint_id?: string | null`

  - `pending_writes?: Array<PendingWrite>`

    - `channel: string`

    - `idx: number`

    - `task_id: string`

    - `blob?: string | null`

    - `type?: string | null`

### Checkpoint Put Response

- `CheckpointPutResponse`

  - `checkpoint_id: string`

  - `checkpoint_ns: string`

  - `thread_id: string`

### Checkpoint List Response

- `CheckpointListResponse = Array<CheckpointListResponseItem>`

  - `checkpoint: Record<string, unknown>`

  - `checkpoint_id: string`

  - `checkpoint_ns: string`

  - `metadata: Record<string, unknown>`

  - `thread_id: string`

  - `parent_checkpoint_id?: string | null`
