# Memory.deleteMessages()

The `.deleteMessages()` method deletes multiple messages by their IDs.

## Usage example

```typescript
await memory?.deleteMessages(['671ae63f-3a91-4082-a907-fe7de78e10ec'])
```

## Parameters

**messageIds** (`string[]`): Array of message IDs to delete

## Returns

**void** (`Promise<void>`): A promise that resolves when all messages are deleted

## Extended usage example

```typescript
import { mastra } from './mastra'
import { MastraDBMessage } from '@mastra/core'

const agent = mastra.getAgent('agent')
const memory = await agent.getMemory()

const { messages } = await memory!.recall({ threadId: 'thread-123' })

const messageIds = messages.map((message: MastraDBMessage) => message.id)
await memory?.deleteMessages([...messageIds])
```

## Related

- [Memory Class Reference](https://mastra.ai/reference/memory/memory-class)
- [recall](https://mastra.ai/reference/memory/recall)
- [Getting Started with Memory](https://mastra.ai/docs/memory/overview)