# Memory.deleteMessages()
[EN] Source: https://mastra.ai/reference/memory/deleteMessages

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

## Usage Example

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

## Parameters

<PropertiesTable
  content={[
    {
      name: "messageIds",
      type: "string[]",
      description: "Array of message IDs to delete",
      isOptional: false,
    },
  ]}
/>

## Returns

<PropertiesTable
  content={[
    {
      name: "void",
      type: "Promise<void>",
      description: "A promise that resolves when all messages are deleted",
    },
  ]}
/>

## Extended usage example

```typescript title="src/test-memory.ts" showLineNumbers copy
import { mastra } from "./mastra";
import { UIMessageWithMetadata } from "@mastra/core/agent";

const agent = mastra.getAgent("agent");
const memory = await agent.getMemory();

const { uiMessages } = await memory!.query({ threadId: "thread-123" });

const messageIds = uiMessages.map(
  (message: UIMessageWithMetadata) => message.id,
);
await memory?.deleteMessages([...messageIds]);
```

## Related

- [Memory Class Reference](/reference/memory/memory-class)
- [query](/reference/memory/query)
- [Getting Started with Memory](/docs/memory/overview)


---
title: "Reference: Memory.getThreadById() | Memory"
description: "Documentation for the `Memory.getThreadById()` method in Mastra, which retrieves a specific thread by its ID."
---